Skip to content

A self-hosted media server and file management system

fix: picture in picture state not updated by browser controls

aminnausinf34474390823
diff --git a/resources/js/components/video/VideoAmbientPlayer.vue b/resources/js/components/video/VideoAmbientPlayer.vue
index b45eb368..46b14524 100755
--- a/resources/js/components/video/VideoAmbientPlayer.vue
+++ b/resources/js/components/video/VideoAmbientPlayer.vue
@@ -116,10 +116,10 @@ watch(
<canvas
v-cloak
v-show="!lightMode && ambientMode && !isAudio"
- width="16"
- :height="isAudio ? '16' : '9'"
+ width="6"
+ :height="isAudio ? '6' : '4'"
aria-hidden="true"
- class="absolute opacity-100 blur-lg pointer-events-none w-full h-full"
+ class="absolute opacity-100 blur-xl pointer-events-none w-full h-full"
ref="canvas"
>
</canvas>
diff --git a/resources/js/components/video/VideoPlayer.vue b/resources/js/components/video/VideoPlayer.vue
index e428ddd6..24ee3d81 100755
--- a/resources/js/components/video/VideoPlayer.vue
+++ b/resources/js/components/video/VideoPlayer.vue
@@ -366,6 +366,7 @@ const onPlayerPlay = async (override = false, recordProgress = true) => {
updateViewCount(stateVideo.value.id);
handleProgress(true);
getEndTime();
+ resetControlsTimeout();
if (isMediaSession.value) navigator.mediaSession.playbackState = 'playing';
} catch (error) {
isLoading.value = false;
@@ -723,6 +724,17 @@ const handleKeyBinds = (event: KeyboardEvent, override = false) => {
}
};
+// Toggles PIP mode when triggered via native browser buttons. Needs to prevent default because the water for the PIP state manually sets PIP mode.
+const enterPictureInPicture = (e: Event) => {
+ e.preventDefault();
+ isPictureInPicture.value = true;
+};
+
+// Does not need to prevent default because the watcher exits PIP mode conditionally
+const leavePictureInPicture = (e: Event) => {
+ isPictureInPicture.value = false;
+};
+
watch(isPictureInPicture, async (value) => {
if (!player.value || isLoading.value) return;
@@ -818,6 +830,8 @@ defineExpose({
@waiting="onPlayerWaiting"
@timeupdate="handlePlayerTimeUpdate"
@click="handlePlayerToggle"
+ @enterpictureinpicture="enterPictureInPicture"
+ @leavepictureinpicture="leavePictureInPicture"
aria-describedby="Play/Pause"
controlsList="nodownload"
:src="stateVideo?.path ? `../${stateVideo?.path}` : ''"
@@ -1118,6 +1132,7 @@ defineExpose({
</div>
</Transition>
</section>
+
<!-- Tap Controls (Z-4) -->
<section :class="`text-xs font-mono select-none pointer-events-auto${controls ? ' cursor-auto' : ' cursor-none'}`" style="z-index: 4">
<span