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

Toggle autoplay in ConcatenatingAudioSource #917

Open
martinc2907 opened this issue Jan 9, 2023 · 12 comments
Open

Toggle autoplay in ConcatenatingAudioSource #917

martinc2907 opened this issue Jan 9, 2023 · 12 comments
Assignees
Labels
1 backlog enhancement New feature or request

Comments

@martinc2907
Copy link

Is your feature request related to a problem? Please describe.
The ConcatenatingAudioSource automatically skips to the next item when the previous item finishes playback. But I need a way to control this behavior by toggling 'autoplay' on/off.

Describe the solution you'd like
A way to toggle autoplay would be nice.

Describe alternatives you've considered
I have tried to manually pause the player when an item is nearing the end of its duration. This solution is not optimal as the pause method is async and playback may finish while the pause method is being processed. It is also not possible to pause at exactly the end of the audio.

Additional context

@ryanheise
Copy link
Owner

I think it's a good idea. While there is a native API to achieve this on iOS, there isn't an API for this yet on Android.

There is an ExoPlayer issue tracking this at google/ExoPlayer#5660

@martinc2907
Copy link
Author

Ah I see, surprised to see that ExoPlayer does not have this functionality yet.

@ryanheise
Copy link
Owner

Note that you can in theory emulate this behaviour quite accurately by using ConcatenatingAudioSource as a tool to prepare the gapless playback queue rather than using it directly as your playlist. You can dynamically remove all following items in the queue if you want it to stop at the end of the current item. Then you can dynamically add more items when you want to allow it to autoplay.

@martinc2907
Copy link
Author

martinc2907 commented Jan 10, 2023

Sounds like an interesting solution as long as an accurate queue(i.e. items after the current index) does not need to be maintained. My UI needs to show the next items in the queue so I don't think it would work.

@ryanheise
Copy link
Owner

Yes, the solution should definitely work but the key point is to use this API as an auto playback queue rather than a playlist. Once you do that, you should be aware that just_audio's state represents the state of that queue and does not represent the playlist state of your app. But accepting that, there is nothing preventing you from maintaining your own state for such purposes and only using just_audio to manage the auto playback queue.

@martinc2907
Copy link
Author

martinc2907 commented Jan 25, 2023

I think it's a good idea. While there is a native API to achieve this on iOS, there isn't an API for this yet on Android.

There is an ExoPlayer issue tracking this at google/ExoPlayer#5660

Seems like ExoPlayer supports pausing at the end of media items since v2.12. What it doesn't support is pausing at arbitrary frames.

@martinc2907
Copy link
Author

@ryanheise
Copy link
Owner

Thanks for noticing that. This issue therefore has no blockers - aside from just the fact that someone still needs to implement it ;-)

@BraveEvidence
Copy link

This will help https://www.youtube.com/watch?v=IMQdSTlTXjA

@0xharkirat
Copy link

Hey @ryanheise @martinc2907 , Can you guys please give me a short example of pausing or stopping the player after current song in playlist is finished.

@Chaphasilor

This comment was marked as off-topic.

@ryanheise

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 backlog enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants