audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

player.stop() not working properly when called from background

Open fakhrii opened this issue 2 years ago • 5 comments

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

fakhrii avatar Oct 24 '22 15:10 fakhrii

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

Gustl22 avatar Nov 23 '22 19:11 Gustl22

@fakhrii Solved?

sabishm avatar Apr 03 '23 08:04 sabishm

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 avatar Apr 04 '23 00:04 fakhrii

@fakhrii @fakhrii which platform?

Gustl22 avatar Apr 09 '23 21:04 Gustl22

@fakhrii @fakhrii which platform?

Problem occurred on both android and ios

fakhrii avatar Apr 09 '23 21:04 fakhrii