Add back playing media listener, refactor

This commit is contained in:
Jordan Eldredge 2016-08-02 23:37:04 -07:00
parent e588b76203
commit dc81083ed3

View file

@ -16,11 +16,7 @@ module.exports = {
this.dispatch({type: 'SET_BALANCE', balance: options.balance});
this.loadFromUrl(options.mediaFile.url, options.mediaFile.name);
this.dispatch(setSkinFromUrl(options.skinUrl));
this._registerListeners();
return this;
},
_registerListeners: function() {
this.media.addEventListener('timeupdate', () => {
this.dispatch({type: 'UPDATE_TIME_ELAPSED', elapsed: this.media.timeElapsed()});
});
@ -29,6 +25,10 @@ module.exports = {
this.dispatch({type: 'SET_MEDIA_STATUS', status: 'STOPPED'});
});
this.media.addEventListener('playing', () => {
this.dispatch({type: 'SET_MEDIA_STATUS', status: 'PLAYING'});
});
this.media.addEventListener('waiting', () => {
this.dispatch({type: 'START_WORKING'});
});
@ -40,6 +40,7 @@ module.exports = {
this.fileInput.onchange = (e) => {
this.loadFromFileReference(e.target.files[0]);
};
return this;
},
/* Functions */