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

Initial Support for Android Auto #76

Closed
wants to merge 5 commits into from

Conversation

hkfuertes
Copy link

Following #71 I open a PR to track my work.

Comment on lines +55 to +68
override fun onCreate() {
super.onCreate()

mediaSession = MediaLibrarySession.Builder(
this,
exoPlayer,
MediaLibrarySessionCallback()
).build()
}

override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession? {
return mediaSession
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found here (https://developer.android.com/reference/androidx/media3/session/MediaLibraryService.MediaLibrarySession) that MediaLibrarySession is an extension of MediaSession and I see that it has an extra attribute MediaLibrarySession.Callback that I imagine (as documentation is pretty much non-existent for Media3 Android Auto) will allow us to control the music from Android Auto.

Obviously it complains:

Caused by: java.lang.IllegalStateException: Session ID must be unique. ID=
                                                                                                    	at androidx.media3.session.MediaSession.<init>(MediaSession.java:732)
                                                                                                    	at androidx.media3.session.MediaLibraryService$MediaLibrarySession.<init>(MediaLibraryService.java:725)
                                                                                                    	at androidx.media3.session.MediaLibraryService$MediaLibrarySession$Builder.build(MediaLibraryService.java:703)
                                                                                                    	at org.grakovne.lissen.AutoBookPlayerService.onCreate(AutoBookPlayerService.kt:62)

The only example I have found is this:
androidx/media#204 (comment)

@hkfuertes
Copy link
Author

@GrakovNe any thoughts on how can I continue?

@GrakovNe
Copy link
Owner

let me implement this feature after NY/Christmas holidays :-)

I hope i'll find a solution!

Thank you for the attempt!

@GrakovNe GrakovNe closed this Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants