ryanheise / just_audio

Audio Player
1.06k stars 678 forks source link

Reopening AudioPlayer after disposing issues #705

Closed othenos closed 2 years ago

othenos commented 2 years ago

Which API doesn't behave as documented, and how does it misbehave? Name here the specific methods or fields that are not behaving as documented, and explain clearly what is happening.

Minimal reproduction project Provide a link here using one of two options:

  1. Fork this repository and modify the example to reproduce the bug, then provide a link here.
  2. If the unmodified official example already reproduces the bug, just write "The example".

To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:

just_audio version 0.9.20

open widget in modal BottomSheet initState creates AudioPlay instance and initializes the player User plays audio selection While audio is streaming, user closes the modal BottomSheet in dispose, audioPlayer is paused, seek to Duration 0, and the disposed. User then opens the modal bottom sheet again This time when user click play the error message (below) appears in the console (audio plays as expected) Any further actions by the user, pause/play produces the same error message.

Error messages

If applicable, copy & paste error message here, within the triple quotes to preserve formatting.
"""[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Bad state: Cannot add new events after calling close
#0      _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)
#1      Subject._add (package:rxdart/src/subjects/subject.dart:142:17)
#2      Subject.add (package:rxdart/src/subjects/subject.dart:136:5)
#3      AudioPlayer._setPlatformActive.subscribeToEvents.<anonymous closure> (package:just_audio/just_audio.dart:1195:27)
#4      _rootRunUnary (dart:async/zone.dart:1434:47)
#5      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)"""

Expected behavior No error after reopening the bottom sheet and pressing play

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Flutter SDK version """Flutter 2.13.0-0.0.pre.409 • channel master • https://github.com/flutter/flutter.git Framework • revision e382f1376a (8 days ago) • 2022-04-06 14:46:11 -0400 Engine • revision 07be32c304 Tools • Dart 2.17.0 (build 2.17.0-266.0.dev) • DevTools 2.12.1"""

insert output of "flutter doctor" here """[✓] Flutter (Channel master, 2.13.0-0.0.pre.409, on macOS 12.3.1 21E258 darwin-arm, locale en-US) • Flutter version 2.13.0-0.0.pre.409 at /Users/mrobinson/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision e382f1376a (8 days ago), 2022-04-06 14:46:11 -0400 • Engine revision 07be32c304 • Dart version 2.17.0 (build 2.17.0-266.0.dev) • DevTools version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1) • Android SDK at /Users/mrobinson/Library/Android/sdk • Platform android-32, build-tools 32.0.0-rc1 • ANDROID_HOME = /Users/mrobinson/Library/Android/sdk • ANDROID_SDK_ROOT = /Users/mrobinson/Library/Android/sdk • Java binary at: /Users/mrobinson/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8309675/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1) • Android Studio at /Users/mrobinson/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8309675/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] Android Studio (version 2021.1) • Android Studio at /Users/mrobinson/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.8193401/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1) • IntelliJ at /Users/mrobinson/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-2/221.5080.210/IntelliJ IDEA.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.3) • IntelliJ at /Users/mrobinson/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-2/213.7172.25/IntelliJ IDEA.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin version 213.5449.25

[✓] Connected device (4 available) • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator) • iPhone 13 Pro Max (mobile) • D57BCEAC-1D42-48F7-81A2-18647F2607D8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.88

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!"""

Additional context Add any other context about the problem here.

othenos commented 2 years ago

I just noticed an updated to just_audio_background from beta4 to beta5. After installing and re-running the application the problem went away. So I am closing this issue as fixed.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.