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

2.0 Minimap: canvas click does nothing; Initial load does not display waveform #1265

Closed
PureSqncMedia opened this issue Dec 6, 2017 · 7 comments · Fixed by #1315
Closed

Comments

@PureSqncMedia
Copy link

PureSqncMedia commented Dec 6, 2017

Having trouble with minimap plugin on version 2

Wavesurfer.js version(s):

2.0 beta 2

Browser version(s):

Chrome Version 62.0.3202.94 (Official Build) (64-bit)

Code needed to reproduce the issue:

  • Angular 1x.
  • wavesurfer.js and Minimap plugin built into vendor.js file via gulp
  • directive loads wavesurfer and minimap.
  • controller inits minimap later

(1) Canvas click issue:

Clicking on minimap canvas scrolled the audio on 1x, now nothing happens. Only main WS container canvas can be intereacted with. Hopefully I am missing some minimap config detail

(2) Minimap waveform does not display on first initialization?

Minimap will not show waveform on first load.
** Soution found: Found that the sequence of loading the minimap cleared the problem.
Im not sure about the operations around promises but toggling the minimap before 'ready' seems to clear for me. code snippet:

vm.wavesurfer.load(activeUrl || null); vm.wavesurfer.once('ready', function () { // do stuff }); _toggleMinimap();

@PureSqncMedia
Copy link
Author

Found that changing the backend to 'mediaelement' seems to clear the minimap render issue, but creates other problems. I think I need to add a timeout or something before loading minimap. does not seem to solve canvas interaction though

@thijstriemstra
Copy link
Contributor

@PureSqncMedia can you try with 2.0.1?

@thijstriemstra
Copy link
Contributor

related to f08cfbd perhaps.

@thijstriemstra
Copy link
Contributor

Soution found: Found that the sequence of loading the minimap cleared the problem.

And can you make a pull request so we can take a look at the fix?

@PureSqncMedia
Copy link
Author

PureSqncMedia commented Dec 28, 2017

@thijstriemstra I tried with 2.0.1 and still no interaction on the minimap canvas. I might try with 'mediaelement' backend, or is that not recommended?

The code fix I found for minimap canvas render is just loading sequence for wavesurfer. I dont believe valuable for a pr. I did not have the rendering or canvas interaction issues on 1.x versions though, same UI process

vm.player.wavesurfer.once('ready', function () {
      .. do stuff on ready, like play
      // loading minimap in here results in first track played not rendering minimap.
       // a subsequential load and load minimap seems to display correctly
        // so moved the add plugin part outside of ready block
});

//works first load
vm.wavesurfer.addPlugin(MiniMapPlugin.create(detail_minimap_wave_options)).initPlugin('minimap');

@roboswank
Copy link
Contributor

roboswank commented Jan 26, 2018

@thijstriemstra @PureSqncMedia

This could be semi related to #1311

minimap.js line 113 (v2.0.3 of wavesurfer)

this.renderEvent =
            ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';

If I change that to this.renderEvent = 'ready';, minimap functions as it did before and can be passed in the plugins array just the same.

I only say it could be related to #1311 because it appears in both cases something was expecting there to be peak data available but there is not.
Right before waveform-ready is fired, this.backend.setPeaks(null) is called, and I do not see anything in there that would set the peaks before firing it.

I do not necessarily know what the desired behavior here is. Like what potential negatives would come from listening to the ready event instead.

Edit: I have a solution for the click issue. Will open PR and see what you think.

roboswank added a commit to roboswank/wavesurfer.js that referenced this issue Jan 26, 2018
Attach click event to drawer wrapper and fire event with the position
thijstriemstra pushed a commit that referenced this issue Jan 26, 2018
Attach click event to drawer wrapper and fire event with the position
@elliottb303
Copy link

@thijstriemstra @roboswank Just updated and happy to see that minimap canvas works now! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants