Skip to content

Commit

Permalink
fix(FEC-9471): slider progress bar exceeds 100% (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyBregman authored Dec 5, 2019
1 parent 0efeb17 commit fafad30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class Flash extends FakeEventTarget implements IEngine {
* @type {Object}
* @private
*/
_config: Object = null;
_config: ?Object = null;

/**
* Promise when load finished
* @type {Promise<*>}
* @private
*/
_loadPromise: Promise<*> = null;
_loadPromise: ?Promise<*> = null;

/**
* volume value
Expand Down Expand Up @@ -303,7 +303,8 @@ class Flash extends FakeEventTarget implements IEngine {
EventType.SEEKED,
EventType.ENDED,
EventType.VIDEO_TRACK_CHANGED,
EventType.AUDIO_TRACK_CHANGED
EventType.AUDIO_TRACK_CHANGED,
EventType.DURATION_CHANGE
];
events.forEach(eventName => {
this._eventManager.listen(this._api, eventName, (event: FakeEvent) => this.dispatchEvent(event));
Expand Down Expand Up @@ -419,11 +420,13 @@ class Flash extends FakeEventTarget implements IEngine {
* @returns {void}
*/
play(): void {
this._loadPromise.then(() => {
if (this._api) {
this._api.play();
}
});
if (this._loadPromise) {
this._loadPromise.then(() => {
if (this._api) {
this._api.play();
}
});
}
}

pause(): void {
Expand Down Expand Up @@ -799,7 +802,7 @@ class Flash extends FakeEventTarget implements IEngine {
* @returns {boolean} - Whether the video tag has an attribute of playsinline.
*/
get playsinline(): boolean {
return this._config.playsinline;
return this._config ? this._config.playsinline : false;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/flashhls-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ class FlashHLSAdapter extends FakeEventTarget {
},
position: (timemetrics: Object) => {
this.paused = false;
this.duration = timemetrics.duration;
if (this.duration != timemetrics.duration) {
this.duration = timemetrics.duration;
this._trigger(EventType.DURATION_CHANGE);
}
this.buffer = timemetrics.buffer;
this.watched = timemetrics.watched;
if (this.currentTime != timemetrics.position || this.ended) {
Expand Down Expand Up @@ -254,6 +257,7 @@ class FlashHLSAdapter extends FakeEventTarget {

seek(to: number): void {
if (this._api) {
this.currentTime = to;
this._api.seek(to);
}
}
Expand Down

0 comments on commit fafad30

Please sign in to comment.