From b9d841574156f6712b54cd878c0b8ebf06e9c384 Mon Sep 17 00:00:00 2001 From: y20k Date: Thu, 25 Feb 2021 10:37:16 +0100 Subject: [PATCH] preparing release --- app/build.gradle | 2 +- .../y20k/transistor/playback/PlayerService.kt | 25 +++++++++++++++---- metadata/en-US/changelogs/82.txt | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ed126ad3..4da7f738 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,7 +13,7 @@ android { targetSdkVersion 30 versionCode 82 versionName '4.0.11' - resConfigs "en", "ar", "ca", "cs","de", "el", "eo","es", "eu", "fr", "he", "hr", "id", "in", "it", "ja", "kab", "nb-rNO", "nl", "pa", "pl", "pt", "pt-rBR", "ru", "sk", "sl", "sr", "th", "tr", "uk", "zh-rCN" + resConfigs "en", "ar", "ca", "cs","de", "el", "eo", "es", "eu", "fr", "he", "hr", "id", "in", "it", "ja", "kab", "nb-rNO", "nl", "pa", "pl", "pt", "pt-rBR", "ru", "sk", "sl", "sr", "th", "tr", "uk", "zh-rCN" } kotlinOptions { diff --git a/app/src/main/java/org/y20k/transistor/playback/PlayerService.kt b/app/src/main/java/org/y20k/transistor/playback/PlayerService.kt index 8fc40281..cf8efb91 100644 --- a/app/src/main/java/org/y20k/transistor/playback/PlayerService.kt +++ b/app/src/main/java/org/y20k/transistor/playback/PlayerService.kt @@ -143,7 +143,7 @@ class PlayerService(): MediaBrowserServiceCompat() { mediaSessionConnector.setQueueNavigator(object : TimelineQueueNavigator(mediaSession) { override fun getMediaDescription(player: Player, windowIndex: Int): MediaDescriptionCompat { // create media description - used in notification - return CollectionHelper.buildStationMediaDescription(this@PlayerService, station, metadataHistory.last()) + return CollectionHelper.buildStationMediaDescription(this@PlayerService, station, getCurrentMetadata()) } override fun onSkipToPrevious(player: Player, controlDispatcher: ControlDispatcher) { LogHelper.d(TAG, "onSkipToPrevious called") // todo remove @@ -378,6 +378,9 @@ class PlayerService(): MediaBrowserServiceCompat() { // update media session connector mediaSessionConnector.setPlayer(player) + // reset metadata to station name + updateMetadata(station.name) + // set playWhenReady state player.playWhenReady = playWhenReady } @@ -487,7 +490,7 @@ class PlayerService(): MediaBrowserServiceCompat() { // wait for result and update collection collection = deferred.await() // special case: trigger metadata view update for stations that have no metadata - if (playerState.playbackState == PlaybackState.STATE_PLAYING && station.name == metadataHistory.last()) { + if (playerState.playbackState == PlaybackState.STATE_PLAYING && station.name == getCurrentMetadata()) { station = CollectionHelper.getStation(collection, station.uuid) updateMetadata(null) } @@ -505,6 +508,18 @@ class PlayerService(): MediaBrowserServiceCompat() { } + /* Gets the most current metadata string */ + private fun getCurrentMetadata(): String { + val metadataString: String + if (metadataHistory.isEmpty()) { + metadataString = station.name + } else { + metadataString = metadataHistory.last() + } + return metadataString + } + + /* Load next station and start playback */ private fun skipToNextStation() { // stop current playback, if necessary @@ -627,11 +642,11 @@ class PlayerService(): MediaBrowserServiceCompat() { val event: KeyEvent? = mediaButtonEvent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) when (event?.keyCode) { KeyEvent.KEYCODE_MEDIA_NEXT -> { - skipToNextStation() + if (event.action == KeyEvent.ACTION_UP) skipToNextStation() return true } KeyEvent.KEYCODE_MEDIA_PREVIOUS -> { - skipToPreviousStation() + if (event.action == KeyEvent.ACTION_UP) skipToPreviousStation() return true } else -> return false @@ -648,7 +663,7 @@ class PlayerService(): MediaBrowserServiceCompat() { // */ // private val metadataProvider = object : MediaSessionConnector.MediaMetadataProvider { // override fun getMetadata(player: Player): MediaMetadataCompat { -// return CollectionHelper.buildStationMediaMetadata(this@PlayerService, station, metadataHistory.last()) +// return CollectionHelper.buildStationMediaMetadata(this@PlayerService, station, getCurrentMetadata()) // } // } // /* diff --git a/metadata/en-US/changelogs/82.txt b/metadata/en-US/changelogs/82.txt index ab496327..74febad3 100644 --- a/metadata/en-US/changelogs/82.txt +++ b/metadata/en-US/changelogs/82.txt @@ -4,3 +4,4 @@ - Esperanto language version - updated translations +- changed notification behavior