zhw2590582 / WFPlayer

:ocean: WFPlayer.js is an audio waveform generator
https://wfplayer.js.org
MIT License
265 stars 33 forks source link

Feature Request: do not scroll until the end / some kind of padding #5

Closed moritz closed 3 years ago

moritz commented 4 years ago

I'd love to have an option for the cursor to jump to the next page slightly before it reaches the end of the current page.

My use case is that I want to annotate songs with their lyrics for creating Karaoke playbacks. Currently if the current page ends at 10 seconds, and I want to align a word (or a line) so that it starts 9.8 seconds, there is no way to see the full waveform for the current word.

zhw2590582 commented 4 years ago

In fact, I don’t quite understand what you said. If there is a lyric that starts at 9.8s, you want to display the next page before the cursor reaches 10s? In that case, when should I skip to the next page 10s ago? This is not easy to judge. I recommend manually adjusting the duration to adjust the display of the waveform:

wf.setOptions({
    duration: 20,
});

Similar example: https://subplayer.js.org

moritz commented 4 years ago

My idea would be have some sort of "padding" (I know, option name taken already). If you set duration to 10s and padding to 1s, then the first page shows the first 10s of wave form, but skips to the second page as soon as the cursor reaches 9s. Then the second page shows 9s to 19s, and skips to page 3 when the cursor reaches 18s (1s before the end of the current page).

Changing duration just shifts the problem. When I set the duration to 20s, I have the same problem as before with lyrics that start at 19.8s. Moreover, when I'm not on the first page, but, say, at 2 minutes with duration set to 20s, then switching duration and thus zoom level moves the cursor around wildly.

zhw2590582 commented 4 years ago

I understand what you mean, but a lot of code changes are needed to implement it, I want to think about it