Skip to content

Commit

Permalink
Fix collab mode regression
Browse files Browse the repository at this point in the history
  • Loading branch information
elonen committed Jun 7, 2024
1 parent 2b58205 commit f2d8b9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 7 additions & 3 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 9 additions & 3 deletions client/src/lib/player_view/VideoPlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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];
Expand All @@ -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(); }
}
}
Expand Down
1 change: 1 addition & 0 deletions protobuf/proto/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> cookies = 1; // Cookies to set. Use empty string to delete a cookie.
Expand Down
1 change: 1 addition & 0 deletions server/src/api_server/ws_handers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f2d8b9e

Please sign in to comment.