From f2d8b9e12dd795bb767848157016fb2b28f5d74e Mon Sep 17 00:00:00 2001 From: elonen Date: Fri, 7 Jun 2024 14:33:55 +0300 Subject: [PATCH] Fix collab mode regression --- client/src/App.svelte | 10 +++++++--- client/src/lib/player_view/VideoPlayer.svelte | 12 +++++++++--- protobuf/proto/client.proto | 1 + server/src/api_server/ws_handers.rs | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/client/src/App.svelte b/client/src/App.svelte index ac0b4f3..27fb443 100644 --- a/client/src/App.svelte +++ b/client/src/App.svelte @@ -182,9 +182,10 @@ function onPlayerSeeked(_e: any) { commentInput.forceDrawMode(false); // Close draw mode when video frame is changed } -function onCollabReport(e: any) { - if ($collabId) - wsEmit({collabReport: e.report}); +function onCollabReport(e: { detail: { report: Proto3.client.ClientToServerCmd_CollabReport; }; }) { + if ($collabId) { + wsEmit({collabReport: e.detail.report}); + } } function onCommentPinClicked(e: any) { @@ -791,6 +792,9 @@ function connectWebsocketAfterAuthCheck(ws_url: string) // collabEvent else if (cmd.collabEvent) { const evt = cmd.collabEvent; + if (evt.subtitleId != $curSubtitle?.id) { + $curSubtitle = $curVideo?.subtitles.find((s) => s.id == evt.subtitleId) ?? null; + } if (!evt.paused) { videoPlayer.collabPlay(evt.seekTimeSec, evt.loop); } else { diff --git a/client/src/lib/player_view/VideoPlayer.svelte b/client/src/lib/player_view/VideoPlayer.svelte index 4cc2962..59ced92 100644 --- a/client/src/lib/player_view/VideoPlayer.svelte +++ b/client/src/lib/player_view/VideoPlayer.svelte @@ -147,6 +147,7 @@ function handleMove(e: MouseEvent | TouchEvent, target: EventTarget|null) { seekSideEffects(); paused = true; send_collab_report(); + if (videoElem) { videoElem.focus(); } } let playback_request_source: string|undefined = undefined; @@ -181,6 +182,10 @@ export function isLooping(): boolean { return loop; } +export function isPaused(): boolean { + return paused; +} + function togglePlay() { const should_play = paused; setPlayback(should_play, "VideoPlayer"); @@ -455,7 +460,7 @@ function offsetTextTracks() { const adjustCues = (track: TextTrack) => { const offset = $curSubtitle?.timeOffset || 0.0; if (!track.cues) { - console.debug("adjustCues(): track has no cues"); + //console.debug("adjustCues(): track has no cues"); return; } console.debug("Offsetting cues on text tracks by", offset, "sec"); @@ -489,6 +494,8 @@ function offsetTextTracks() { // Set loop in/out points function setLoopPoint(isInPoint: boolean) { + if ($collabId) { return; } // Disable custom loops in collab mode, hard to sync + const loop_was_valid = (loopEndTime > loopStartTime); function resetLoop() { [loopStartTime, loopEndTime] = [-1, -2]; @@ -511,8 +518,7 @@ function setLoopPoint(isInPoint: boolean) { } else if (loop_was_valid) { resetLoop(); } - let playbutton = document.getElementById("playbutton"); - if (playbutton) { playbutton.focus(); } + if (videoElem) { videoElem.focus(); } } } diff --git a/protobuf/proto/client.proto b/protobuf/proto/client.proto index b0cf1d6..4ea955b 100644 --- a/protobuf/proto/client.proto +++ b/protobuf/proto/client.proto @@ -46,6 +46,7 @@ message ServerToClientCmd { bool loop = 3; double seek_time_sec = 4; // From start of media file optional string drawing = 5; // data-uri of an image + optional string subtitle_id = 6; } message SetCookies { map cookies = 1; // Cookies to set. Use empty string to delete a cookie. diff --git a/server/src/api_server/ws_handers.rs b/server/src/api_server/ws_handers.rs index 7c859c9..0199ca7 100644 --- a/server/src/api_server/ws_handers.rs +++ b/server/src/api_server/ws_handers.rs @@ -619,6 +619,7 @@ pub async fn msg_collab_report(data: &CollabReport, ses: &mut UserSession, serve seek_time_sec: data.seek_time_sec, from_user: ses.user_name.clone(), drawing: data.drawing.clone(), + subtitle_id: data.subtitle_id.clone(), }); server.emit_cmd(ce, super::SendTo::Collab(collab_id)).map(|_| ()) } else {