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

Zoom into a segment #415

Open
sshadmand opened this issue Oct 23, 2021 · 1 comment
Open

Zoom into a segment #415

sshadmand opened this issue Oct 23, 2021 · 1 comment

Comments

@sshadmand
Copy link

My apologies if I missed it, but I didn't see any reference to this in the docs (https://github.com/bbc/peaks.js#instanceviewscreatezoomviewcontainer) or past GH issues.

  1. Given a segment, I would like to zoom into that segment so it is the only part of an audio displayed to a user.
  2. (and/or) I would like to restrict playing and interaction to only be within that segment. I.e. if a user clicks anywhere else than within the segment, nothing happens.

Thanks for your help!

@chrisn
Copy link
Member

chrisn commented Oct 25, 2021

Thank you for the question. You should be able to do something like this to zoom to fit a segment to the display:

const view = peaks.views.getView('zoomview');
const duration = segment.endTime - segment.startTime;
view.setZoom({ seconds: duration });
view.setStartTime(segment.startTime);

But it may not be possible to achieve the zoom level you want as you can't zoom in more closely than the original waveform data resolution. Zooming out from that resolution is fine.

Restricting interaction to a segment is currently not possible although it could be added I guess.

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

No branches or pull requests

2 participants