Duration reports `null` in `SequenceState.currentSource.duration`
Which API doesn't behave as documented, and how does it misbehave?
The stream from player.sequenceStateStream sometimes returns incorrect information.
Listening to a stream of player.sequenceStateStream.currentSource.duration will return null when using preload=true on the setAudioSource.
Minimal reproduction project Provide a link here using one of two options: https://github.com/dickermoshe/just_audio/tree/minor/just_audio/example
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Press "setAudioSource and play"
The duration which is being streamed from
SequenceState.currentSource.durationwill benull - Press "setAudioSource, load and play" The duration will be streamed correctly
Error messages There are no clear errors, here is the output after running the app and pressing "setAudioSource and play"
D/BufferPoolAccessor2.0( 5639): bufferpool2 0xb400006f6487f5c8 : 0(0 size) total buffers - 0(0 size) used buffers - 51/61 (recycle/alloc) - 5/110 (fetch/transfer)
D/BufferPoolAccessor2.0( 5639): evictor expired: 1, evicted: 1
I/ViewRootImpl@4224cc3[MainActivity]( 5639): ViewPostIme pointer 0
I/ViewRootImpl@4224cc3[MainActivity]( 5639): ViewPostIme pointer 1
I/ExoPlayerImpl( 5639): Init 5e1dee3 [ExoPlayerLib/2.18.7] [beyond0q, SM-G970U, samsung, 31]
I/DMCodecAdapterFactory( 5639): Creating an asynchronous MediaCodec adapter for track type audio
I/CCodec ( 5639): state->set(ALLOCATING)
I/CCodec ( 5639): allocate(c2.sec.mp3.decoder)
I/CCodec ( 5639): setting up 'default' as default (vendor) store
I/CCodec ( 5639): Created component [c2.sec.mp3.decoder]
I/CCodec ( 5639): state->set(ALLOCATED)
D/CCodecConfig( 5639): read media type: audio/mpeg
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater( 5639): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig( 5639): query failed after returning 7 values (BAD_INDEX)
D/CCodecConfig( 5639): c2 config diff is Dict {
D/CCodecConfig( 5639): c2::u32 coded.bitrate.value = 64000
D/CCodecConfig( 5639): c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig( 5639): c2::u32 input.delay.value = 0
D/CCodecConfig( 5639): string input.media-type.value = "audio/mpeg"
D/CCodecConfig( 5639): string output.media-type.value = "audio/raw"
D/CCodecConfig( 5639): c2::u32 raw.channel-count.value = 2
D/CCodecConfig( 5639): c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig( 5639): }
I/MediaCodec( 5639): MediaCodec will operate in async mode
D/CCodec ( 5639): [c2.sec.mp3.decoder] buffers are bound to CCodec for this session
I/CCodec ( 5639): appPid(5639) width(0) height(0)
D/CCodecConfig( 5639): no c2 equivalents for log-session-id
D/CCodecConfig( 5639): no c2 equivalents for flags
D/CCodecConfig( 5639): config failed => CORRUPTED
D/CCodecConfig( 5639): c2 config diff is c2::u32 raw.channel-count.value = 1
W/Codec2Client( 5639): query -- param skipped: index = 1107298332.
D/CCodec ( 5639): client requested max input size 4096, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec ( 5639): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec ( 5639): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec ( 5639): int32_t bitrate = 64000
D/CCodec ( 5639): int32_t channel-count = 1
D/CCodec ( 5639): int32_t max-input-size = 8192
D/CCodec ( 5639): string mime = "audio/mpeg"
D/CCodec ( 5639): int32_t sample-rate = 44100
D/CCodec ( 5639): int64_t durationUs = 0
D/CCodec ( 5639): }
D/CCodec ( 5639): setup formats output: AMessage(what = 0x00000000) = {
D/CCodec ( 5639): int32_t channel-count = 1
D/CCodec ( 5639): string mime = "audio/raw"
D/CCodec ( 5639): int32_t sample-rate = 44100
D/CCodec ( 5639): }
I/CCodecConfig( 5639): query failed after returning 7 values (BAD_INDEX)
D/MediaCodec( 5639): keep callback message for reclaim
I/CCodec ( 5639): state->set(STARTING)
W/Codec2Client( 5639): query -- param skipped: index = 1342179345.
W/Codec2Client( 5639): query -- param skipped: index = 2415921170.
D/CCodecBufferChannel( 5639): [c2.sec.mp3.decoder#51] Created input block pool with allocatorID 16 => poolID 46 - OK (0)
D/BufferPoolAccessor2.0( 5639): bufferpool2 0xb400006f6484b548 : 0(0 size) total buffers - 0(0 size) used buffers - 64/69 (recycle/alloc) - 5/126 (fetch/transfer)
D/BufferPoolAccessor2.0( 5639): Destruction - bufferpool2 0xb400006f6484b548 cached: 0/0M, 0/0% in use; allocs: 69, 93% recycled; transfers: 126, 96% unfetched
D/BufferPoolAccessor2.0( 5639): bufferpool2 0xb400006f648adc18 : 0(0 size) total buffers - 0(0 size) used buffers - 8/13 (recycle/alloc) - 4/8 (fetch/transfer)
D/BufferPoolAccessor2.0( 5639): Destruction - bufferpool2 0xb400006f648adc18 cached: 0/0M, 0/0% in use; allocs: 13, 62% recycled; transfers: 8, 50% unfetched
D/BufferPoolAccessor2.0( 5639): Destruction - bufferpool2 0xb400006f6487f5c8 cached: 0/0M, 0/0% in use; allocs: 61, 84% recycled; transfers: 110, 95% unfetched
I/CCodecBufferChannel( 5639): [c2.sec.mp3.decoder#51] Created output block pool with allocatorID 16 => poolID 46 - OK
D/CCodecBufferChannel( 5639): [c2.sec.mp3.decoder#51] Configured output block pool ids 46 => OK
I/CCodec ( 5639): state->set(RUNNING)
I/CCodecBufferChannel( 5639): [c2.sec.mp3.decoder#51] 4 initial input buffers available
D/AudioTrack( 5639): setVolume(1.000000, 1.000000) pid : 5639
D/AudioTrack( 5639): getTimestamp_l(58): device stall time corrected using current time 114952871231981
D/AudioTrack( 5639): stop(58): called with 163008 frames delivered
D/BufferPoolAccessor2.0( 5639): evictor expired: 3, evicted: 0
D/BufferPoolAccessor2.0( 5639): bufferpool2 0xb400006f6489e4a8 : 5(40960 size) total buffers - 1(8192 size) used buffers - 140/145 (recycle/alloc) - 5/284 (fetch/transfer)
D/BufferPoolAccessor2.0( 5639): evictor expired: 1, evicted: 1
Expected behavior The correct duration to be reported
Screenshots
https://github.com/ryanheise/just_audio/assets/75931499/59861738-dc6b-4630-bced-3191acc5e03c
Smartphone (please complete the following information):
- Samsung Galaxy S10e
- Android 12
Flutter SDK version
[√] Flutter (Channel stable, 3.13.2, on Microsoft Windows [Version 10.0.22621.2283], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.7.3)
[√] Android Studio (version 2021.3)
[√] VS Code, 64-bit edition (version 1.82.3)
[√] VS Code (version 1.83.0-insider)
[√] Connected device (4 available)
[√] Network resources
• No issues found!
Additional context N/A
Thanks for the report, can you clarify the reproduction steps by giving user steps, not code?
- User listens to a song until it completes.
- User listens to the same song again.
The result is a stream of the current duration that doesn't work. I've included a video.
If you run load and play, it does work. However typically, a button on a song will use setAudioSource and then play.
In a personal app I'm working on I've temporary avoided this by using tags to check whether the song being taped is already loaded and then, using load instead on setAudioSource.
Thanks for the quick reply. Let me know if there is anything else you need to debug this. I'm really enjoying this package. Thanks again.
I don't understand your user steps. To be clear, I am the user. When I start your app you need to tell me (the user) what to click on. When submitting the bug report, I wrote the following instructions with an example of what I meant for clarity:
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
So the point is what does the user of your app need to click on and in what order?
Your bug report was confusing since you didn't give me user steps, you gave me code and method names which is what I didn't want when I said "user steps, not code":
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
setAudioSourceis called on anAudioSource.playis called,- The playback completes.
setAudioSourceis called on the same AudioSource content (the name file/url)playis called.
Now you've tried to rewrite the steps but now you wrote this:
- User listens to a song until it completes.
- User listens to the same song again.
Again, I don't know what I'm supposed to click on. I mean, your app has more than one button, doesn't it? Please give me "user steps, not code" so that I can know exactly what I need to do. You can edit your original bug report by editing this section to give the correct user steps.
Edited. I didn't realize the user steps referred to the example code, sorry.
Here is the part I edited above
Steps to reproduce the behavior:
- Open the app.
- Click the "setAudioSource and play" button.
- Wait for the audio to finish playing
- Click the "setAudioSource and play" button again.
- The duration is then reported as
nullin the bottom text that is reporting theplayer.sequenceStateStream.currentSourcestream. - (Optional) If you were to press "load and play" then it would work.
Thanks, that is what I was after. Also note:
You can edit your original bug report
By the way, can you also provide feedback on what was unclear about the instructions so that I can improve them? Remember, here were the original instructions in the bug report:
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
I have edited it. Maybe "Steps to reproduce the behavior in the project you provided" It could just be that I'm an idiot, but that would be clearer.
@ryanheise I've updated the original bug report. Sorry about the miscommunications.