fix: reinit player safely
This commit is contained in:
@@ -6,6 +6,7 @@ import { updateQualityOptions } from '../quality';
|
||||
import { updateModeButtons } from '../mode';
|
||||
import { updateOverlay, isAutoplayEnabled, switchEpisodeRange } from './ui';
|
||||
import { markEpisodeTransition } from '../progress';
|
||||
import { safeLocalStorage } from '../storage';
|
||||
|
||||
/**
|
||||
* Handles video end: either marks complete or loads next episode.
|
||||
@@ -71,7 +72,7 @@ export const goToNextEpisode = async (): Promise<void> => {
|
||||
state.container.dataset.startTimeSeconds = String(state.startTimeSeconds);
|
||||
|
||||
// load new video (keep preferences)
|
||||
const preferredQuality = localStorage.getItem('mal:preferred-quality') || 'best';
|
||||
const preferredQuality = safeLocalStorage.getItem('mal:preferred-quality') || 'best';
|
||||
state.video.src = `${state.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(state.modeSources[fallback].token)}${preferredQuality !== 'best' ? `&quality=${encodeURIComponent(preferredQuality)}` : ''}`;
|
||||
state.video.load();
|
||||
if (!state.video.paused) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { state } from '../state';
|
||||
import { qs } from '../../q';
|
||||
import { safeLocalStorage } from '../storage';
|
||||
|
||||
/**
|
||||
* Syncs autoplay checkbox with localStorage on init.
|
||||
@@ -8,11 +9,11 @@ import { qs } from '../../q';
|
||||
export const setupAutoplayButton = (): void => {
|
||||
const btn = document.querySelector('[data-autoplay]') as HTMLInputElement | null;
|
||||
if (!btn) return;
|
||||
btn.checked = localStorage.getItem('mal:autoplay-enabled') !== 'false';
|
||||
btn.checked = safeLocalStorage.getItem('mal:autoplay-enabled') !== 'false';
|
||||
};
|
||||
|
||||
export const isAutoplayEnabled = (): boolean =>
|
||||
localStorage.getItem('mal:autoplay-enabled') !== 'false';
|
||||
safeLocalStorage.getItem('mal:autoplay-enabled') !== 'false';
|
||||
|
||||
/**
|
||||
* Updates video overlay text (shown briefly on episode change).
|
||||
|
||||
Reference in New Issue
Block a user