Gapless playback is not working
See original GitHub issueIssue description
When trying to play a gapless playback between two MP3 files, a noticeable gap is detected between them.
The issue is also reproduced when using Exoplayer demo app with the test.mp3
file already added in assets.
I added the following snippet to PlayerActivity
in Exoplayer demo app L299 for test purpose => the issue is reproduced : a gap between the two media sources is heard.
val concatenatingMediaSource = ConcatenatingMediaSource()
val defaultMediaSourceFactory = DefaultMediaSourceFactory(context)
concatenatingMediaSource.addMediaSource(defaultMediaSourceFactory.createMediaSource(
MediaItem.fromUri("asset:///test.mp3")))
concatenatingMediaSource.addMediaSource(defaultMediaSourceFactory.createMediaSource(
MediaItem.fromUri("asset:///test.mp3")))
player.setMediaSource(concatenatingMediaSource)
player.prepare()
Please notice that the delay/padding information is well detected by Exoplayer for the test.mp3
in demo app assets.
- ExoPlayer version number : 2.13.0
- Android version : Android 7 & Android 10
- Android device: Samsung galaxy s7 edge & Samsung galaxy s10
Please let me know if you need more details. Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (16 by maintainers)
Top Results From Across the Web
Solved: Gapless playback not working. - The Spotify Community
When listening to a gapless album on Premium there is a jump between tracks and also the volume auto adjusts. Any way to...
Read more >Is gapless playback not working on Spotify? : r/Muse - Reddit
I'm listening to Drones right now and the transition from Drill-Psycho and JFK-Defector has a gap and it does not sound very good....
Read more >Gapless Playback Issue - Apple Community
Hi, I have recently noticed an issue where pauses have suddenly appeared on an album that should have no gaps between tracks.
Read more >Gapless Playback problems - BitPerfect
The result is that albums whose tracks do not all have the same data in their "Artist" fields may exhibit problems with Gapless...
Read more >Spotify Plugin - GAPLESS playback not working
My issue is that I cannot get the GAPLESS playback to work. There's always a brief pause between tracks, specially noticed and annoying...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking into the emulator codec config, it is clear that the
c2
decoders are alias toOMX
.The config is the same for all Emulated Pixel 3 XL API 29 & 30 and real Pixel 3 XL API 29 and 30:
Nevertheless on API 29 on the emulator, when querying
MediaCodecInfo
the canonical name ofOMX.google.mp3.decode
is returned notc2.android.mp3.decoder
as expected. As a result it is not recognized as an aliased codec.The weird issue is that this only affects an emulated Pixel 3 XL API 29. Emulating a Pixel 3 XL at API 30 doesn’t show the bug, all codecs are correctly listed as OMX (aliased) and C2. A real Pixel 3 XL flashed at the last public release of API 29 also correctly exposes the codecs twice (alias and not aliased). I can’t explain the behaviour difference.
So whatever is causing aliased codecs to only show as their aliased name seems to only affect some devices on API 29 (Android 10).
As a result, if we find a way to differentiate the OMX and C2 codec is seems it will have to be by analysing their decoding behaviour rather than their metadata.
Alternatively, we could consider all API 29
OMX.google.mp3.decode
decoders to be alias of C2 as it was the default config on Android 10. Nevertheless, such change would be nearly impossible to test and I’m afraid of regressing any devices that would really use OMX decoders on Android 10.I found what is happening but I have no root caused it yet.
Normally (for example on Pixel) during a track transition here is what happens:
The issue I’m observing in the emulator is at step 5. The renderer assumes that if the last buffer of the track queued for decoding has a presentation time of τ, the last buffer decoded of the codec will have a presentation time of τ. This is not the case on the emulator. An additional decoded buffer with a presentation time τ’’ is outputted by the codec even though no encoded buffer with a presentation time τ’’ was ever pushed. Note that presentation time τ’’ == τ’. I don’t think it is significant tough.
Here is what happens on the emulator:
Following reproduction step from https://github.com/google/ExoPlayer/issues/8594#issuecomment-779985786. The consistent presentation times observed are:
I don’t know why the decoder (OMX.google.mp3.decoder) outputs one more buffer than was queued. We might want to rely on the EOS flag on the buffer rather than the presentation time.
Regardless, we should avoid the constant double
onQueueEndOfStream
call on the processors on each track transition in handle buffer. One due toreconfigurationPending
(10) and the second one due to thestartMediaTimeUsNeedsSync
(11) due tohandleDiscontinuity
called on track transition (5).