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] 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) -}