Skip to content

Commit

Permalink
Merge pull request video-dev#1559 from azu/fix-events-default-exports
Browse files Browse the repository at this point in the history
fix `events.js` and `hls.js`
  • Loading branch information
mangui authored Feb 9, 2018
2 parents fb78755 + 45a34e3 commit 44286cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/events.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @typedef {string} HlsEvent
* @enum {HlsEvents}
* @readonly
* @enum {string}
*/
export default HlsEvents = {
const HlsEvents = {
// fired before MediaSource is attaching to media element - data: { media }
MEDIA_ATTACHING: 'hlsMediaAttaching',
// fired when MediaSource has been succesfully attached to media element - data: { }
Expand Down Expand Up @@ -110,3 +110,4 @@ export default HlsEvents = {
// fired upon stream controller state transitions - data: { previousState, nextState }
STREAM_STATE_TRANSITION: 'hlsStreamStateTransition'
};
export default HlsEvents;
11 changes: 5 additions & 6 deletions src/hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {hlsDefaultConfig} from './config';
import {FragmentTracker} from './helper/fragment-tracker';

import HlsEvents from './events';

import EventEmitter from 'events';

// polyfill for IE11
Expand Down Expand Up @@ -50,7 +49,7 @@ export default class Hls {
* @type {HlsEvents}
*/
static get Events() {
return Event;
return HlsEvents;
}

/**
Expand Down Expand Up @@ -239,7 +238,7 @@ export default class Hls {
*/
destroy() {
logger.log('destroy');
this.trigger(Event.DESTROYING);
this.trigger(HlsEvents.DESTROYING);
this.detachMedia();
this.coreComponents.concat(this.networkControllers).forEach(component => {component.destroy();});
this.url = null;
Expand All @@ -254,15 +253,15 @@ export default class Hls {
attachMedia(media) {
logger.log('attachMedia');
this.media = media;
this.trigger(Event.MEDIA_ATTACHING, {media: media});
this.trigger(HlsEvents.MEDIA_ATTACHING, {media: media});
}

/**
* Detach from the media
*/
detachMedia() {
logger.log('detachMedia');
this.trigger(Event.MEDIA_DETACHING);
this.trigger(HlsEvents.MEDIA_DETACHING);
this.media = null;
}

Expand All @@ -275,7 +274,7 @@ export default class Hls {
logger.log(`loadSource:${url}`);
this.url = url;
// when attaching to a source URL, trigger a playlist load
this.trigger(Event.MANIFEST_LOADING, {url: url});
this.trigger(HlsEvents.MANIFEST_LOADING, {url: url});
}

/**
Expand Down

0 comments on commit 44286cf

Please sign in to comment.