Re-enabled media session on service start. Do not condition radio resumption to having a cookie, since those are only valid when authenticated anonymously.

This commit is contained in:
Antoine POPINEAU 2020-07-10 18:46:49 +02:00
parent 080c07eeab
commit fe224b097a
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
2 changed files with 12 additions and 5 deletions

View File

@ -97,6 +97,8 @@ class PlayerService : Service() {
}
}
Otter.get().mediaSession.active = true
mediaControlsManager = MediaControlsManager(this, scope, Otter.get().mediaSession.session)
player = SimpleExoPlayer.Builder(this).build().apply {

View File

@ -35,14 +35,19 @@ class RadioPlayer(val context: Context, val scope: CoroutineScope) {
private val favoritedRepository = FavoritedRepository(context)
init {
Cache.get(context, "radio_type")?.readLine()?.log()
Cache.get(context, "radio_id")?.readLine()?.log()
Cache.get(context, "radio_session")?.readLine()?.log()
Cache.get(context, "radio_cookie")?.readLine()?.log()
Cache.get(context, "radio_type")?.readLine()?.let { radio_type ->
Cache.get(context, "radio_id")?.readLine()?.toInt()?.let { radio_id ->
Cache.get(context, "radio_session")?.readLine()?.toInt()?.let { radio_session ->
Cache.get(context, "radio_cookie")?.readLine()?.let { radio_cookie ->
currentRadio = Radio(radio_id, radio_type, "", "")
session = radio_session
cookie = radio_cookie
}
val cachedCookie = Cache.get(context, "radio_cookie")?.readLine()
currentRadio = Radio(radio_id, radio_type, "", "")
session = radio_session
cookie = cachedCookie
}
}
}