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

when playing a region, the region-in event and region-out event fired almost same time(less than 20 micro-seconds) which lead to playing region fails #3781

Open
alexzhangmaker opened this issue Jul 11, 2024 · 3 comments

Comments

@alexzhangmaker
Copy link

the console output:
timeRegionIn:1720684628131===>timeRegionOut:1720684628138, delta:7
here the number is Date().getTime(), and the delta is the difference between in and out event.

And below is the region to be play, and we can see the start and end is "start": 6.310421089646, "end": 8.87566764644661
{
"listeners": {
"update": {},
"update-end": {},
"play": {},
"click": {},
"dblclick": {},
"remove": {}
},
"totalDuration": 237.145397,
"numberOfChannels": 1,
"minLength": 0,
"maxLength": null,
"contentEditable": false,
"subscriptions": [
null,
null,
null
],
"id": "region-g4950a6n02g",
"start": 6.310421089646,
"end": 8.87566764644661,
"drag": false,
"resize": true,
"color": "rgba(58.7709341160575, 222.1914898683647, 59.940289305805834, 0.5)",
"channelIdx": -1,
"element": {},
"content": {}
}

And this happens very often.

Can anyone please help to figure out the reason? Thanks

@pengzhendong
Copy link
Contributor

pengzhendong commented Jul 19, 2024

Reproduced:

  1. Open https://wavesurfer.xyz/examples/?regions.js
  2. Drag the Drag me, and then click it
Updated region r {listeners: {…}, totalDuration: 26.386688, numberOfChannels: 2, minLength: 0, maxLength: Infinity, …}
region-in r {listeners: {…}, totalDuration: 26.386688, numberOfChannels: 2, minLength: 0, maxLength: Infinity, …}
region-out r {listeners: {…}, totalDuration: 26.386688, numberOfChannels: 2, minLength: 0, maxLength: Infinity, …}
region-in r {listeners: {…}, totalDuration: 26.386688, numberOfChannels: 2, minLength: 0, maxLength: Infinity, …}

@katspaugh
Copy link
Owner

The reason is probably the browser seeking back and forth when the audio is unbuffered. I’ve seen this behavior in Safari.
You can set a backend: 'WebAudio' option to mitigate this.

@alexzhangmaker
Copy link
Author

@katspaugh Thanks. problem solved by adding "backend: 'WebAudio'" option.

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

No branches or pull requests

3 participants