-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Can ExoPlayer play gapless looping audio? #920
Comments
There is currently no simple way to achieve this with ExoPlayer: for gapless playback it is necessary to read the relevant metadata from source, trim decoded audio samples from the start/end of the presentation based on the metadata and use the same Android AudioTrack instance across the transition from one source to the next. #497 tracks adding support for doing this. (Note that the Android framework's MediaPlayer has a method setNextMediaPlayer which might work for your use case, but this is unrelated to ExoPlayer so we can't provide support here.) |
Thanks for your reply. Just to be clear, this is for looping a single audio file, not sequential playback of multiple audio files. It seems like your reply might be based on a misunderstanding that it was for sequential audio files. Does that make a difference? It's hard to believe it's so difficult to prevent gaps in looped audio on Android. On iOS, it's automatic. Thanks Sent from my iPhone
|
I don't think it makes any difference. In the current design, you can implement looping by seeking back to the start of the stream when playback ends, but this won't be gapless because the player can't prepare what will be played next in advance. Also, we don't currently trim encoder delay/padding samples, which means the output will include silence at the start/end of playback for streams that use this. For now, I'd probably just use MediaPlayer.setNextMediaPlayer. If you need to use ExoPlayer for some reason and you know that the input media does not use encoder delay and padding, it might be possible to implement gapless looping using a custom concatenating SampleSource specialized to your use case, perhaps using #1070 as a starting point. |
Will the gapless support also work for video? Specifically looping the same
|
It's still work in progress, but I think video transitions should be seamless. |
You can use LoopingMediaSource as source instead. MediaSource source = new ExtractorMediaSource(videoUri, ...); Ref: https://google.github.io/ExoPlayer/guide.html#seamlessly-looping-a-video |
We have looping background sounds in our apps, and with the Android mediaplayer, there's a noticeable gap when the audio files loop. We've tried both m4a and ogg audios, but the gap is always there. Does ExoPlayer eliminate these gaps?
The text was updated successfully, but these errors were encountered: