7244f99c by andrewmnlv Committed by David LaPalomento

fix: SegmentLoader.handleUpdateEnd_ run after player was disposed (#711)

Remove handleUpdateEnd event listener after the player is disposed.
1 parent 50dd3d26
...@@ -22,7 +22,7 @@ export default class SourceUpdater { ...@@ -22,7 +22,7 @@ export default class SourceUpdater {
22 22
23 // run completion handlers and process callbacks as updateend 23 // run completion handlers and process callbacks as updateend
24 // events fire 24 // events fire
25 this.sourceBuffer_.addEventListener('updateend', () => { 25 this.onUpdateendCallback_ = () => {
26 let pendingCallback = this.pendingCallback_; 26 let pendingCallback = this.pendingCallback_;
27 27
28 this.pendingCallback_ = null; 28 this.pendingCallback_ = null;
...@@ -30,9 +30,11 @@ export default class SourceUpdater { ...@@ -30,9 +30,11 @@ export default class SourceUpdater {
30 if (pendingCallback) { 30 if (pendingCallback) {
31 pendingCallback(); 31 pendingCallback();
32 } 32 }
33 }); 33
34 this.sourceBuffer_.addEventListener('updateend', 34 this.runCallback_();
35 this.runCallback_.bind(this)); 35 };
36
37 this.sourceBuffer_.addEventListener('updateend', this.onUpdateendCallback_);
36 38
37 this.runCallback_(); 39 this.runCallback_();
38 }; 40 };
...@@ -162,6 +164,7 @@ export default class SourceUpdater { ...@@ -162,6 +164,7 @@ export default class SourceUpdater {
162 * dispose of the source updater and the underlying sourceBuffer 164 * dispose of the source updater and the underlying sourceBuffer
163 */ 165 */
164 dispose() { 166 dispose() {
167 this.sourceBuffer_.removeEventListener('updateend', this.onUpdateendCallback_);
165 if (this.sourceBuffer_ && this.mediaSource.readyState === 'open') { 168 if (this.sourceBuffer_ && this.mediaSource.readyState === 'open') {
166 this.sourceBuffer_.abort(); 169 this.sourceBuffer_.abort();
167 } 170 }
......