I am trying to develop an application that gets metadata of other applications that are playing music / video. Right now, I am focusing on the Youtube Android app. I figured that MusixMatch does it, so it must be possible. From what I can gather, MusixMatch listens to any changes to the MediaSession of Youtube in order to retrieve metadata. My question is how?
Here's what I have tried done so far.
- Set up a
MediaBrowserService
. - Set up callbacks on the
MediaBrowserService
- Set up the token on the service.
But I'm still generally confused. The service should be able to be triggered in the back, even when the application has died. This means I do not manually bind the service to anything. So... How is it exactly being triggered? I tried adding intent-filters
but the ones I have tried haven't worked.
Here is the list of intent-filters
I have tried... I tried a bunch, because none were working.
<receiver
android:name=".broadcastReceiver.YoutubeReceiver"
android:enabled="@bool/youtubeBroadcast"
android:exported="@bool/youtubeBroadcast"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="com.android.youtube.metachanged"/>
<action android:name="com.google.android.youtube.onPlaybackStateChanged"/>
<action android:name="com.google.android.youtube.onplaybackstatechanged"/>
<action android:name="com.google.android.youtube.player.YouTubePlayer.OnInitializedListener"/>
<action android:name="com.google.android.youtube.player.YouTubePlayer.PlaybackEventListener"/>
<action android:name="com.google.android.youtube.player.YouTubePlayer.OnFullscreenListener"/>
<action android:name="com.google.android.youtube.player.YouTubePlayer.PlayerStateChangeListener"/>
</intent-filter>
</receiver>