-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: clear event binding function references #38
Changes from 1 commit
2adaa99
5b011b6
4f667f4
a0630ca
ff26649
cdebe37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,22 @@ import {Error} from 'playkit-js' | |
import Widevine from './drm/widevine' | ||
import PlayReady from './drm/playready' | ||
|
||
|
||
type ShakaEventsType = { [event: string]: string }; | ||
|
||
/** | ||
* Shaka events enum | ||
* @type {Object} | ||
* @const | ||
*/ | ||
const SHAKA_EVENTS: ShakaEventsType = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enums convention are to lead with capitals and refer as singular (i.e. |
||
ERROR: 'error' , | ||
ADAPTION: 'adaption', | ||
BUFFERING: 'buffering', | ||
WAITING: 'waiting', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WAITING and PLAYING are HTML5 events |
||
PLAYING: 'playing' | ||
}; | ||
|
||
/** | ||
* Adapter of shaka lib for dash content | ||
* @classdesc | ||
|
@@ -212,11 +228,11 @@ export default class DashAdapter extends BaseMediaSourceAdapter { | |
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove redundant lines (!!!) |
||
_createAdapterFunctionBindings(): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do this logic statically when we declare the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dan-ziv what do you mean statically? we want to have the this bindings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _adapterEventsBindings: { [name: string]: Function } = { |
||
this._adapterEventsBindings['error'] = (event) => this._onError(event); | ||
this._adapterEventsBindings['adaption'] = () => this._onAdaptation(); | ||
this._adapterEventsBindings['buffering'] = (event) => this._onBuffering(event); | ||
this._adapterEventsBindings['waiting'] = () => this._onWaiting(); | ||
this._adapterEventsBindings['playing'] = () => this._onPlaying(); | ||
this._adapterEventsBindings[SHAKA_EVENTS.ERROR] = (event) => this._onError(event); | ||
this._adapterEventsBindings[SHAKA_EVENTS.ADAPTION] = () => this._onAdaptation(); | ||
this._adapterEventsBindings[SHAKA_EVENTS.BUFFERING] = (event) => this._onBuffering(event); | ||
this._adapterEventsBindings[SHAKA_EVENTS.WAITING] = () => this._onWaiting(); | ||
this._adapterEventsBindings[SHAKA_EVENTS.PLAYING] = () => this._onPlaying(); | ||
} | ||
|
||
/** | ||
|
@@ -226,12 +242,11 @@ export default class DashAdapter extends BaseMediaSourceAdapter { | |
* @returns {void} | ||
*/ | ||
_addBindings(): void { | ||
this._shaka.addEventListener('adaptation', this._adapterEventsBindings.adaption); | ||
this._shaka.addEventListener('error', this._adapterEventsBindings.error); | ||
this._shaka.addEventListener('buffering', this._adapterEventsBindings.buffering); | ||
//TODO use events enum when available | ||
this._videoElement.addEventListener('waiting', this._adapterEventsBindings.waiting); | ||
this._videoElement.addEventListener('playing', this._adapterEventsBindings.playing); | ||
this._shaka.addEventListener(SHAKA_EVENTS.ADAPTION, this._adapterEventsBindings.adaption); | ||
this._shaka.addEventListener(SHAKA_EVENTS.ERROR, this._adapterEventsBindings.error); | ||
this._shaka.addEventListener(SHAKA_EVENTS.BUFFERING, this._adapterEventsBindings.buffering); | ||
this._videoElement.addEventListener(SHAKA_EVENTS.WAITING, this._adapterEventsBindings.waiting); | ||
this._videoElement.addEventListener(SHAKA_EVENTS.PLAYING, this._adapterEventsBindings.playing); | ||
} | ||
|
||
/** | ||
|
@@ -241,12 +256,11 @@ export default class DashAdapter extends BaseMediaSourceAdapter { | |
* @returns {void} | ||
*/ | ||
_removeBindings(): void { | ||
this._shaka.removeEventListener('adaptation', this._adapterEventsBindings.adaption); | ||
this._shaka.removeEventListener('error', this._adapterEventsBindings.error); | ||
this._shaka.removeEventListener('buffering', this._adapterEventsBindings.buffering); | ||
//TODO use events enum when available | ||
this._videoElement.removeEventListener('waiting', this._adapterEventsBindings.waiting); | ||
this._videoElement.removeEventListener('playing', this._adapterEventsBindings.playing); | ||
this._shaka.removeEventListener(SHAKA_EVENTS.ADAPTION, this._adapterEventsBindings.adaption); | ||
this._shaka.removeEventListener(SHAKA_EVENTS.ERROR, this._adapterEventsBindings.error); | ||
this._shaka.removeEventListener(SHAKA_EVENTS.BUFFERING, this._adapterEventsBindings.buffering); | ||
this._videoElement.removeEventListener(SHAKA_EVENTS.WAITING, this._adapterEventsBindings.waiting); | ||
this._videoElement.removeEventListener(SHAKA_EVENTS.PLAYING, this._adapterEventsBindings.playing); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to
ShakaEventType