-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Any way to control the resolution of audio-position-changed
?
#24
Comments
Hmmm, are you subscribed to that event on the stereo service or on the sound itself? There's a 500ms poller on the stereo service that controls the Another thing worth trying for your situation is starting your own loop with a much smaller delay where you update the waveform if the sound is playing? The mozilla docs for |
I originally subscribed to that event on the sound, but I tried subscribing on the stereo service but that doesn't seem to make a difference. I tried overriding import Service from '@ember/service';
import stereo from 'ember-stereo/services/stereo';
export default class CustomStereoService extends stereo {
pollInterval = 50;
} And then I'm injecting it into my component like this:
When using that service I can call |
Hmm, not sure why the helpers would quit working, but yeah that is what I was thinking. I'd try the other suggestion then? From what I saw in some searches, it's not that the audio element doesn't have updated data, it just doesn't notify that it does at a really high frequency. What kind of things are you updating on the waveform player using that |
@jkeen I'm just updating the cusor position as it travels across the waveform and it just kind of jumps in half second increments instead of smoothly flowing. I didn't really mind that so much at first but then I started working on displaying regions and highlighting comments associated with those regions and I discovered that |
Oh ok, interesting. I'd try making an ember concurrency task that loops and monitors the position manually on the currently playing sound (perhaps even using the private |
Thanks for the tip on using the private So now the relevant bits of the component look something like this: togglePlaySoundTask = task(async () => {
await this.sound.togglePause();
if(this.sound.isPlaying){
this.pollForChanges.perform();
}
});
pollForChanges = task(async () => {
while(this.sound.isPlaying) {
let position = this.sound._currentPosition();
let timeInSeconds = position / 1000;
await this.wavesurfer.setTime(timeInSeconds);
await timeout(60);
}
}); I found that without the And if I use |
That task modifier syntax is nice—I realized my brain's default is still the decorator-style syntax like this: @task
*pollForChanges() {
while (this.sound.isPlaying) {
let position = this.sound._currentPosition();
let timeInSeconds = position / 1000;
yield this.wavesurfer.setTime(timeInSeconds);
yield timeout(60);
}
} but I guess I need to update my settings! Glad that solved it, but sorry for the hassle! The timeout is definitely key or else it just locks the browser, and I think doing a It would be nice to solve this in ember-stereo, though. I can definitely improve the frequency |
…24 chore: refactor where position is set on a playing sound
# [4.3.0](v4.2.3...v4.3.0) (2023-11-12) ### Features * improve firing resolution of audio-position-changed event. refs [#24](#24) ([0777253](0777253))
@jagthedrummer Just released 4.3.0 that should fix this issue! Subscribing to |
Awesome, @jkeen! I'll give it a try tomorrow. I'd already discovered that my implementation was less than ideal and performed pretty poorly if the timeout was too low. I was going to look at using animation frames to make sure that it wasn't firing too often, but it looks like you already have that in yours. Will give it a try and report back. |
Just wanted to report back that the fix in 4.3.0 is working great for me. I went back to just registering for the |
…24 chore: refactor where position is set on a playing sound
# [5.0.0-beta.19](v5.0.0-beta.18...v5.0.0-beta.19) (2024-03-18) ### Features * improve firing resolution of audio-position-changed event. refs [#24](#24) ([e1ebbc0](e1ebbc0))
# [5.0.0-beta.20](v5.0.0-beta.19...v5.0.0-beta.20) (2024-03-18) ### Bug Fixes * if crossorigin=anonymous fails on <audio> element, automatically try removing crossorigin. Resolves CORS issue ([3bbda22](3bbda22)) * Implement proper teardown on sound destruction ([f1d6355](f1d6355)) * only show durationWorkaroundTask error if the task wasn't cancelled ([c5f6b08](c5f6b08)) * Resolve issue introduced in last version when multiple sound position sliders on the same page ([a2dc4bd](a2dc4bd)) * resolve issue when trying to play a sound that is already playing. fixes [#23](#23) ([dc32ba3](dc32ba3)) * Resolve issue where sound-position-progress modifier would not work with howler since howler doesn't emit audio-position-changed events ([77408ff](77408ff)) * Resolve some more bugs with sound-position modifiers ([fb496c3](fb496c3)) * send pause event when releasing control of shared audio element ([f7fec45](f7fec45)) ### Features * Allow xhr option to be passed through to connections, so each connection can handle authenticated requests ([82fc6ad](82fc6ad)) * Fail native audio connection if xhr is passed, as native audio does not support that. ([93dea68](93dea68)) * improve firing resolution of audio-position-changed event. refs [#24](#24) ([0777253](0777253))
# [4.3.0](v4.2.3...v4.3.0) (2023-11-12) ### Features * improve firing resolution of audio-position-changed event. refs [#24](#24) ([0777253](0777253))
I've registered for the
audio-position-changed
event which I'm using to keep my waveform player up to date. I've noticed that the player updates kind of jerk and stutter and it seems like that's due to theaudio-position-changed
event only firing about twice a second at most. Is there any way to get that event to fire more often?The text was updated successfully, but these errors were encountered: