diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-03-16 20:25:15 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-03-16 20:25:15 +0100 |
commit | bb45d82b08906718e5e2dc33d6f1724c6c9e89a2 (patch) | |
tree | facf9dd8ae1f0321c3c402d39c0ed62463ea616f /core | |
parent | 92efa255721af0e29e502d69c90d8d878cc6e258 (diff) | |
parent | 202f211230ad20bfc539fa5a5fff080e2e1ac623 (diff) | |
download | AntennaPod-bb45d82b08906718e5e2dc33d6f1724c6c9e89a2.zip |
Merge pull request #1689 from mfietz/issue/1687-delay-hide-controls
Video player: Delay controls hide on interaction
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java | 6 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java | 56 |
2 files changed, 32 insertions, 30 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java index 20bdd1f75..d3a5f576a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java @@ -604,7 +604,11 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre * Returns the position of the current media object or INVALID_TIME if the position could not be retrieved. */ public int getPosition() { - if (!playerLock.tryLock()) { + try { + if (!playerLock.tryLock(50, TimeUnit.MILLISECONDS)) { + return INVALID_TIME; + } + } catch (InterruptedException e) { return INVALID_TIME; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 27935978c..1a011a90b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -19,7 +19,6 @@ import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.SurfaceHolder; -import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; @@ -424,6 +423,7 @@ public abstract class PlaybackController { clearStatusMsg(); checkMediaInfoLoaded(); cancelPositionObserver(); + onPositionObserverUpdate(); updatePlayButtonAppearance(playResource, playText); if (PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { setScreenOn(false); @@ -574,34 +574,32 @@ public abstract class PlaybackController { } - public OnClickListener newOnPlayButtonClickListener() { - return v -> { - if (playbackService == null) { - Log.w(TAG, "Play/Pause button was pressed, but playbackservice was null!"); - return; - } - switch (status) { - case PLAYING: - playbackService.pause(true, reinitOnPause); - break; - case PAUSED: - case PREPARED: - playbackService.resume(); - break; - case PREPARING: - playbackService.setStartWhenPrepared(!playbackService - .isStartWhenPrepared()); - if (reinitOnPause - && playbackService.isStartWhenPrepared() == false) { - playbackService.reinit(); - } - break; - case INITIALIZED: - playbackService.setStartWhenPrepared(true); - playbackService.prepare(); - break; - } - }; + public void playPause() { + if (playbackService == null) { + Log.w(TAG, "Play/Pause button was pressed, but playbackservice was null!"); + return; + } + switch (status) { + case PLAYING: + playbackService.pause(true, reinitOnPause); + break; + case PAUSED: + case PREPARED: + playbackService.resume(); + break; + case PREPARING: + playbackService.setStartWhenPrepared(!playbackService + .isStartWhenPrepared()); + if (reinitOnPause + && playbackService.isStartWhenPrepared() == false) { + playbackService.reinit(); + } + break; + case INITIALIZED: + playbackService.setStartWhenPrepared(true); + playbackService.prepare(); + break; + } } public boolean serviceAvailable() { |