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

Request for Adding Delay Between Tracks in Flutter Just_Audio Playlist #1193

Open
burhanaksendir opened this issue Feb 21, 2024 · 8 comments
Assignees
Labels
1 backlog enhancement New feature or request

Comments

@burhanaksendir
Copy link

Is your feature request related to a problem? Please describe.
I am experiencing issues with sound transitions when playing a playlist with podcast content. Specifically, there is no gap at the beginning of each track, causing audio problems when transitioning to the next track.

Describe the solution you'd like
I would like to be able to add a slight delay at the beginning of each track in a playlist when using the flutter just_audio package. This delay would help prevent audio issues during transitions between tracks.

Describe alternatives you've considered
I have considered manually editing the audio files to include a brief silence at the beginning of each track. However, I believe having a built-in feature within the flutter just_audio package to handle this delay would be a more efficient and convenient solution.

Additional context
I have a playlist containing podcast content, and the absence of a gap at the beginning of each track leads to audio problems when transitioning between tracks. To address this issue, I am seeking a way to introduce a delay during the transition between tracks to ensure smoother audio playback.

@ryanheise
Copy link
Owner

Thank you for the suggestion, although I feel this feature would be a little to niche, and unnecessary since there are alternative approaches.

Describe alternatives you've considered
I have considered manually editing the audio files to include a brief silence at the beginning of each track. However, [...]

You could also create an audio asset containing a short amount of silence of the desired length, then use a concatenating audio source to concatenate it before each item. Those silent assets will be indexed in the player's sequence, so you probably won't want to use the player's sequence directly as the model for your UI. You would need to then manage it yourself which is a downside, but it is at least possible.

This is similar to other requests to support crossfade transitions and such. These are all possible to achieve without building it directly into just_audio, but just require more effort on the part of the app developer using the library.

@burhanaksendir
Copy link
Author

You could also create an audio asset containing a short amount of silence of the desired length, then use a concatenating audio source to concatenate it before each item....

Thank you for your response and providing alternative approaches. Would it be more practical to add a delay when transitioning to the next track in the playlist? Is it possible for you to provide a small code example demonstrating how to achieve this?

@ryanheise
Copy link
Owner

Can you be more precise? If by delay, you mean Future.delay, then no because that could potentially relinquish control to the os when in background mode on iOS.

@burhanaksendir
Copy link
Author

Can you be more precise? If by delay, you mean Future.delay, then no because that could potentially relinquish control to the os when in background mode on iOS.

I appreciate your clarification regarding the potential issues with using Future.delay. To be more precise, yes, I was referring to Future.delay, and it seems that I've encountered challenges in finding a suitable solution for the mentioned issue.

Additionally, I'd like to highlight that the playlist contains hundreds of podcast episodes, and individually managing each one would be time-consuming. Therefore, I'm actively seeking a more efficient and streamlined method for this task.

I'm still exploring options to find a more seamless and efficient way to introduce delays between podcast episodes without compromising the user experience. If you have any further insights or alternative ideas, I'd be grateful for your input.

@ryanheise
Copy link
Owner

I would suggest a silent asset as mentioned above. I can't think of any further comments or insights to add on top of that. A variation of simply inserting the asset into the ConcatenatingAudioSource before each podcast episode would be to dynamically generate an HLS stream representing one episode and insert the silent asset as the first file in that HLS stream, and produce one HLS for each episode. I'm not able to advise you in detail on how to do that, however. You can research the two alternatives and weigh up their respective advantages and disadvantages.

@raminjavi
Copy link

raminjavi commented Jul 23, 2024

Can you be more precise? If by delay, you mean Future.delay, then no because that could potentially relinquish control to the os when in background mode on iOS.

I appreciate your clarification regarding the potential issues with using Future.delay. To be more precise, yes, I was referring to Future.delay, and it seems that I've encountered challenges in finding a suitable solution for the mentioned issue.

Additionally, I'd like to highlight that the playlist contains hundreds of podcast episodes, and individually managing each one would be time-consuming. Therefore, I'm actively seeking a more efficient and streamlined method for this task.

I'm still exploring options to find a more seamless and efficient way to introduce delays between podcast episodes without compromising the user experience. If you have any further insights or alternative ideas, I'd be grateful for your input.

I added SilenceAudioSource between each episode but it sabotaged the indexing, did you find any other solution?

@ryanheise
Copy link
Owner

If you customise it like that, you will need to also manage your own indexing, i.e. keep your own variables to track the current index in your app's own frame of reference and so on. I think I have answered similar questions on stack overflow before.

@Barez001159544
Copy link

player.positionStream.listen((position) async {
if (position == player.duration) {
player.pause();
await Future.delayed(Duration(seconds: delayFactor)); /// 5-second delay for example
player.seekToNext();
player.play();
}
});

  This's the finest answer i could get, although it's not the best solution but should work!

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

4 participants