doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.23k stars 997 forks source link

[4.0.0-rc06] TrackPlayer.reset() doesn't clear Now Playing metadata in control center on Android. #2074

Closed DennisdeWitNL closed 11 months ago

DennisdeWitNL commented 1 year ago

Describe the Bug I am using TrackPlayer.reset(); to clear the queue and to clear the Now Playing metadata in the Control Center on Android. While it works fine on RC05, it seems to be broken on RC06. Also, it seems

       android: {
         appKilledPlaybackBehavior: AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification,
        },

Doesn't clear the NowPlaying metadata either when closing the app, while the RC05 version works perfectly fine that way. It probably is related to each other.

Steps To Reproduce

Code To Reproduce In my case I just made a button to reset the queue:

  const RemoveStreamByButton = async () => {
      await TrackPlayer.reset();

  };

Replicable on Example App? Can you replicate this bug in the React Native Track Player Example App?

Yes, and it works fine with RC05, just a problem with RC06.

Environment Info: Paste the results of npx react-native info

System:
  OS: macOS 14.0
  CPU: (10) arm64 Apple M1 Max
  Memory: 6.00 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 19.6.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.4.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.05.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.11.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9514443
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.18
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.2
    wanted: 0.72.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Paste the exact react-native-track-player version you are using

    "react-native-track-player": "^4.0.0-rc06",

Real device? Or simulator? What OS are you running?

We have tested this against an LG Velvet (Android 12), Samsung S22 Plus (Android 13), Samsung S10 Plus (Android 12) and the emulator (Android 12). All with the same results.

How I can Help What can you do to help resolve this? Have you investigated the underlying JS or Swift/Android code causing this bug? Can you create a Pull Request with a fix?

No, I don't know Swift/Kotlin, I am a JS developer, sorry!

l3k commented 1 year ago

Hello @DennisdeWitNL, check this code

const RemoveStreamByButton = async () => {
  await TrackPlayer.stop();
  await TrackPlayer.reset();
};
DennisdeWitNL commented 1 year ago

Hello @DennisdeWitNL, check this code

const RemoveStreamByButton = async () => {
  await TrackPlayer.stop();
  await TrackPlayer.reset();
};

Yep, that seems to make the notification disappear again, indeed. I will roll out an internal beta and check if my testers also have no problems anymore. :)

dcvz commented 1 year ago

This should now be fixed with rc07 which was just released

NagashreeNMeda commented 11 months ago

This is still happening on latest version rc07 for iOS devices. Any suggestions to fix this?

dcvz commented 11 months ago

This is still happening on latest version rc07 for iOS devices. Any suggestions to fix this?

Should not be. @DennisdeWitNL could you also verify whether you continue to see this?

dcvz commented 11 months ago

Verified via the example app with the latest RC

DennisdeWitNL commented 11 months ago

This is still happening on latest version rc07 for iOS devices. Any suggestions to fix this?

Should not be. @DennisdeWitNL could you also verify whether you continue to see this?

As you might know, today was ‘shiny new toy’-day for Apple users. I am setting up my iPhone now and will tell you the results later today or tomorrow. :)

DennisdeWitNL commented 11 months ago

@dcvz With RC09, on iOS 17.0.2, it clears the Now Playing correctly when performing a TrackPlayer.reset().