Skip to content

Commit

Permalink
Listen to and relay play and pause events on media element (#1104)
Browse files Browse the repository at this point in the history
* Listen to and relay play and pause events on media element

* Corrected the 'pause' event label

* removed play and pause emits from respective functions
  • Loading branch information
nlicitra authored and mspae committed Aug 19, 2017
1 parent 2dc9727 commit bcb5ae2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mediaelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export default class MediaElement extends WebAudio {
this.fireEvent('finish');
});

// Listen to and relay play and pause events to enable
// playback control from the external media element
media.addEventListener('play', () => {
this.fireEvent('play');
});

media.addEventListener('pause', () => {
this.fireEvent('pause');
});

this.media = media;
this.peaks = peaks;
this.onPlayEnd = null;
Expand Down Expand Up @@ -214,7 +224,6 @@ export default class MediaElement extends WebAudio {
this.seekTo(start);
this.media.play();
end && this.setPlayEnd(end);
this.fireEvent('play');
}

/**
Expand All @@ -225,7 +234,6 @@ export default class MediaElement extends WebAudio {
pause() {
this.media && this.media.pause();
this.clearPlayEnd();
this.fireEvent('pause');
}

/** @private */
Expand Down

0 comments on commit bcb5ae2

Please sign in to comment.