Fix double duration on all Apple devices

The fix will be applied when Safari browser is detected.
This commit is contained in:
138138138 2021-02-02 21:25:13 +08:00 committed by GitHub
parent 685902adab
commit a6970e02f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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