[Android] Prevent NPE in switchToVideo()
Geoffrey Métais
git at videolan.org
Wed Jun 22 18:10:06 CEST 2016
vlc-android | branch: 2.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jun 22 18:03:41 2016 +0200| [23129265c30653972a81c77168642a2a9674f7cb] | committer: Geoffrey Métais
Prevent NPE in switchToVideo()
(cherry picked from commit d6c964c1db3dd6023e44ca242b50072e6b37e5ba)
> https://code.videolan.org/videolan/vlc-android/commit/23129265c30653972a81c77168642a2a9674f7cb
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index e791181..1d77773 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -757,17 +757,18 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread
public boolean switchToVideo() {
- if (mMediaList.getMedia(mCurrentIndex).hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO) || !canSwitchToVideo())
+ MediaWrapper media = mMediaList.getMedia(mCurrentIndex);
+ if (media == null || media.hasFlag(MediaWrapper.MEDIA_FORCE_AUDIO) || !canSwitchToVideo())
return false;
mVideoBackground = false;
if (isVideoPlaying()) {//Player is already running, just send it an intent
setVideoTrackEnabled(true);
LocalBroadcastManager.getInstance(this).sendBroadcast(
VideoPlayerActivity.getIntent(VideoPlayerActivity.PLAY_FROM_SERVICE,
- getCurrentMediaWrapper(), false, mCurrentIndex));
+ media, false, mCurrentIndex));
} else if (!mSwitchingToVideo) {//Start the video player
VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
- getCurrentMediaWrapper().getUri(), mCurrentIndex);
+ media.getUri(), mCurrentIndex);
mSwitchingToVideo = true;
}
return true;
More information about the Android
mailing list