I'm working on a music player in my React Native app. I have a fully functioning player right now based on ExoPlayer 2.17.1 that is controlled by a MusicService
class extending HeadlessJsTaskService()
.
The issue is that now I need to support Android Auto and to do that you need a MediaBrowserService registered per the docs.
Is there any way for me to extend both of these services? The headless ability is critical to a smooth running player in React Native, so my last resort would be to ditch that all together and implement a standard Android MediaBrowserServiceCompat()
Here are some snippets from my project:
AndroidManifest.xml
<!-- The main service, handles playback, playlists and media buttons -->
<service android:name=".audio.service.MusicService" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
MusicService.kt
class MusicService : HeadlessJsTaskService() {
private lateinit var player: BaseAudioPlayer // My ExoPlayer controller