Skip to content

Commit

Permalink
syncs to edge on livestreams jump to live
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jul 31, 2024
1 parent d695dcc commit 111e60a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1659,9 +1659,17 @@ export default class App extends React.Component<AppProps, AppState> {
}
target = Math.max(target, 0);
this.Player().seekVideo(target);
const hlsTarget =
Math.floor(Date.now() / 1000) - this.HTMLInterface.getDuration() + target;
this.socket.emit('CMD:seek', this.state.isLiveStream ? hlsTarget : target);
// Livestreams sync to network using timestamp since video time may be different for each viewer
if (this.state.isLiveStream) {
const now = Math.floor(Date.now() / 1000);
let liveStreamTarget = now - this.HTMLInterface.getDuration() + target;
// If livestream and seeking close to edge, set target as max
if (now - liveStreamTarget <= 5) {
liveStreamTarget = Number.MAX_SAFE_INTEGER;
}
target = liveStreamTarget;
}
this.socket.emit('CMD:seek', target);
};

onFullScreenChange = () => {
Expand Down
8 changes: 5 additions & 3 deletions src/components/Controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ export class Controls extends React.Component<ControlsProps> {
<Progress
size="tiny"
color="blue"
onClick={
duration < Infinity && !this.props.disabled ? roomSeek : undefined
}
onClick={(e: any, time: number) => {
if (duration < Infinity && !this.props.disabled) {
roomSeek(e, time);
}
}}
onMouseOver={this.onMouseOver}
onMouseOut={this.onMouseOut}
onMouseMove={this.onMouseMove}
Expand Down

0 comments on commit 111e60a

Please sign in to comment.