Commit 265982e3 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Immediately set PlaybackService foreground on Oreo

parent f0626baf
......@@ -516,6 +516,7 @@ class PlaybackService : MediaBrowserServiceCompat() {
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (AndroidUtil.isOOrLater && !VLCApplication.isForeground()) forceForeground()
when (intent?.action) {
Intent.ACTION_MEDIA_BUTTON -> {
if (AndroidDevices.hasTsp || AndroidDevices.hasPlayServices) MediaButtonReceiver.handleIntent(mediaSession, intent)
......@@ -558,6 +559,15 @@ class PlaybackService : MediaBrowserServiceCompat() {
return playlistManager.player.getVout()
}
private fun forceForeground() {
val ctx = this@PlaybackService
val notification = NotificationHelper.createPlaybackNotification(ctx,false,
ctx.resources.getString(R.string.loading), "", "",null,
false, mediaSession.sessionToken, sessionPendingIntent)
startForeground(3, notification)
isForeground = true
}
private fun sendStartSessionIdIntent() {
val sessionId = VLCOptions.getAudiotrackSessionId()
if (sessionId == 0) return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment