diff --git a/assets/js/player.js b/assets/js/player.js index 043266318..3c4188d07 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) +}