Skip to content

Commit

Permalink
feat(FEC-10682): signal seek in different way from buffering. (#508)
Browse files Browse the repository at this point in the history
Issue: seek and the buffer was signaled as the same state in the player - couldn't be able to find the difference between the real buffer and seeking.
Solution: add a new state for seeking to make sure it won't signal as a buffer.
  • Loading branch information
Yuvalke authored Nov 25, 2020
1 parent 21d7227 commit ec69082
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/state/state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export default class StateManager {
[Html5EventType.ERROR]: () => {
this._updateState(StateType.IDLE);
this._dispatchEvent();
},
[Html5EventType.SEEKED]: () => {
if (this._prevState && this._prevState.type === StateType.PLAYING) {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
}
}
},
[StateType.PAUSED]: {
Expand All @@ -111,9 +117,14 @@ export default class StateManager {
this._dispatchEvent();
},
[Html5EventType.WAITING]: () => {
this._updateState(StateType.BUFFERING);
this._lastWaitingTime = this._player.currentTime;
this._dispatchEvent();
if (this._player.seeking) {
this._updateState(StateType.LOADING);
this._dispatchEvent();
} else {
this._updateState(StateType.BUFFERING);
this._lastWaitingTime = this._player.currentTime;
this._dispatchEvent();
}
},
[Html5EventType.ENDED]: () => {
this._updateState(StateType.IDLE);
Expand All @@ -133,12 +144,6 @@ export default class StateManager {
this._updateState(StateType.PAUSED);
this._dispatchEvent();
},
[Html5EventType.SEEKED]: () => {
if (this._prevState && this._prevState.type === StateType.PLAYING) {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
}
},
[Html5EventType.TIME_UPDATE]: () => {
if (this._player.currentTime !== this._lastWaitingTime && this._prevState && this._prevState.type === StateType.PLAYING) {
this._lastWaitingTime = null;
Expand Down Expand Up @@ -228,7 +233,6 @@ export default class StateManager {
);
this._player.dispatchEvent(event);
}

/**
* Destroys the state manager.
* @public
Expand Down

0 comments on commit ec69082

Please sign in to comment.