Skip to content

Commit

Permalink
slight updates to player, expose stright play and pause
Browse files Browse the repository at this point in the history
  • Loading branch information
Digital authored and Digital committed May 16, 2024
1 parent 8012dcb commit 2f5e741
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions v2/src/components/VNewPersistentPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,30 @@ onMounted(() => {
// handle the toggle play event
const togglePlay = () => {
// Play or pause the sound.
if ($mediaPlayerRef.value && isPlaying.value) {
emit("toggle-play", false)
isPlaying.value = false
$mediaPlayerRef.value.pause()
} else {
isPlaying.value = true
emit("toggle-play", true)
if ($mediaPlayerRef.value && isPlayable.value) {
if (isPlaying.value) {
emit("toggle-play", false)
isPlaying.value = false
$mediaPlayerRef.value.pause()
} else {
isPlaying.value = true
emit("toggle-play", true)
$mediaPlayerRef.value.play()
}
}
}
// exposed method to handle the play
const play = () => {
if ($mediaPlayerRef.value && isPlayable.value) {
$mediaPlayerRef.value.play()
}
}
// exposed method to handle the pause
const pause = () => {
if ($mediaPlayerRef.value && isPlayable.value) {
$mediaPlayerRef.value.pause()
}
}
// exposed method to handle the minimize toggle
const toggleMinimize = (e) => {
Expand Down Expand Up @@ -725,6 +739,8 @@ defineExpose({
togglePlay,
jumpToTime,
$mediaPlayerRef,
play,
pause,
})
</script>

Expand Down

0 comments on commit 2f5e741

Please sign in to comment.