diff --git a/src/contrib/websocket_remote/Constants.h b/src/contrib/websocket_remote/Constants.h index 9ad030703..c66ecaeff 100644 --- a/src/contrib/websocket_remote/Constants.h +++ b/src/contrib/websocket_remote/Constants.h @@ -43,7 +43,7 @@ namespace defaults { static const std::string password = ""; static const int transcoder_cache_count = 50; static const bool transcoder_synchronous = false; - static const bool transcoder_synchronous_fallback = true; + static const bool transcoder_synchronous_fallback = false; } namespace prefs { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/MainActivity.java b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/MainActivity.java index 1ac1a3c57..53cc3566c 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/MainActivity.java +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/MainActivity.java @@ -58,22 +58,26 @@ public class MainActivity extends WebSocketActivityBase { private WebSocketService wss = null; private SharedPreferences prefs; + private PlaybackService playback; + private Handler handler = new Handler(); + private TextView title, artist, album, playPause, volume; private TextView titleWithArt, artistAndAlbumWithArt, volumeWithArt; + private View mainTrackMetadataWithAlbumArt, mainTrackMetadataNoAlbumArt; private TextView notPlayingOrDisconnected; private View buffering, bufferingWithArt; private View connected; private CheckBox shuffleCb, muteCb, repeatCb; private View disconnectedOverlay; - private Handler handler = new Handler(); - private PlaybackService playback; + private ImageView albumArtImageView; + + private ViewPropertyAnimator metadataAnim1, metadataAnim2; /* ugh, artwork related */ private enum DisplayMode { Artwork, NoArtwork, Stopped } - private View mainTrackMetadataWithAlbumArt, mainTrackMetadataNoAlbumArt; - private ViewPropertyAnimator metadataAnim1, metadataAnim2; private AlbumArtModel albumArtModel = AlbumArtModel.empty(); - private ImageView albumArtImageView; + private DisplayMode lastDisplayMode = DisplayMode.Stopped; + private String lastArtworkUrl = null; static { REPEAT_TO_STRING_ID = new HashMap<>(); @@ -338,7 +342,7 @@ public class MainActivity extends WebSocketActivityBase { this.playPause.setText(playing ? R.string.button_pause : R.string.button_play); final boolean stopped = (playback.getPlaybackState() == PlaybackState.Stopped); - notPlayingOrDisconnected.setVisibility(stopped ? View.VISIBLE : View.GONE); + notPlayingOrDisconnected.setVisibility(!connected || stopped ? View.VISIBLE : View.GONE); boolean buffering = playback.getPlaybackState() == PlaybackState.Buffering; @@ -413,6 +417,8 @@ public class MainActivity extends WebSocketActivityBase { } private void setMetadataDisplayMode(DisplayMode mode) { + lastDisplayMode = mode; + if (metadataAnim1 != null) { metadataAnim1.cancel(); metadataAnim2.cancel(); @@ -467,11 +473,13 @@ public class MainActivity extends WebSocketActivityBase { final String url = albumArtModel.getUrl(); if (Strings.empty(url)) { + this.lastArtworkUrl = null; albumArtModel.fetch(); setMetadataDisplayMode(DisplayMode.NoArtwork); } - else { + else if (!url.equals(lastArtworkUrl) || lastDisplayMode == DisplayMode.Stopped) { final int loadId = albumArtModel.getId(); + this.lastArtworkUrl = url; Glide.with(this) .load(url) @@ -484,6 +492,7 @@ public class MainActivity extends WebSocketActivityBase { boolean isFirstResource) { setMetadataDisplayMode(DisplayMode.NoArtwork); + lastArtworkUrl = null; return false; } @@ -511,6 +520,9 @@ public class MainActivity extends WebSocketActivityBase { }) .into(albumArtImageView); } + else { + setMetadataDisplayMode(lastDisplayMode); + } } private void navigateToCurrentArtist() { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/ExoPlayerWrapper.java b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/ExoPlayerWrapper.java index 0b6e8e4ac..396db9984 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/ExoPlayerWrapper.java +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/ExoPlayerWrapper.java @@ -211,15 +211,17 @@ public class ExoPlayerWrapper extends PlayerWrapper { public void dispose() { Preconditions.throwIfNotOnMainThread(); - setState(State.Killing); - removeActivePlayer(this); - if (this.player != null) { - this.player.setPlayWhenReady(false); - this.player.removeListener(eventListener); - this.player.stop(); - this.player.release(); + if (!dead()) { + setState(State.Killing); + removeActivePlayer(this); + if (this.player != null) { + this.player.setPlayWhenReady(false); + this.player.removeListener(eventListener); + this.player.stop(); + this.player.release(); + } + setState(State.Disposed); } - setState(State.Disposed); } @Override diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/StreamingPlaybackService.java b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/StreamingPlaybackService.java index 917f0c224..a9764d28b 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/StreamingPlaybackService.java +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/playback/StreamingPlaybackService.java @@ -90,6 +90,7 @@ public class StreamingPlaybackService implements PlaybackService { if (nextMetadata != null && nextPlayer != null) { if (currentPlayer != null) { + currentPlayer.setOnStateChangedListener(null); currentPlayer.dispose(); }