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

Fix AudioStreamPlaybackInteractive::get_playback_position() always returning 0 #100262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adriano-sudario
Copy link

get_playback_position method from AudioStreamPlaybackInteractive is currently returning always 0.

Minimum Reproduction Project under scene bugs/interactive_stream_get_playback_position_returns_always_zero.tscn

@adriano-sudario adriano-sudario requested a review from a team as a code owner December 11, 2024 01:15
@adriano-sudario
Copy link
Author

This is not a bug, see:

* [Document `AudioStreamPlayer.get_playback_position()` intentionally aways returning `0.0` when using `AudioStreamInteractive` #99200](https://github.com/godotengine/godot/pull/99200)

I still believe it makes a lot more sense to return the current clip's playback position than just returning 0.
Maybe it could return -1 if more transitioning is happening? And then add this behavior to the documenation.
What do you think?

@AThousandShips
Copy link
Member

That'd be up to the audio team to decide, I just repeated what has been done recently

@timoschwarzer
Copy link
Contributor

I feel like returning 0 makes more sense here because this audio playback can have multiple streams play at the same time with different playback positions. I think there should be dedicated methods specifically for AudioStreamPlaybackInteractive to get playback positions of a specific stream by index/name and to get the stream indexes/names that are currently active and which state they are in (Fade In/Playing/Fade Out).

@basilicon
Copy link

If AudioStreamPlaybackInteractive is going to have dedicated methods for getting playback position for each stream anyways, could get_playback_position default to returning the playback position for the current stream, rather than doing nothing and returning 0? I feel always returning 0 feels weird, since clearly if something is playing, the playback position should be nonzero. The documentation could also specify that the returned playback position is only for the current stream, and recommends using those other methods for the other streams.

Also, I can't think of many use cases for get_playback_position (or even the other dedicated methods). First and foremost, you can't use playback position with AudioStreamInteractive for AudioStreamPlayer's seek() or play() methods, as currently AudioStreamInteractive only plays streams from their beginnings. The primary use for the get_playback_position method in this context is debugging, and I don't think it makes sense to have a debugging method always return 0.

This isn't totally related, but it might be nice to have some functionality for pausing/resuming AudioStreamInteractive's playback. It would be useful for when you need to temporarily pause the game to open a menu or play a cutscene or something, but don't want to restart the current stream from the beginning when you unpause. To me, this seems like the main reason why you might want to use a function like this in the first place; so you can stop playback and then resume it roughly where you left off.

@AThousandShips AThousandShips changed the title Fix AudioStreamPlaybackInteractive::get_playback_position() returning always 0 Fix AudioStreamPlaybackInteractive::get_playback_position() always returning 0 Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants