Skip to content

Commit

Permalink
fix(FEC-11035): catch resolve the promise chain and load create promi…
Browse files Browse the repository at this point in the history
…se for each call. (#553)

Issues: 
1. catch once resolve the promise chain for next.
2. Multiple load promises created by multiple load calls.

Solution: 
1. return promise reject to reject the chain 
2. create the loadPromise once until we'll get a reset or destroy.
  • Loading branch information
Yuvalke committed Mar 17, 2021
1 parent 089018c commit f1e2fff
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/engines/html5/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,22 +503,14 @@ export default class Html5 extends FakeEventTarget implements IEngine {
*/
load(startTime: ?number): Promise<Object> {
this._el.load();
return new Promise((resolve, reject) => {
this._canLoadMediaSourceAdapterPromise
.then(() => {
if (this._mediaSourceAdapter) {
this._mediaSourceAdapter
.load(startTime)
.then(tracks => resolve(tracks))
.catch(error => reject(error));
} else {
resolve({});
}
})
.catch(error => {
reject(error);
});
}).catch(error => this.dispatchEvent(new FakeEvent(Html5EventType.ERROR, error)));
return this._canLoadMediaSourceAdapterPromise
.then(() => {
return this._mediaSourceAdapter ? this._mediaSourceAdapter.load(startTime) : Promise.resolve({});
})
.catch(error => {
this.dispatchEvent(new FakeEvent(Html5EventType.ERROR, error));
return Promise.reject(error);
});
}

/**
Expand Down

0 comments on commit f1e2fff

Please sign in to comment.