Skip to content
Snippets Groups Projects
Commit 771072c6 authored by Robert Stone's avatar Robert Stone Committed by Nicolas Pomepuy
Browse files

Set initial playback state and allowed actions

parent 9f54ba2e
No related branches found
Tags 3.3.3 tv3.3.3
1 merge request!1188Add Support for Driving Mode
......@@ -891,10 +891,15 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
mediaButtonIntent.setClass(this, MediaButtonReceiver::class.java)
val mbrIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0)
val mbrName = ComponentName(this, MediaButtonReceiver::class.java)
mediaSession = MediaSessionCompat(this, "VLC", mbrName, mbrIntent)
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS)
mediaSession.setCallback(MediaSessionCallback(this))
val playbackState = PlaybackStateCompat.Builder()
.setActions(enabledActions)
.setState(PlaybackStateCompat.STATE_NONE, 0, 0f)
.build()
mediaSession = MediaSessionCompat(this, "VLC", mbrName, mbrIntent).apply {
setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS or MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS)
setCallback(MediaSessionCallback(this@PlaybackService))
setPlaybackState(playbackState)
}
try {
mediaSession.isActive = true
} catch (e: NullPointerException) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment