Example code throws an exception after repopulating playlist
Which API doesn't behave as documented, and how does it misbehave?
Not sure which particular api is misbehaving. But seems like the interaction between player and ConcatenatingAudioSource is the problem.
The example in just_audio_background throws an exception if you empty the playlist, add a song by clicking "+" and then tap on the added song in the playlist.
Minimal reproduction project The example in just_audio_background/example
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Run the example in chrome browser
- Remove all the entries in playlist by swiping right.
- Add a new entry to playlist by clicking "+".
- Tap on the newly added song in the playlist.
Error messages
Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:40169/dart_sdk.js:5041:11)
at Object.nullCheck (http://localhost:40169/dart_sdk.js:5366:30)
at just_audio_web.Html5AudioPlayer.new._seek (http://localhost:40169/packages/just_audio_web/just_audio_web.dart.lib.js:386:16)
at _seek.next (<anonymous>)
at runBody (http://localhost:40169/dart_sdk.js:37422:34)
at Object._async [as async] (http://localhost:40169/dart_sdk.js:37453:7)
at just_audio_web.Html5AudioPlayer.new.[_seek] (http://localhost:40169/packages/just_audio_web/just_audio_web.dart.lib.js:382:20)
at just_audio_web.Html5AudioPlayer.new.seek (http://localhost:40169/packages/just_audio_web/just_audio_web.dart.lib.js:377:26)
at seek.next (<anonymous>)
at runBody (http://localhost:40169/dart_sdk.js:37422:34)
at Object._async [as async] (http://localhost:40169/dart_sdk.js:37453:7)
at just_audio_web.Html5AudioPlayer.new.seek (http://localhost:40169/packages/just_audio_web/just_audio_web.dart.lib.js:375:20)
at just_audio_background._PlayerAudioHandler.new.customPlayerSeek (http://localhost:40169/packages/just_audio_background/just_audio_background.dart.lib.js:478:44)
at customPlayerSeek.next (<anonymous>)
at http://localhost:40169/dart_sdk.js:37403:33
at _RootZone.runUnary (http://localhost:40169/dart_sdk.js:37274:59)
at _FutureListener.thenAwait.handleValue (http://localhost:40169/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:40169/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:40169/dart_sdk.js:33095:17)
at async._AsyncCallbackEntry.new.callback (http://localhost:40169/dart_sdk.js:32824:27)
at Object._microtaskLoop (http://localhost:40169/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:40169/dart_sdk.js:37532:13)
at http://localhost:40169/dart_sdk.js:33303:9
Expected behavior Should not throw an exception.
Screenshots N/A
Desktop (please complete the following information):
- OS: Ubuntu 21.04
- Browser: Chrome 92.0.4515.131 (Official Build) (64-bit)
Smartphone (please complete the following information):
- N/A
Flutter SDK version
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.59.0)
[✓] Connected device (3 available)
• No issues found!
Additional context In general, once the ConcatenatingAudioSource becomes empty, I start seeing several problems after adding new sources to it.
If you need any help (including ways to reproduce, test/verify, etc), let me know.
Hi @pmphfm if you view the Javascript console within your browser, you should see a better stack trace containing dart line numbers rather than js line numbers.
However, I'm able to reproduce it. It happens even without just_audio_background, and it also happens even without clicking the add button. If you swipe to delete the first 3 items in the playlist leaving only the last one, then click play, it will also give the same error.
I'll investigate.
Can you try release 0.9.9?