Skip to content

Commit

Permalink
fix(FEC-11419): explore why Live Start over starts with few seconds d…
Browse files Browse the repository at this point in the history
…elay (#626)

1. prevent currentTime to be negative
2. add missing event disaptcher case of live seekbar
3. don't use the currentTime and duration from the player but from props
  • Loading branch information
yairans committed Jul 21, 2021
1 parent 1c9c1d6 commit 2892bac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/components/event-dispatcher/event-dispatcher-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function onChangeableComponentsHandler(store: any, action: Object, player: Objec
player.dispatchEvent(new SeekedEvent(action.payload.from, action.payload.to));
break;

case 'SeekBarLivePlaybackContainer':
player.dispatchEvent(new SeekedEvent(action.payload.from, action.payload.to));
break;

case 'ActivePreset':
player.dispatchEvent(new FakeEvent(FakeEvent.Type.UI_PRESET_CHANGE, action.payload));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SeekBarLivePlaybackContainer extends Component {
const {eventManager, player, isDraggingActive, updateCurrentTime} = this.props;
eventManager.listen(player, player.Event.TIME_UPDATE, () => {
if (!isDraggingActive) {
updateCurrentTime(player.currentTime - player.getStartTimeOfDvrWindow());
updateCurrentTime(Math.max(player.currentTime - player.getStartTimeOfDvrWindow(), 0));
}
});
}
Expand Down
32 changes: 13 additions & 19 deletions src/components/seekbar/seekbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class SeekBar extends Component {
return;
}
if (this.props.isDraggingActive) {
const oldTime = this.props.player.currentTime;
const oldTime = this.props.currentTime;
const newTime = this.getTime(e);
this.props.changeCurrentTime(newTime);
this.updateSeekBarProgress(newTime, this.props.duration);
Expand Down Expand Up @@ -239,57 +239,51 @@ class SeekBar extends Component {
* @memberof SeekBar
*/
handleKeydown(event: KeyboardEvent, isAccessibility: boolean): void {
const {player} = this.props;
const {duration, currentTime} = this.props;
/**
* Do seek operations.
* @param {number} from - Seek start point.
* @param {number} to - Seek end point.
* @returns {void}
*/
const seek = (from: number, to: number) => {
player.currentTime = to;
this.updateSeekBarProgress(player.currentTime, this.props.duration, true);
this.props.changeCurrentTime(to);
this.updateSeekBarProgress(to, duration, true);
this.props.notifyChange({
from: from,
to: to
});
};
let newTime;
this.props.updatePlayerHoverState(true);
const basePosition = player.isLive() ? player.getStartTimeOfDvrWindow() : 0;
const duration = player.isLive() ? player.liveDuration : player.duration;
switch (event.keyCode) {
case KeyMap.LEFT:
if (!isAccessibility) {
this.props.updateOverlayActionIcon(IconType.Rewind);
}
newTime = player.currentTime - KEYBOARD_DEFAULT_SEEK_JUMP > basePosition ? player.currentTime - KEYBOARD_DEFAULT_SEEK_JUMP : basePosition;
seek(player.currentTime, newTime);
newTime = currentTime - KEYBOARD_DEFAULT_SEEK_JUMP > 0 ? currentTime - KEYBOARD_DEFAULT_SEEK_JUMP : 0;
seek(currentTime, newTime);
break;
case KeyMap.RIGHT:
if (!isAccessibility) {
this.props.updateOverlayActionIcon(IconType.Forward);
}
newTime = player.currentTime + KEYBOARD_DEFAULT_SEEK_JUMP > duration ? duration : player.currentTime + KEYBOARD_DEFAULT_SEEK_JUMP;
seek(player.currentTime, newTime);
newTime = currentTime + KEYBOARD_DEFAULT_SEEK_JUMP > duration ? duration : currentTime + KEYBOARD_DEFAULT_SEEK_JUMP;
seek(currentTime, newTime);
break;
case KeyMap.HOME:
if (!isAccessibility) {
this.props.updateOverlayActionIcon(IconType.StartOver);
}
newTime = basePosition;
seek(player.currentTime, newTime);
newTime = 0;
seek(currentTime, newTime);
break;
case KeyMap.END:
if (!isAccessibility) {
this.props.updateOverlayActionIcon(IconType.SeekEnd);
}
if (player.isLive()) {
player.seekToLiveEdge();
} else {
newTime = duration;
seek(player.currentTime, newTime);
}
newTime = duration;
seek(currentTime, newTime);
break;
}
}
Expand Down Expand Up @@ -320,7 +314,7 @@ class SeekBar extends Component {
onSeekbarTouchEnd = (e: Event): void => {
if (this.props.isDraggingActive) {
let time = this.getTime(e);
const oldTime = this.props.player.currentTime;
const oldTime = this.props.currentTime;
const newTime = time;
this.props.changeCurrentTime(newTime);
this.updateSeekBarProgress(newTime, this.props.duration);
Expand Down

0 comments on commit 2892bac

Please sign in to comment.