diff --git a/android/app/src/main/java/com/fabledsword/minstrel/player/MinstrelForwardingPlayer.kt b/android/app/src/main/java/com/fabledsword/minstrel/player/MinstrelForwardingPlayer.kt index eb8c52bd..be14cc46 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/player/MinstrelForwardingPlayer.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/player/MinstrelForwardingPlayer.kt @@ -342,6 +342,23 @@ class MinstrelForwardingPlayer( } } + // The system media notification / lock-screen / Android Auto / Wear 'next' + // and 'previous' buttons issue COMMAND_SEEK_TO_NEXT / COMMAND_SEEK_TO_PREVIOUS + // -> Player.seekToNext() / seekToPrevious(), which are DISTINCT from the + // *MediaItem variants the in-app transport buttons call. Un-overridden, the + // base ForwardingPlayer forwards these to the paused local delegate -- so + // the notification next/prev only nudged the local cursor (which the poll + // then re-synced back to Sonos), reading as dead buttons while casting. + // Route them through the same Sonos path as the media-item variants when a + // UPnP route is engaged; plain local playback keeps the default behaviour. + override fun seekToNext() { + if (isRemote() || isLoadingUpnp()) seekToNextMediaItem() else super.seekToNext() + } + + override fun seekToPrevious() { + if (isRemote() || isLoadingUpnp()) seekToPreviousMediaItem() else super.seekToPrevious() + } + override fun getCurrentPosition(): Long = if (isRemote()) remoteState.positionMs else super.getCurrentPosition()