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

Load existing media element #707

Merged
merged 9 commits into from
May 12, 2016

Conversation

therewasaguy
Copy link
Contributor

@therewasaguy therewasaguy commented Apr 25, 2016

Adds the ability to load an existing HTML5 or

Usage:

init wavesurfer with backend: 'MediaElement'.

 wavesurfer.util.ajax({
    responseType: 'json',
    url: waveformPath // path to .json file with precomputed waveform data
  }).
  on('success', function (data) {
      wavesurfer.loadExistingMediaElement( htmlElement, data);
  });

What is the best way to document this? Should I add a line to docs/methods.html in the gh-pages branch and an example?

If anyone has suggestions let me know and I'll happily update the PR.

( re #698 )

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 4.587% when pulling 2805b72 on therewasaguy:load-existing-media-elt into 26657a8 on katspaugh:master.

var media = elt;
media.controls = this.params.mediaControls;
media.autoplay = this.params.autoplay || false;
media.style.width = '100%';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't change the way an existing element looks? It can be done in the app's CSS.

@katspaugh
Copy link
Owner

What is the best way to document this? Should I add a line to docs/methods.html in the gh-pages branch and an example?

Yeah, sure. An example with an existing video element would be nice, since it's asked about a lot.

Thank you very much!

@therewasaguy
Copy link
Contributor Author

Thanks for your quick feedback, @katspaugh! All good points, and I'm sorry I should have updated some of these before sending the PR.

I will update this all soon, and I'll add a demo with video.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 4.667% when pulling 48ffdde on therewasaguy:load-existing-media-elt into 622322d on katspaugh:master.

@therewasaguy
Copy link
Contributor Author

therewasaguy commented Apr 29, 2016

Updated and added an example using a <video>.

While consolidating the code, I was thinking... why not could just use load for existing media elements, rather than create a separate method? load does type checking and if the first argument is not a string (path to media file) but is instead an existing media element, load knows what to do. Does that sound like a good approach?

@katspaugh
Copy link
Owner

Thanks!

Does that sound like a good approach?

Yep, sounds like a good idea!

@@ -89,7 +124,7 @@ WaveSurfer.util.extend(WaveSurfer.MediaElement, {
},

seekTo: function (start) {
if (start != null) {
if (start) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change this? If start is 0 we want to go to the beginning, not to the current position.

Copy link
Contributor Author

@therewasaguy therewasaguy Apr 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I will revert this. While I was testing, setting media element .currentTime was always going back to zero, and I made this while troubleshooting before I realized it was due to the server (python simple server) and had nothing to do with the library. I should have reverted this and remembered that from your stack overflow post. Works fine on other servers.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 4.667% when pulling b3e8112 on therewasaguy:load-existing-media-elt into 622322d on katspaugh:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 4.667% when pulling b202eb1 on therewasaguy:load-existing-media-elt into 622322d on katspaugh:master.

@katspaugh katspaugh merged commit 4079d54 into katspaugh:master May 12, 2016
@katspaugh
Copy link
Owner

Thanks a lot, @therewasaguy!

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.

None yet

3 participants