Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android lock screen/notification ignores capabilities #1775

Closed
sam1463 opened this issue Oct 5, 2022 · 16 comments
Closed

android lock screen/notification ignores capabilities #1775

sam1463 opened this issue Oct 5, 2022 · 16 comments

Comments

@sam1463
Copy link

sam1463 commented Oct 5, 2022

Describe the Bug
Not sure if this is intended or not, but it is counterintuitive.
If I specify notificationCapabilities and compactCapabilities that do not include SkipToNext or SkipToPrevious, I would not expect the buttons for those functionalities to appear on the notification controls for android. I do not want to enable those controls, but it seems there is no option except to have those buttons appear, and simply not function if I don't provide those capabilities. Additionally, I am providing RemoteJumpForward and RemoteJumpBackward, and the controls for that do not show up on the android notification.

Steps To Reproduce
Instantiate track player like in the docs, and provide the following capabilities. The notification controls show the skip to previous track button regardless, and show the skip to next track as long as you're not on the last track in the list of tracks. The "jump" controls are not shown.
I think the notification should check capabilities for displaying these, rather than doing it solely based on the length of tracks and current track index.

Code To Reproduce

const AUDIO_CAPABILITIES = [
  Capability.Play,
  Capability.Pause,
  Capability.JumpForward,
  Capability.JumpBackward,
  Capability.SeekTo,
];

...

        await TrackPlayer.updateOptions({
          android: {
            appKilledPlaybackBehavior:
              AppKilledPlaybackBehavior.ContinuePlayback,
          },
          capabilities: AUDIO_CAPABILITIES,
          notificationCapabilities: AUDIO_CAPABILITIES,
          compactCapabilities: AUDIO_CAPABILITIES,
        });

        await TrackPlayer.add(tracks);

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

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

System:
    OS: macOS 12.2.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 31.07 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v14.15.5/bin/yarn
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.3/bin/npm
    Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 30, 31, 32, 33
      Build Tools: 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0
      System Images: android-30 | ARM 64 v8a, android-30 | Intel x86 Atom_64, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom_64, android-30 | Google Play ARM 64 v8a, android-31 | ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-32 | Google Play ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-Tiramisu | Google APIs ARM 64 v8a, android-Tiramisu | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8309675
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.14.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.0.0 => 18.0.0 
    react-native: 0.69.5 => 0.69.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
sa

Paste the exact react-native-track-player version you are using
3.2.0
Real device? Or simulator? real android device - pixel 4 on api 33
What OS are you running? android 13 / api 33

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?

@sam1463 sam1463 added the Bug label Oct 5, 2022
@sam1463 sam1463 changed the title android lock screen/notification shows controls, ignoring capabilities android lock screen/notification ignores capabilities Oct 5, 2022
@jspizziri
Copy link
Collaborator

Please read this issue

#1702 (comment)

@sam1463
Copy link
Author

sam1463 commented Oct 6, 2022

Thanks @jspizziri ! I did try looking for related issues before opening this one but clearly missed that one 🤦

@sam1463
Copy link
Author

sam1463 commented Oct 6, 2022

@jspizziri I'm still seeing the behavior described in this ticket, even on the nightly build (3.2.0-e742959cc1d697d69daeade39830155bce2ccde7).

Is the expected behavior of this library / KotlinAudio to show certain controls regardless of whether the relevant capabilities are passed? I had expected that omitting capabilities would hide the controls (rather than having controls that don't do anything)

My code:

await TrackPlayer.updateOptions({
          android: {
            appKilledPlaybackBehavior:
              AppKilledPlaybackBehavior.StopPlaybackAndRemoveNotification,
          },
          capabilities: AUDIO_CAPABILITIES,
          notificationCapabilities: [], // AUDIO_CAPABILITIES,
          compactCapabilities: [], // AUDIO_CAPABILITIES,
        });

@sam1463
Copy link
Author

sam1463 commented Oct 6, 2022

@jspizziri Can we re-open this?

I'm seeing this same issue on the example app in this repo, making only these changes necessary to repro:

diff --git a/example/src/services/SetupService.ts b/example/src/services/SetupService.ts
index ef02e38..774b9b3 100644
--- a/example/src/services/SetupService.ts
+++ b/example/src/services/SetupService.ts
@@ -21,14 +21,15 @@ export const SetupService = async (): Promise<boolean> => {
       capabilities: [
         Capability.Play,
         Capability.Pause,
-        Capability.SkipToNext,
-        Capability.SkipToPrevious,
+        Capability.JumpForward,
+        Capability.JumpBackward,
         Capability.SeekTo,
       ],
       compactCapabilities: [
         Capability.Play,
         Capability.Pause,
-        Capability.SkipToNext,
+        Capability.JumpForward,
+        Capability.JumpBackward,
       ],
       progressUpdateEventInterval: 2,
     });

It should show the rewind icon and forward icon with these changes, instead of the skip track backward/forward icons, right?

Screenshot_20221006-145802

@riku99
Copy link

riku99 commented Nov 8, 2022

@sam1463
Did you solve the problem?
I have the same problem.

@sam1463
Copy link
Author

sam1463 commented Nov 8, 2022

@sam1463 Did you solve the problem? I have the same problem.

@jspizziri can you re-open this issue? It's still occurring on the current version of the library (3.2.0) and is easily reproducible in the example app.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Feb 7, 2023
@martinmidtsund
Copy link
Contributor

Seems like this is still an issue on the example project.

@puckey
Copy link
Collaborator

puckey commented Feb 20, 2023

So it looks like the cause is a behavior change in Android 13: https://developer.android.com/about/versions/13/behavior-changes-13#playback-controls

@puckey
Copy link
Collaborator

puckey commented Feb 22, 2023

I fixed this for the most part in the KotlinAudio library through doublesymmetry/KotlinAudio#64

@puckey puckey removed the Unconfirmed Bugs that have not been confirmed by the core team. label Feb 22, 2023
@jeroenptrs

This comment was marked as resolved.

@jeroenptrs
Copy link

@puckey I'm wondering what the status is here, is there something we can do to help to get this merged in? Testing on android 13, ...

@jeroenptrs
Copy link

Tried 4.0-rc1 and seekto, jumpforward and jumpbackward seem to work, but I'm not seeing RemotePlay and RemotePause events come in. I verified it on the example app as well.

@jspizziri
Copy link
Collaborator

jspizziri commented Mar 15, 2023

Tried 4.0-rc1 and seekto, jumpforward and jumpbackward seem to work, but I'm not seeing RemotePlay and RemotePause events come in. I verified it on the example app as well.

This seems unrelated to this particular issue. Please use discord to ask questions and create distinct issues for new issues.

@puckey
Copy link
Collaborator

puckey commented Mar 16, 2023

Considering this fixed.

@puckey puckey closed this as completed Mar 16, 2023
@Nikualla1
Copy link

@sam1463 Did you solve this?
I am having the same issue on 3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

7 participants