Skip to content
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

Listen to and relay play and pause events on media element #1104

Merged
merged 4 commits into from
Jun 8, 2017

Conversation

nlicitra
Copy link
Contributor

Short description of changes:

Added automatic listening to the "play" and "pause" events of the provided media element. In the current implementation, I can only control audio playback from within the context of wavesurfer.js. In the application I'm building, I want to have the media element be the single source of audio playback control, allowing the wavesurfer.js instance to be a single part of a group of visualizations rather than the main controller.

Breaking in the external API:

None that I am aware of

Breaking changes in the internal API:

None that I am aware of

Todos/Notes:

I don't know if this has any unexpected consequences but it worked perfectly for me with this simple change when running wavesurfer.js with the {backend: "MediaElement"} configuration.

Related Issues and other PRs:

N/A

@katspaugh
Copy link
Owner

This is a good idea!

However, won't this double fire the play and pause events when launched through wavesurfer.js (and not via the media element)? Maybe we need to remove the other fireEvent calls in the play and pause methods?

@nlicitra
Copy link
Contributor Author

Good thinking! I've removed the emit statements from the play and pause as the calls to this.media.play() and this.media.pause() should now cause the event to be fired automatically.

@nlicitra
Copy link
Contributor Author

nlicitra commented Jun 5, 2017

@katspaugh just want to follow up on my changes. Thanks!

@katspaugh
Copy link
Owner

Sorry, I was on vacation. Thank you, merged!

@katspaugh katspaugh merged commit dcd8b55 into katspaugh:master Jun 8, 2017
mspae pushed a commit to mspae/wavesurfer.js that referenced this pull request Aug 18, 2017
…#1104)

* Listen to and relay play and pause events on media element

* Corrected the 'pause' event label

* removed play and pause emits from respective functions
mspae pushed a commit that referenced this pull request Aug 19, 2017
* Listen to and relay play and pause events on media element

* Corrected the 'pause' event label

* removed play and pause emits from respective functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants