From d1663be1b61cceb39b58dfae67289e02658c9b96 Mon Sep 17 00:00:00 2001 From: Marcus Eibrink-Lunzenauer Date: Wed, 8 May 2024 14:13:03 +0200 Subject: [PATCH 1/3] 263 Prefer master tracks and hls and wait for `NaN` and `Infinity`. (PR 627) --- frontend/js/integrations/search.js | 1 + frontend/js/player-adapter-html5.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/js/integrations/search.js b/frontend/js/integrations/search.js index 994f46c82..42e6de5cb 100644 --- a/frontend/js/integrations/search.js +++ b/frontend/js/integrations/search.js @@ -159,6 +159,7 @@ define([ RegExp.prototype.test.bind(/application\/.*|video\/.*/), _.property("mimetype") )); + videos = _.sortBy(videos, "master").reverse(); videos.sort( util.lexicographic([ util.firstWith(_.compose( diff --git a/frontend/js/player-adapter-html5.js b/frontend/js/player-adapter-html5.js index c06fab055..5658ddae8 100644 --- a/frontend/js/player-adapter-html5.js +++ b/frontend/js/player-adapter-html5.js @@ -85,7 +85,7 @@ define( window.Hls = Hls; mediaElementPlayer = new mejs.MediaElementPlayer(targetElement, { - renderers: ["html5", "native_hls"], + renderers: ["native_hls", "html5"], alwaysShowControls: true, autoRewind: false, stretching: "fill", @@ -96,7 +96,7 @@ define( */ $(mediaElement).on("canplay durationchange", function () { // If duration is still not valid - if (isNaN(self.getDuration()) || mediaElement.readyState < 1) { + if (!isFinite(self.getDuration()) || mediaElement.readyState < 1) { return; } From 3fa20a55cb553d922fb23dd7dcbb43ca3089d8d9 Mon Sep 17 00:00:00 2001 From: Martin Wygas Date: Fri, 24 Jan 2025 13:26:53 +0100 Subject: [PATCH 2/3] Address review comments of #627 --- frontend/js/integrations/search.js | 4 +++- frontend/js/player-adapter-html5.js | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/js/integrations/search.js b/frontend/js/integrations/search.js index 42e6de5cb..30b5e0e31 100644 --- a/frontend/js/integrations/search.js +++ b/frontend/js/integrations/search.js @@ -159,9 +159,11 @@ define([ RegExp.prototype.test.bind(/application\/.*|video\/.*/), _.property("mimetype") )); - videos = _.sortBy(videos, "master").reverse(); videos.sort( util.lexicographic([ + util.firstWith( + _.property("master") + ), util.firstWith(_.compose( RegExp.prototype.test.bind(/composite\/.*/), _.property("type") diff --git a/frontend/js/player-adapter-html5.js b/frontend/js/player-adapter-html5.js index 5658ddae8..4bffa64ce 100644 --- a/frontend/js/player-adapter-html5.js +++ b/frontend/js/player-adapter-html5.js @@ -85,7 +85,6 @@ define( window.Hls = Hls; mediaElementPlayer = new mejs.MediaElementPlayer(targetElement, { - renderers: ["native_hls", "html5"], alwaysShowControls: true, autoRewind: false, stretching: "fill", From cc1262e0826d05ad252a9bb1d594e9fa7487752b Mon Sep 17 00:00:00 2001 From: Martin Wygas Date: Fri, 24 Jan 2025 13:28:19 +0100 Subject: [PATCH 3/3] Add update handler to display video duration correctly --- frontend/js/player-adapter-html5.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/js/player-adapter-html5.js b/frontend/js/player-adapter-html5.js index 4bffa64ce..a2d4e75ec 100644 --- a/frontend/js/player-adapter-html5.js +++ b/frontend/js/player-adapter-html5.js @@ -106,6 +106,7 @@ define( // If duration is valid, we changed status self.status = PlayerAdapter.STATUS.PAUSED; self.dispatchEvent(new Event(PlayerAdapter.EVENTS.READY)); + mediaElementPlayer.updateDuration(); if (self.waitToPlay) { self.play();