From 685902adabb7da522587f6308495701891a8b5fe Mon Sep 17 00:00:00 2001 From: 138138138 <78271024+138138138@users.noreply.github.com> Date: Mon, 1 Feb 2021 15:59:27 +0800 Subject: [PATCH 1/4] Update player.js Fixes audio mode duration doubled in iPhone iOS browsers. The player will stop after reaching the real duration. iOS() checks both iOS and iPadOS. Only tested on iPhone iOS browsers. Testers needed for behavior of iPadOS and MacOS. --- assets/js/player.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/assets/js/player.js b/assets/js/player.js index 04326631..3c4188d0 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -547,3 +547,27 @@ window.addEventListener('keydown', e => { if (player.share) { player.share(shareOptions); } + +//iOS audio double duration fix +player.on('loadedmetadata', function () { + if (iOS() && video_data.params.listen) { + player.on('timeupdate', function () { + if (player.remainingTime() < player.duration() / 2) { + player.currentTime(player.duration() + 1); + } + }) + } +}); + +function iOS() { + return [ + 'iPad Simulator', + 'iPhone Simulator', + 'iPod Simulator', + 'iPad', + 'iPhone', + 'iPod' + ].includes(navigator.platform) + // iPad on iOS 13 detection + || (navigator.userAgent.includes("Mac") && "ontouchend" in document) +} From a6970e02f937112bbc9f8be4fa69e820b8381e1b Mon Sep 17 00:00:00 2001 From: 138138138 <78271024+138138138@users.noreply.github.com> Date: Tue, 2 Feb 2021 21:25:13 +0800 Subject: [PATCH 2/4] Fix double duration on all Apple devices The fix will be applied when Safari browser is detected. --- assets/js/player.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index 3c4188d0..29b62147 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -548,9 +548,9 @@ if (player.share) { player.share(shareOptions); } -//iOS audio double duration fix +// Safari audio double duration fix player.on('loadedmetadata', function () { - if (iOS() && video_data.params.listen) { + if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { player.on('timeupdate', function () { if (player.remainingTime() < player.duration() / 2) { player.currentTime(player.duration() + 1); @@ -558,16 +558,3 @@ player.on('loadedmetadata', function () { }) } }); - -function iOS() { - return [ - 'iPad Simulator', - 'iPhone Simulator', - 'iPod Simulator', - 'iPad', - 'iPhone', - 'iPod' - ].includes(navigator.platform) - // iPad on iOS 13 detection - || (navigator.userAgent.includes("Mac") && "ontouchend" in document) -} From ddd7f3f3849be4b81fafd31097075285739e7fd9 Mon Sep 17 00:00:00 2001 From: 138138138 <78271024+138138138@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:50:14 +0800 Subject: [PATCH 3/4] Update player.js --- assets/js/player.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index 29b62147..031711ee 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -549,8 +549,8 @@ if (player.share) { } // Safari audio double duration fix -player.on('loadedmetadata', function () { - if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { +if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { + player.on('loadedmetadata', function () { player.on('timeupdate', function () { if (player.remainingTime() < player.duration() / 2) { player.currentTime(player.duration() + 1); From 121224b1b03cfffb7cb0f32764571bbff2476f22 Mon Sep 17 00:00:00 2001 From: 138138138 <78271024+138138138@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:05:29 +0800 Subject: [PATCH 4/4] Fix ; () {} --- assets/js/player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index 031711ee..e03ab89c 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -555,6 +555,6 @@ if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { if (player.remainingTime() < player.duration() / 2) { player.currentTime(player.duration() + 1); } - }) - } -}); + }); + }); +}