ghenry22 / cordova-plugin-music-controls2

A Cordova plugin displaying music controls in notifications (cordova-plugin-music-controls)
MIT License
59 stars 60 forks source link

Is it possible to get the info of a music played by another application? #92

Closed landscht closed 1 year ago

landscht commented 1 year ago

Is it possible to simply get the information of a song played by another application (Spotify or other) into our application. I tried to listen to the events with MediaControls.subscribe but I get nothing when I pause the music or change the music in spotify via the music controls.

ghenry22 commented 1 year ago

I don't think this would be possible, the subscribe method only subscribes the the events from your own instance of media controls.

On android you have a unique appID and notification channel ID so you wouldn't be able to subscribe to the other app. On iOS you can only have 1 app with an active audio session at a time and you need that to have the command center/lock screen controls.

There are functions for inter-app audio that can allow sharing now playing information but whether they are exposed by commercial apps or not I have no idea. Spotify for example does have an API, perhaps you could hit that API to check the most recently played track but it wouldn't be super efficient as you'd just be polling it non-stop.