From 98e684b954f03bd9308b1e23d4ca2f9f8545ab37 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Wed, 12 Feb 2025 20:15:09 +0100 Subject: [PATCH] Apply MediaSession fixes to all videos Wolvic has an internal extension which feeds the navigator.mediaSession object with progress information. It was initially developed to get progress information for the progress bar that is shown on fullscreen videos. That's the reason why the extension was only injecting data into the web engine for those videos that were emitting the onfullscreen events. The problem is that in VisionGlass we have another progress bar that is shown in the phone UI but for all videos, not only fullscreen ones. The fix is to capture the playing event and then apply the mediasession fixes that we already have in place for the video element that issued the event. Fixes #1406 --- .../extensions/fxr_mediasession/main.js | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/app/src/main/assets/extensions/fxr_mediasession/main.js b/app/src/main/assets/extensions/fxr_mediasession/main.js index 6e60094083..e5646b28c6 100644 --- a/app/src/main/assets/extensions/fxr_mediasession/main.js +++ b/app/src/main/assets/extensions/fxr_mediasession/main.js @@ -53,24 +53,8 @@ function mediaSessionFix() { }); } -document.addEventListener('fullscreenchange', (event) => { - if (!document.fullscreenElement) { - if (video) { - video.removeEventListener('ratechange', handleVideoUpdate); - video.removeEventListener('timeupdate', handleVideoUpdate); - } - video = null; - return; - } - - if (document.fullscreenElement.tagName.toLowerCase() === "video") { - video = document.fullscreenElement; - } else { - video = document.fullscreenElement.getElementsByTagName("video")[0] || null; - } - - if (video) { - logDebug("Apply MediaSession fixes for video"); +addEventListener('playing', (event) => { + logDebug('Playing event:', event.target.src); + video = event.target; mediaSessionFix(); - } -}); \ No newline at end of file +}, {capture: true});