From 2c22b0839f7dced5e82c1f1b23e040ea0849461d Mon Sep 17 00:00:00 2001 From: 138138138 <78271024+138138138@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:32:00 +0800 Subject: [PATCH] Safari audio double duration fix for iOS 15 The previous method breaks Always Loop feature on iOS 15. The previous player.currentTime(player.duration() + 1) sometimes breaks the entire player. Now it jumps to (end - 1) seconds when the time goes between over half and (end - 2) seconds. With Always Loop on, player will jump to the beginning after 1 second. --- 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 a1a2cd16..74cdd987 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -675,8 +675,8 @@ if (player_data.preferred_caption_found) { 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); + if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) { + player.currentTime(player.duration() - 1); } }); });