ryanheise / just_audio

Audio Player
1.03k stars 652 forks source link

Unable to play song from background notification in android 14 #1236

Closed Vishnu798 closed 4 months ago

Vishnu798 commented 4 months ago

Which API doesn't behave as documented, and how does it misbehave? When i turn off my phone screen the audio is playing perfectly fine. When i double tap on screen, notification tray appears from where I can play and pause, So when i pause mu audio from there it got pause fine, But when i play from there It does not plays from there. I find the same behavior as my app in your example as well.

Minimal reproduction project Provide a link here using one of two options: 1) AndroidManifest.xml :-

2) app main.dart :- void main() async {

WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
 options: DefaultFirebaseOptions.currentPlatform,);
 MobileAds.instance.initialize();
  FirebaseMessaging.onBackgroundMessage(helper.firebaseMessagingBackgroundHandler);

// Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to Crashlytics
if (!kIsWeb) {

await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);} // FlutterError.onError = (errorDetails) { // FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails); // }; // PlatformDispatcher.instance.onError = (error, stack) { // FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); // return true; // }; // FirebaseCrashlytics.instance.crash(); await JustAudioBackground.init( androidNotificationChannelId: 'com.ryanheise.bg_demo.channel.audio', androidNotificationChannelName: 'Audio playback', // androidNotificationOngoing: false, // preloadArtwork: true, androidNotificationClickStartsActivity: true, androidStopForegroundOnPause: false ); await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions( alert: true, badge: true, sound: true, ); runApp( MyApp());

}

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

  1. Play any audio in your app.
  2. Turn off your screen.
  3. Double tap to wake up the screen, background notification is visible.
  4. Click on pause to stop the audio then tap on play to play it again.
  5. Play button does not works.

Error messages

D/AudioManagerExtImpl(17799): getStreamVolume packageName=com.example.music_player_version3, index=10, streamType=3
D/MediaBrowserCompat(17799): Connecting to a MediaBrowserService.

Expected behavior on Play the audio should continue.

Screenshots 1000051099 Unable to play/ continue the song on play tap as show in the above image which shows notification.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Flutter SDK version

[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.22631.3447], locale en-IN)
    • Flutter version 3.19.5 on channel stable at C:\Users\vishn\Downloads\flutter_windows_3.19.5-stable\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (5 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\vishn\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.33)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.34407.143
    • Windows 10 SDK version 10.0.19041.0
    X The current Visual Studio installation is incomplete.
      Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.

[√] Android Studio (version 2023.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.89.0)
    • VS Code at C:\Users\vishn\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.88.0

[√] Connected device (4 available)
    • CPH2495 (mobile)  • G6WOMJMVIR4HGEQ4 • android-arm64  • Android 14 (API 34)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [Version 10.0.22631.3447]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 124.0.6367.119
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 124.0.2478.67

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Additional context Add any other context about the problem here.

ryanheise commented 4 months ago

Provide a link here using one of two options:

What you did was not one of the two options given in the instructions.

I'm closing this as an invalid bug report. This your second invalid bug report, please don't make it a 3rd.

github-actions[bot] commented 4 months 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.