[Android] Check player has media before any action
Geoffrey Métais
git at videolan.org
Fri Nov 10 11:04:40 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov 10 10:16:42 2017 +0100| [2a7ff86f4b05740600485a40bc94bfbd3a1eddae] | committer: Geoffrey Métais
Check player has media before any action
> https://code.videolan.org/videolan/vlc-android/commit/2a7ff86f4b05740600485a40bc94bfbd3a1eddae
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index bb9de1f3e..11aaca431 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -415,7 +415,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
Log.i(TAG, "AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
// Lower the volume
- if (mMediaPlayer.isPlaying()) {
+ if (isPlaying()) {
final int volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (audioDuckLevel == -1)
audioDuckLevel = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)/5;
@@ -434,7 +434,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
}
if (mLossTransient) {
if (wasPlaying && mSettings.getBoolean("resume_playback", true))
- mMediaPlayer.play();
+ play();
mLossTransient = false;
}
break;
@@ -1045,7 +1045,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@MainThread
public void pause() {
- if (mPausable) {
+ if (hasCurrentMedia() && mPausable) {
savePosition();
mMediaPlayer.pause();
}
@@ -1728,7 +1728,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@MainThread
public boolean isPlaying() {
- return mMediaPlayer.isPlaying();
+ return hasCurrentMedia() && mMediaPlayer.isPlaying();
}
@MainThread
More information about the Android
mailing list