fix: race condition in playNextEpisode()
This commit is contained in:
+8
-1
@@ -175,6 +175,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Center: Large Play Button -->
|
||||||
|
<button class="watch-center-play" id="player-center-play">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon">
|
||||||
|
<path d="M8 5v14l11-7z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- Loading Spinner -->
|
<!-- Loading Spinner -->
|
||||||
<div class="watch-loading" id="player-loading">
|
<div class="watch-loading" id="player-loading">
|
||||||
@@ -596,7 +602,8 @@
|
|||||||
</label>
|
</label>
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
<span class="setting-label">Enable Upscaling</span>
|
<span class="setting-label">Enable Upscaling</span>
|
||||||
<span class="setting-hint">Upscale lower-resolution content to a higher resolution during transcoding.</span>
|
<span class="setting-hint">Upscale lower-resolution content to a higher resolution during
|
||||||
|
transcoding.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-item" id="upscale-method-container" style="display: none;">
|
<div class="setting-item" id="upscale-method-container" style="display: none;">
|
||||||
|
|||||||
@@ -179,9 +179,23 @@ class VideoPlayer {
|
|||||||
togglePlay();
|
togglePlay();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Center play button (large button shown when paused)
|
||||||
|
const centerPlayBtn = document.getElementById('player-center-play');
|
||||||
|
centerPlayBtn?.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
togglePlay();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click on video to toggle play/pause
|
||||||
|
this.video?.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
togglePlay();
|
||||||
|
});
|
||||||
|
|
||||||
// Update play/pause UI
|
// Update play/pause UI
|
||||||
const updatePlayUI = () => {
|
const updatePlayUI = () => {
|
||||||
const isPaused = this.video.paused;
|
const isPaused = this.video.paused;
|
||||||
|
const hasVideo = this.video.src && this.video.src !== '' && this.video.readyState > 0;
|
||||||
|
|
||||||
// Bottom bar button
|
// Bottom bar button
|
||||||
const iconPlay = btnPlay?.querySelector('.icon-play');
|
const iconPlay = btnPlay?.querySelector('.icon-play');
|
||||||
@@ -191,6 +205,11 @@ class VideoPlayer {
|
|||||||
iconPlay.classList.toggle('hidden', !isPaused);
|
iconPlay.classList.toggle('hidden', !isPaused);
|
||||||
iconPause.classList.toggle('hidden', isPaused);
|
iconPause.classList.toggle('hidden', isPaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Center play button - show only when paused AND video is loaded
|
||||||
|
if (centerPlayBtn) {
|
||||||
|
centerPlayBtn.classList.toggle('show', isPaused && hasVideo);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.video.addEventListener('play', updatePlayUI);
|
this.video.addEventListener('play', updatePlayUI);
|
||||||
@@ -329,7 +348,13 @@ class VideoPlayer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.container.addEventListener('mousemove', showOverlay);
|
this.container.addEventListener('mousemove', showOverlay);
|
||||||
this.container.addEventListener('click', showOverlay);
|
this.container.addEventListener('click', (e) => {
|
||||||
|
showOverlay();
|
||||||
|
// Only toggle play if clicking directly on video or container (not controls)
|
||||||
|
if (e.target === this.video || e.target === this.container || e.target.classList.contains('watch-overlay')) {
|
||||||
|
togglePlay();
|
||||||
|
}
|
||||||
|
});
|
||||||
this.container.addEventListener('touchstart', showOverlay);
|
this.container.addEventListener('touchstart', showOverlay);
|
||||||
|
|
||||||
this.video.addEventListener('play', resetOverlayTimer);
|
this.video.addEventListener('play', resetOverlayTimer);
|
||||||
|
|||||||
@@ -151,10 +151,18 @@ class WatchPage {
|
|||||||
this.video?.addEventListener('waiting', () => this.showLoading());
|
this.video?.addEventListener('waiting', () => this.showLoading());
|
||||||
this.video?.addEventListener('canplay', () => this.hideLoading());
|
this.video?.addEventListener('canplay', () => this.hideLoading());
|
||||||
|
|
||||||
// Overlay auto-hide
|
// Overlay auto-hide + click to toggle play
|
||||||
const watchSection = document.querySelector('.watch-video-section');
|
const watchSection = document.querySelector('.watch-video-section');
|
||||||
watchSection?.addEventListener('mousemove', () => this.showOverlay());
|
watchSection?.addEventListener('mousemove', () => this.showOverlay());
|
||||||
watchSection?.addEventListener('touchstart', () => this.showOverlay());
|
watchSection?.addEventListener('touchstart', () => this.showOverlay());
|
||||||
|
watchSection?.addEventListener('click', (e) => {
|
||||||
|
this.showOverlay();
|
||||||
|
// Only toggle play if clicking on video area (not controls)
|
||||||
|
if (e.target === this.video || e.target === watchSection ||
|
||||||
|
e.target.classList.contains('watch-overlay') || e.target === this.overlay) {
|
||||||
|
this.togglePlay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
document.addEventListener('keydown', (e) => this.handleKeyboard(e));
|
document.addEventListener('keydown', (e) => this.handleKeyboard(e));
|
||||||
@@ -1243,9 +1251,11 @@ class WatchPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async playNextEpisode() {
|
async playNextEpisode() {
|
||||||
|
// Save next episode data BEFORE canceling (cancel clears the data)
|
||||||
|
const nextEp = this.nextEpisodePanel?.nextEpisodeData;
|
||||||
|
|
||||||
this.cancelNextEpisode();
|
this.cancelNextEpisode();
|
||||||
|
|
||||||
const nextEp = this.nextEpisodePanel?.nextEpisodeData;
|
|
||||||
if (!nextEp) return;
|
if (!nextEp) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user