fix: notification skip/back drive the app queue
- advertise next/previous on a ForwardingPlayer so the notification and Android Auto show the buttons, and route them to the mood queue - rename the preview section to 'Up next' with a clearer subtitle - version 0.3.2
This commit is contained in:
1 parent
2478505dba
commit
e28e95fa2b
5 files changed
+49
-8
No files matched your search
@@ -41,7 +41,7 @@ val hasUploadKey = uploadKeyStore?.exists() == true &&
|
||||
val appVersionCode = (System.getenv("VERSION_CODE") ?: localProperties.getProperty("VERSION_CODE") ?: "1").toInt()
|
||||
val appVersionName = System.getenv("VERSION_NAME")
|
||||
?: localProperties.getProperty("VERSION_NAME")
|
||||
?: "0.3.1"
|
||||
?: "0.3.2"
|
||||
|
||||
kotlin {
|
||||
androidTarget {
|
||||
|
||||
+41
-1
@@ -9,6 +9,8 @@ import android.view.KeyEvent
|
||||
import androidx.core.content.IntentCompat
|
||||
import androidx.media3.common.AudioAttributes
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.ForwardingPlayer
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.session.MediaSession
|
||||
import androidx.media3.session.MediaSessionService
|
||||
@@ -38,7 +40,7 @@ class PlaybackService : MediaSessionService() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
val player = ExoPlayer.Builder(this)
|
||||
val exoPlayer = ExoPlayer.Builder(this)
|
||||
.setAudioAttributes(
|
||||
AudioAttributes.Builder()
|
||||
.setUsage(C.USAGE_MEDIA)
|
||||
@@ -52,6 +54,44 @@ class PlaybackService : MediaSessionService() {
|
||||
setWakeMode(C.WAKE_MODE_NETWORK)
|
||||
}
|
||||
|
||||
// ExoPlayer holds one item at a time; the queue lives in the app. Advertise
|
||||
// next/previous so the notification and Android Auto show the buttons and
|
||||
// route them to the queue instead of seeking inside the single item.
|
||||
val player = object : ForwardingPlayer(exoPlayer) {
|
||||
override fun getAvailableCommands(): Player.Commands =
|
||||
super.getAvailableCommands().buildUpon()
|
||||
.addAll(
|
||||
Player.COMMAND_SEEK_TO_NEXT,
|
||||
Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
|
||||
Player.COMMAND_SEEK_TO_PREVIOUS,
|
||||
Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,
|
||||
)
|
||||
.build()
|
||||
|
||||
override fun isCommandAvailable(command: Int): Boolean =
|
||||
command == Player.COMMAND_SEEK_TO_NEXT ||
|
||||
command == Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM ||
|
||||
command == Player.COMMAND_SEEK_TO_PREVIOUS ||
|
||||
command == Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM ||
|
||||
super.isCommandAvailable(command)
|
||||
|
||||
override fun seekToNext() {
|
||||
if (!PlaybackCommands.next()) super.seekToNext()
|
||||
}
|
||||
|
||||
override fun seekToNextMediaItem() {
|
||||
if (!PlaybackCommands.next()) super.seekToNextMediaItem()
|
||||
}
|
||||
|
||||
override fun seekToPrevious() {
|
||||
if (!PlaybackCommands.previous()) super.seekToPrevious()
|
||||
}
|
||||
|
||||
override fun seekToPreviousMediaItem() {
|
||||
if (!PlaybackCommands.previous()) super.seekToPreviousMediaItem()
|
||||
}
|
||||
}
|
||||
|
||||
val sessionActivity = PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
|
||||
+2
-2
@@ -189,9 +189,9 @@ fun MoodDetailScreen(state: AppState, store: AppStore) {
|
||||
if (state.preview.isNotEmpty()) {
|
||||
item {
|
||||
HorizontalDivider(Modifier.padding(vertical = 12.dp))
|
||||
SectionTitle("Next batch")
|
||||
SectionTitle("Up next")
|
||||
Text(
|
||||
"What the radio would play next, mixed from this mood and its ready picks. " +
|
||||
"Preview of the radio mix: these are the tracks that would play next. " +
|
||||
"Nothing here is downloaded or saved.",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ fun SettingsScreen(state: AppState, store: AppStore) {
|
||||
Column(Modifier.padding(18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text("About", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||
Text(
|
||||
"AudioManager 0.3.1 · $platformName",
|
||||
"AudioManager 0.3.2 · $platformName",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user