Skip to content

Commit

Permalink
fix(FEC-10760): Youbora - bufferUnderrun event fired when buffering s…
Browse files Browse the repository at this point in the history
…tarted and no bufferDuration in Ping events (#516)
  • Loading branch information
Dan Ziv committed Dec 8, 2020
1 parent 9a0d4f6 commit a287fa4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 67 deletions.
78 changes: 21 additions & 57 deletions src/state/state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {StateType} from './state-type';
import {CustomEventType, Html5EventType} from '../event/event-type';
import FakeEvent from '../event/fake-event';
import getLogger from '../utils/logger';
import Env from '../utils/env';

/**
* This class responsible to manage all the state machine of the player.
Expand Down Expand Up @@ -68,87 +69,49 @@ export default class StateManager {
*/
_transitions: Transition = {
[StateType.IDLE]: {
[Html5EventType.LOAD_START]: () => {
this._updateState(StateType.LOADING);
this._dispatchEvent();
},
[Html5EventType.PLAY]: () => {
this._updateState(StateType.BUFFERING);
this._dispatchEvent();
},
[Html5EventType.SEEKED]: () => {
this._updateState(StateType.PAUSED);
this._dispatchEvent();
}
[Html5EventType.LOAD_START]: () => this._updateState(StateType.LOADING),
[Html5EventType.PLAY]: () => this._updateState(StateType.BUFFERING),
[Html5EventType.SEEKED]: () => this._updateState(StateType.PAUSED)
},
[StateType.LOADING]: {
[Html5EventType.LOADED_METADATA]: () => {
this._updateState(StateType.PAUSED);
this._dispatchEvent();
},
[Html5EventType.ERROR]: () => {
this._updateState(StateType.IDLE);
this._dispatchEvent();
},
[Html5EventType.LOADED_METADATA]: () => this._updateState(StateType.PAUSED),
[Html5EventType.ERROR]: () => this._updateState(StateType.IDLE),
[Html5EventType.SEEKED]: () => {
if (this._prevState && this._prevState.type === StateType.PLAYING) {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
}
}
},
[StateType.PAUSED]: {
[Html5EventType.PLAY]: () => {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
},
[Html5EventType.PLAYING]: () => {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
},
[Html5EventType.ENDED]: () => {
this._updateState(StateType.IDLE);
this._dispatchEvent();
}
[Html5EventType.PLAY]: () => this._updateState(StateType.PLAYING),
[Html5EventType.PLAYING]: () => this._updateState(StateType.PLAYING),
[Html5EventType.ENDED]: () => this._updateState(StateType.IDLE)
},
[StateType.PLAYING]: {
[Html5EventType.PAUSE]: () => {
this._updateState(StateType.PAUSED);
this._dispatchEvent();
},
[Html5EventType.PAUSE]: () => this._updateState(StateType.PAUSED),
[Html5EventType.WAITING]: () => {
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);
this._dispatchEvent();
},
[Html5EventType.ERROR]: () => {
this._updateState(StateType.IDLE);
this._dispatchEvent();
}
[Html5EventType.ENDED]: () => this._updateState(StateType.IDLE),
[Html5EventType.ERROR]: () => this._updateState(StateType.IDLE)
},
[StateType.BUFFERING]: {
[Html5EventType.PLAYING]: () => {
this._updateState(StateType.PLAYING);
this._dispatchEvent();
},
[Html5EventType.PAUSE]: () => {
this._updateState(StateType.PAUSED);
this._dispatchEvent();
},
[Html5EventType.PLAYING]: () => this._updateState(StateType.PLAYING),
[Html5EventType.PAUSE]: () => this._updateState(StateType.PAUSED),
[Html5EventType.TIME_UPDATE]: () => {
if (this._player.currentTime !== this._lastWaitingTime && this._prevState && this._prevState.type === StateType.PLAYING) {
if (
Env.browser.name === 'IE' &&
this._player.currentTime !== this._lastWaitingTime &&
this._prevState &&
this._prevState.type === StateType.PLAYING
) {
this._lastWaitingTime = null;
this._updateState(StateType.PLAYING);
this._dispatchEvent();
}
}
}
Expand Down Expand Up @@ -215,6 +178,7 @@ export default class StateManager {
this._prevState = this._curState;
this._curState = new State(type);
this._logger.debug(`Switch player state: from ${this._prevState.type} to ${this._curState.type}`);
this._dispatchEvent();
}
}

Expand Down
20 changes: 10 additions & 10 deletions test/src/configs/external-captions.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"He": {
"url": "http://externaltests.dev.kaltura.com/player/library_Player_V3/Captions/Caption_files_VTT/hebrew.vtt",
"label": "Heb",
"language": "he",
"type": "vtt",
"default": false
"url": "http://externaltests.dev.kaltura.com/player/library_Player_V3/Captions/Caption_files_VTT/hebrew.vtt",
"label": "Heb",
"language": "he",
"type": "vtt",
"default": false
},
"Ru": {
"url": "http://externaltests.dev.kaltura.com/player/library_Player_V3/Captions/Caption_files_VTT/hebrew.vtt",
"label": "Rus",
"language": "ru",
"type": "vtt",
"default": false
"url": "http://externaltests.dev.kaltura.com/player/library_Player_V3/Captions/Caption_files_VTT/hebrew.vtt",
"label": "Rus",
"language": "ru",
"type": "vtt",
"default": false
}
}

0 comments on commit a287fa4

Please sign in to comment.