1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-21 14:47:41 +01:00

source reset bug fixes (HLS fix & volume fix)

This commit is contained in:
Jelle van Snik 2023-02-12 13:06:30 +01:00
parent 886ffe78ef
commit dcc158e705
2 changed files with 8 additions and 4 deletions

View file

@ -12,7 +12,7 @@ export function resetForSource(s: VideoPlayerState) {
isDragSeeking: false, isDragSeeking: false,
isFirstLoading: true, isFirstLoading: true,
hasPlayedOnce: false, hasPlayedOnce: false,
volume: 0, volume: state.mediaPlaying.volume, // volume settings needs to persist through resets
}; };
state.progress = { state.progress = {
time: 0, time: 0,

View file

@ -129,18 +129,22 @@ export function createVideoStateProvider(
}, },
setSource(source) { setSource(source) {
if (!source) { if (!source) {
resetStateForSource(descriptor, state);
player.src = ""; player.src = "";
state.source = null; state.source = null;
resetStateForSource(descriptor, state);
updateSource(descriptor, state); updateSource(descriptor, state);
return; return;
} }
// reset before assign new one so the old HLS instance gets destroyed
resetStateForSource(descriptor, state);
if (source?.type === MWStreamType.HLS) { if (source?.type === MWStreamType.HLS) {
if (player.canPlayType("application/vnd.apple.mpegurl")) { if (player.canPlayType("application/vnd.apple.mpegurl")) {
// HLS supported natively by browser
player.src = source.source; player.src = source.source;
} else { } else {
// HLS support // HLS through HLS.js
if (!Hls.isSupported()) { if (!Hls.isSupported()) {
state.error = { state.error = {
name: `Not supported`, name: `Not supported`,
@ -168,6 +172,7 @@ export function createVideoStateProvider(
hls.loadSource(source.source); hls.loadSource(source.source);
} }
} else if (source.type === MWStreamType.MP4) { } else if (source.type === MWStreamType.MP4) {
// standard MP4 stream
player.src = source.source; player.src = source.source;
} }
@ -178,7 +183,6 @@ export function createVideoStateProvider(
url: source.source, url: source.source,
caption: null, caption: null,
}; };
resetStateForSource(descriptor, state);
updateSource(descriptor, state); updateSource(descriptor, state);
}, },
setCaption(id, url) { setCaption(id, url) {