react-native-track-player
react-native-track-player copied to clipboard
[Feature Request] Support for always-on-display
Describe the Bug
After upgrading from stable to v2.2.0-rc3
, my app no longer shows track/artist name on the ambient display on an Android 12 device. The title and artist show up fine in the notification and on the lock screen when the notification is displayed, it's just when the phone is fully locked and the ambient display is on that I see the "No title" where that info used to be.
Steps To Reproduce Play a track with a valid track name/artist name on an Android 12 device, lock it, and observe the ambient display
I don't actually know how to emulate the ambient display feature but I can try to repro there too if someone else can let me know if it's possible.
Code To Reproduce https://github.com/austinried/subtracks/tree/react-native-track-player-next
Environment Info:
Paste the results of npx react-native info
System:
OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Memory: 158.45 MB / 15.39 GB
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.19.1 - /tmp/yarn--1650003558066-0.14211410378890887/node
Yarn: 1.22.18 - /tmp/yarn--1650003558066-0.14211410378890887/yarn
npm: 6.14.16 - ~/.nvm/versions/node/v14.19.1/bin/npm
Watchman: 4.9.0 - /usr/bin/watchman
SDKs:
Android SDK:
Android NDK: 22.1.7171670
IDEs:
Android Studio: Not Found
Languages:
Java: 11.0.12 - /home/austin/.sdkman/candidates/java/current/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.4 => 0.67.4
npmGlobalPackages:
*react-native*: Not Found
@mpivchev looks like a android rewrite bug.
We try to extract the title from the file metadata:
override fun getCurrentContentTitle(player: Player): CharSequence {
return metadataProvider.getTitle() ?: player.mediaMetadata.displayTitle ?: ""
}
If nothing is found, the default will be an empty string, so it looks like the title provided in the metadata of your file is actually "No title". Please check your file metadata and if you still believe this is a bug please update this issue.
I believe the metadata should be alright, as the title and subtitle display in the notification, it's only in the ambient display (when the device is locked) that it says "No title" for all tracks, and I use the same set of tracks for testing between this RC3 version and my standard 2.1.3 branch where this works. I'll see if I can duplicate this in the example app with a track I can link you to as well, though.
Actually this happens with the tracks that are already in the example app apparently, so just fire that up on an Android device with ambient display and you can repro this. Here's mine:
Ah I see. We currently don't handle ambient display at all, so this would have to be implemented.
@mpivchev is this something it would be good to have help on?
@austinried is this something you'd be interested (with guidance) in taking a crack at?
@jspizziri yeah, if anyone is willing to contribute that would be great :)
This does not look like a bug, but a missing feature, so changed accordingly.
Thing is though this works in 2.1.3, here's the same song from the example app:
So this is more like a feature reinstatement. Either way though, I have been trying to figure out from what I can what's being done in 2.1.3 that isn't in 2.2.0 in this case. I haven't made much progress yet, and I haven't gotten the setup working yet where I can make changes to KotlinAudio locally for testing, but I'm trying to get that going.
One thing I could really use that I'm still missing is actually documentation on what controls the media title/subtitle in the ambient display screen. I'm imagining it's not something that's being controlled directly through an API but probably something to do with how the media session is being set up and this metadata isn't being passed where it used to be.
@austinried reach out to me on discord if you want help getting a android test env set up.
@mpivchev can you point @austinried in the right direction here?
Actually I think I just found something close to documentation, I was relying too heavily on calling this "ambient display" in my searching and just found this SO post about media on the "always on display" https://stackoverflow.com/questions/59144878/media-session-has-no-title-on-aod-always-on-display
We are using KotlinAudio and ExoPlayer as our audio player libraries. The file that is responsible for the notification content is this one.
From the post you sent it looks like it can be used to set up the AOD content as well.
Same problem here!
@mpivchev Thanks for the tip, I've started poking around there and the NotificationManager and I think I've found where that metadata should be passed for the AOD to work, which is into the media session/connector's metadata methods. I'm gonna do a bit more testing here and then put up a PR for review.
I've got the PR up for the fix on this over in KotlinAudio here: https://github.com/doublesymmetry/KotlinAudio/pull/23
Before this is completely "Done" a new version of KotlinAudio needs to be released and then this project will need to be updated to use the new version.
Will do this soon! There's some other changes we're trying to also get in the next KotlinAudio release
Thanks, just trying to leave a trail of breadcrumbs for folks.
@austinried how you solved problem? can i make patch or something else
@JavoxirNazarov You need to wait for the upstream patch to be released and then updated here.
@jspizziri sorry, When will there be a new release?
@JavoxirNazarov I don't know unfortunately.
got it @jspizziri. but anyway the library is super! thank you guys for all your work!
I just retested this on an Android device and it seems as though the issue has been fixed at some point.
@jspizziri Which version are you using? I haven't found a way to solve it. Thanks!