Skip to content

Commit f2d8b9e

Browse files
committed
Fix collab mode regression
1 parent 2b58205 commit f2d8b9e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

client/src/App.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ function onPlayerSeeked(_e: any) {
182182
commentInput.forceDrawMode(false); // Close draw mode when video frame is changed
183183
}
184184
185-
function onCollabReport(e: any) {
186-
if ($collabId)
187-
wsEmit({collabReport: e.report});
185+
function onCollabReport(e: { detail: { report: Proto3.client.ClientToServerCmd_CollabReport; }; }) {
186+
if ($collabId) {
187+
wsEmit({collabReport: e.detail.report});
188+
}
188189
}
189190
190191
function onCommentPinClicked(e: any) {
@@ -791,6 +792,9 @@ function connectWebsocketAfterAuthCheck(ws_url: string)
791792
// collabEvent
792793
else if (cmd.collabEvent) {
793794
const evt = cmd.collabEvent;
795+
if (evt.subtitleId != $curSubtitle?.id) {
796+
$curSubtitle = $curVideo?.subtitles.find((s) => s.id == evt.subtitleId) ?? null;
797+
}
794798
if (!evt.paused) {
795799
videoPlayer.collabPlay(evt.seekTimeSec, evt.loop);
796800
} else {

client/src/lib/player_view/VideoPlayer.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ function handleMove(e: MouseEvent | TouchEvent, target: EventTarget|null) {
147147
seekSideEffects();
148148
paused = true;
149149
send_collab_report();
150+
if (videoElem) { videoElem.focus(); }
150151
}
151152
152153
let playback_request_source: string|undefined = undefined;
@@ -181,6 +182,10 @@ export function isLooping(): boolean {
181182
return loop;
182183
}
183184
185+
export function isPaused(): boolean {
186+
return paused;
187+
}
188+
184189
function togglePlay() {
185190
const should_play = paused;
186191
setPlayback(should_play, "VideoPlayer");
@@ -455,7 +460,7 @@ function offsetTextTracks() {
455460
const adjustCues = (track: TextTrack) => {
456461
const offset = $curSubtitle?.timeOffset || 0.0;
457462
if (!track.cues) {
458-
console.debug("adjustCues(): track has no cues");
463+
//console.debug("adjustCues(): track has no cues");
459464
return;
460465
}
461466
console.debug("Offsetting cues on text tracks by", offset, "sec");
@@ -489,6 +494,8 @@ function offsetTextTracks() {
489494
490495
// Set loop in/out points
491496
function setLoopPoint(isInPoint: boolean) {
497+
if ($collabId) { return; } // Disable custom loops in collab mode, hard to sync
498+
492499
const loop_was_valid = (loopEndTime > loopStartTime);
493500
function resetLoop() {
494501
[loopStartTime, loopEndTime] = [-1, -2];
@@ -511,8 +518,7 @@ function setLoopPoint(isInPoint: boolean) {
511518
} else if (loop_was_valid) {
512519
resetLoop();
513520
}
514-
let playbutton = document.getElementById("playbutton");
515-
if (playbutton) { playbutton.focus(); }
521+
if (videoElem) { videoElem.focus(); }
516522
}
517523
}
518524

protobuf/proto/client.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ message ServerToClientCmd {
4646
bool loop = 3;
4747
double seek_time_sec = 4; // From start of media file
4848
optional string drawing = 5; // data-uri of an image
49+
optional string subtitle_id = 6;
4950
}
5051
message SetCookies {
5152
map<string, string> cookies = 1; // Cookies to set. Use empty string to delete a cookie.

server/src/api_server/ws_handers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ pub async fn msg_collab_report(data: &CollabReport, ses: &mut UserSession, serve
619619
seek_time_sec: data.seek_time_sec,
620620
from_user: ses.user_name.clone(),
621621
drawing: data.drawing.clone(),
622+
subtitle_id: data.subtitle_id.clone(),
622623
});
623624
server.emit_cmd(ce, super::SendTo::Collab(collab_id)).map(|_| ())
624625
} else {

0 commit comments

Comments
 (0)