Allow join prompt after paused YouTube sync
This commit is contained in:
+12
-2
@@ -53,6 +53,7 @@ let applyingWatchStateUntil = 0;
|
||||
let pauseEnforcementUntil = 0;
|
||||
let syncedPlaybackRetryUntil = 0;
|
||||
let youtubeStartPromptAllowedUntil = 0;
|
||||
let allowJoinedYoutubeStartPrompt = false;
|
||||
let desiredYoutubePlaying = false;
|
||||
let youtubeReadyResolvers = [];
|
||||
let watchApplySequence = 0;
|
||||
@@ -562,6 +563,7 @@ async function applyWatchState(state, { suppressEvents = true, allowStartPrompt
|
||||
|
||||
if (!currentYoutubeVideoId) {
|
||||
desiredYoutubePlaying = false;
|
||||
allowJoinedYoutubeStartPrompt = false;
|
||||
youtubePlaybackRequestId++;
|
||||
syncedPlaybackRetryUntil = 0;
|
||||
youtubeStartPromptAllowedUntil = 0;
|
||||
@@ -900,7 +902,10 @@ async function handleSignal(message) {
|
||||
peerId = message.peerId;
|
||||
setStatus(`Joined the call as ${displayName}. ${message.peers.length} other participant(s).`);
|
||||
if (message.watchState) {
|
||||
await applyWatchState(message.watchState, { allowStartPrompt: true });
|
||||
const watchShouldPlay = message.watchState.action === "play" ||
|
||||
(!message.watchState.action && Boolean(message.watchState.playing));
|
||||
allowJoinedYoutubeStartPrompt = Boolean(message.watchState.videoId && !watchShouldPlay);
|
||||
await applyWatchState(message.watchState, { allowStartPrompt: watchShouldPlay });
|
||||
}
|
||||
if (message.presentationState?.sharing) {
|
||||
setTimeout(() => {
|
||||
@@ -936,7 +941,12 @@ async function handleSignal(message) {
|
||||
}
|
||||
|
||||
if (message.type === "watch-state") {
|
||||
await applyWatchState(message);
|
||||
const watchShouldPlay = message.action === "play" || (!message.action && Boolean(message.playing));
|
||||
const allowStartPrompt = allowJoinedYoutubeStartPrompt && watchShouldPlay;
|
||||
if (allowStartPrompt) {
|
||||
allowJoinedYoutubeStartPrompt = false;
|
||||
}
|
||||
await applyWatchState(message, { allowStartPrompt });
|
||||
setStatus(`${message.name || "Someone"} synced YouTube playback.`);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user