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

AudioStreamPlayer not returning position on get_playback_position() on HTML5 #95128

Closed
togie14 opened this issue Aug 4, 2024 · 5 comments · Fixed by #95197
Closed

AudioStreamPlayer not returning position on get_playback_position() on HTML5 #95128

togie14 opened this issue Aug 4, 2024 · 5 comments · Fixed by #95197

Comments

@togie14
Copy link

togie14 commented Aug 4, 2024

Tested versions

-reproducible in v4.3.beta3.official [82cedc8]
-not reproducible in v4.2.2.stable.official [15073af]

System information

Windows 11 Godot v4.3.beta3.official [82cedc8]

Issue description

HTML5 export returns same value no matter what position song is at while using AudioStreamMP3, changed the AudioStreamPlayer type to the new synchronized and now i am getting correct results on exported project.

Side note, it seems that it always returning 0.00290249427781 regardless of which song is played.

Steps to reproduce

Create new project and add AudioStreamPlayer and Label to scene
Attach mp3 to AudioStreamPlayer and set autoplay to true
Create script that updates label.text with AudioStreamPlayer.get_playback_positon() in _process
Export to web build and test

Minimal reproduction project (MRP)

This is a fairly easy project to create..

@AThousandShips
Copy link
Member

Please confirm with a recent version like rc2

@akien-mga
Copy link
Member

I can confirm the issue in 4.3.rc2, with both OGG and MP3 files.

MRP: testtt.zip

@adamscott
Copy link
Member

adamscott commented Aug 6, 2024

So I can confirm this issue as the fix cannot be implemented as is right now for the 4.3.0 release.*

The WebAudio API for AudioBufferSourceNode doesn't have a playhead parameter. The only guarantee is that we know whether a AudioBufferSourceNode is playing or not.

There's an existing WebAudio API issue.

There's a way to know that "playhead" parameter though, if we use the code that is mentioned here: WebAudio/web-audio-api#2397 (comment) (along with a fix). It's not perfect, but it's the most precise "playhead" that we can have.

But implementing this is 4.4 material, maybe cherry-pickable for 4.3.1.

*I know about #95197 by @yahkr, see my comment: #95197 (comment)

@akien-mga
Copy link
Member

@adamscott If this can't be fixed for 4.3, this should be documented in the description of get_playback_position, so users understand why it doesn't work.

And it should probably return a sentinel value (0 or -1) instead of (seemingly?) uninitialized memory.

@adamscott
Copy link
Member

@adamscott If this can't be fixed for 4.3, this should be documented in the description of get_playback_position, so users understand why it doesn't work.

And it should probably return a sentinel value (0 or -1) instead of (seemingly?) uninitialized memory.

@akien-mga I need to test @yahkr PR, as they implemented what I wanted to do but didn't had the time to do so the last days (being not available/time with my family). I'll do this for tomorrow, so maybe this can be fixed for 4.3.

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