mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
source reset bug fixes (HLS fix & volume fix)
This commit is contained in:
parent
886ffe78ef
commit
dcc158e705
2 changed files with 8 additions and 4 deletions
|
@ -12,7 +12,7 @@ export function resetForSource(s: VideoPlayerState) {
|
|||
isDragSeeking: false,
|
||||
isFirstLoading: true,
|
||||
hasPlayedOnce: false,
|
||||
volume: 0,
|
||||
volume: state.mediaPlaying.volume, // volume settings needs to persist through resets
|
||||
};
|
||||
state.progress = {
|
||||
time: 0,
|
||||
|
|
|
@ -129,18 +129,22 @@ export function createVideoStateProvider(
|
|||
},
|
||||
setSource(source) {
|
||||
if (!source) {
|
||||
resetStateForSource(descriptor, state);
|
||||
player.src = "";
|
||||
state.source = null;
|
||||
resetStateForSource(descriptor, state);
|
||||
updateSource(descriptor, state);
|
||||
return;
|
||||
}
|
||||
|
||||
// reset before assign new one so the old HLS instance gets destroyed
|
||||
resetStateForSource(descriptor, state);
|
||||
|
||||
if (source?.type === MWStreamType.HLS) {
|
||||
if (player.canPlayType("application/vnd.apple.mpegurl")) {
|
||||
// HLS supported natively by browser
|
||||
player.src = source.source;
|
||||
} else {
|
||||
// HLS support
|
||||
// HLS through HLS.js
|
||||
if (!Hls.isSupported()) {
|
||||
state.error = {
|
||||
name: `Not supported`,
|
||||
|
@ -168,6 +172,7 @@ export function createVideoStateProvider(
|
|||
hls.loadSource(source.source);
|
||||
}
|
||||
} else if (source.type === MWStreamType.MP4) {
|
||||
// standard MP4 stream
|
||||
player.src = source.source;
|
||||
}
|
||||
|
||||
|
@ -178,7 +183,6 @@ export function createVideoStateProvider(
|
|||
url: source.source,
|
||||
caption: null,
|
||||
};
|
||||
resetStateForSource(descriptor, state);
|
||||
updateSource(descriptor, state);
|
||||
},
|
||||
setCaption(id, url) {
|
||||
|
|
Loading…
Reference in a new issue