Show join YouTube prompt deterministically

This commit is contained in:
codex
2026-06-10 20:47:59 +02:00
parent 1fdd7adf3c
commit a0de254241
+12
View File
@@ -494,6 +494,15 @@ function handleYoutubeStateChange(event) {
}
if (event.data === YT.PlayerState.PLAYING) {
setYoutubeStartPromptVisible(false);
setTimeout(() => {
if (
Date.now() < youtubeStartPromptAllowedUntil &&
desiredYoutubePlaying &&
youtubePlayer?.getPlayerState?.() !== YT.PlayerState.PLAYING
) {
setYoutubeStartPromptVisible(true);
}
}, 700);
}
if (![YT.PlayerState.PLAYING, YT.PlayerState.PAUSED, YT.PlayerState.ENDED].includes(event.data)) {
@@ -598,6 +607,9 @@ async function applyWatchState(state, { suppressEvents = true, allowStartPrompt
}
if (shouldPlay) {
if (allowStartPrompt) {
setYoutubeStartPromptVisible(true);
}
const sameVideo = player.getVideoData?.().video_id === currentYoutubeVideoId;
const playerState = player.getPlayerState?.();
if (sameVideo && ![YT.PlayerState.UNSTARTED, YT.PlayerState.CUED].includes(playerState)) {