mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1040 from JustAMan/fix-native-hls-resume
Fix native hls resume
(cherry picked from commit 2223a16813
)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
parent
914ef1e566
commit
b52cb34319
1 changed files with 22 additions and 6 deletions
|
@ -171,13 +171,29 @@ define(['appSettings', 'browser', 'events'], function (appSettings, browser, eve
|
||||||
|
|
||||||
// Appending #t=xxx to the query string doesn't seem to work with HLS
|
// Appending #t=xxx to the query string doesn't seem to work with HLS
|
||||||
// For plain video files, not all browsers support it either
|
// For plain video files, not all browsers support it either
|
||||||
var delay = browser.safari ? 2500 : 0;
|
|
||||||
if (delay) {
|
if (element.duration >= seconds) {
|
||||||
setTimeout(function () {
|
// media is ready, seek immediately
|
||||||
setCurrentTimeIfNeeded(element, seconds);
|
setCurrentTimeIfNeeded(element, seconds);
|
||||||
}, delay);
|
|
||||||
} else {
|
} else {
|
||||||
|
// update video player position when media is ready to be sought
|
||||||
|
var events = ["durationchange", "loadeddata", "play", "loadedmetadata"];
|
||||||
|
var onMediaChange = function(e) {
|
||||||
|
if (element.currentTime === 0 && element.duration >= seconds) {
|
||||||
|
// seek only when video position is exactly zero,
|
||||||
|
// as this is true only if video hasn't started yet or
|
||||||
|
// user rewound to the very beginning
|
||||||
|
// (but rewinding cannot happen as the first event with media of non-empty duration)
|
||||||
|
console.debug(`seeking to ${seconds} on ${e.type} event`);
|
||||||
setCurrentTimeIfNeeded(element, seconds);
|
setCurrentTimeIfNeeded(element, seconds);
|
||||||
|
events.map(function(name) {
|
||||||
|
element.removeEventListener(name, onMediaChange);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
events.map(function (name) {
|
||||||
|
element.addEventListener(name, onMediaChange);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue