From 2f5e7419150de7db03ac0114fcb448b51c7c5463 Mon Sep 17 00:00:00 2001 From: Digital Date: Thu, 16 May 2024 14:15:08 -0400 Subject: [PATCH] slight updates to player, expose stright play and pause --- v2/src/components/VNewPersistentPlayer.vue | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/v2/src/components/VNewPersistentPlayer.vue b/v2/src/components/VNewPersistentPlayer.vue index d6171b1..960550b 100644 --- a/v2/src/components/VNewPersistentPlayer.vue +++ b/v2/src/components/VNewPersistentPlayer.vue @@ -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) => { @@ -725,6 +739,8 @@ defineExpose({ togglePlay, jumpToTime, $mediaPlayerRef, + play, + pause, })