audioplayers
audioplayers copied to clipboard
player.stop() not working properly when called from background
I'm playing a notification sound in loop mode and trying to stop when the app is in the background. I'm using the package system_alert_window and inside its callback function i'm calling
player.stop();
but the player won't shut down.
It works perfectly when the app is active but not when it's in the background
flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.5 21G72 darwin-arm, locale en-TN) • Flutter version 2.8.1 at /Users/macbook/Dev/SDKs/flutter_2.8.1 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 77d935af4d (10 months ago), 2021-12-16 08:37:33 -0800 • Engine revision 890a5fca2e • Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/macbook/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • 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.2) • Android Studio at /Applications/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.12+0-b1504.28-7817840)
[✓] VS Code (version 1.72.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available) • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 106.0.5249.119
So you talking about android or ios? Can you provide a reproduction example. Sorry I don't have the time to setup an example or modify the example of audioplayers. Also try to use the issue template.
Also see #1038
@fakhrii Solved?
Yeah i used isolates to achieve what i intend to do. For some reason, whenever i use the player instance initiated in the main thread i get null
@fakhrii @fakhrii which platform?
@fakhrii @fakhrii which platform?
Problem occurred on both android and ios