Commit d6c964c1 authored by Geoffrey Métais's avatar Geoffrey Métais

Prevent NPE in switchToVideo()

parent 1a586537
...@@ -750,17 +750,18 @@ public class PlaybackService extends Service implements IVLCVout.Callback { ...@@ -750,17 +750,18 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread @MainThread
public boolean switchToVideo() { 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; return false;
mVideoBackground = false; mVideoBackground = false;
if (isVideoPlaying()) {//Player is already running, just send it an intent if (isVideoPlaying()) {//Player is already running, just send it an intent
setVideoTrackEnabled(true); setVideoTrackEnabled(true);
LocalBroadcastManager.getInstance(this).sendBroadcast( LocalBroadcastManager.getInstance(this).sendBroadcast(
VideoPlayerActivity.getIntent(VideoPlayerActivity.PLAY_FROM_SERVICE, VideoPlayerActivity.getIntent(VideoPlayerActivity.PLAY_FROM_SERVICE,
getCurrentMediaWrapper(), false, mCurrentIndex)); media, false, mCurrentIndex));
} else if (!mSwitchingToVideo) {//Start the video player } else if (!mSwitchingToVideo) {//Start the video player
VideoPlayerActivity.startOpened(VLCApplication.getAppContext(), VideoPlayerActivity.startOpened(VLCApplication.getAppContext(),
getCurrentMediaWrapper().getUri(), mCurrentIndex); media.getUri(), mCurrentIndex);
mSwitchingToVideo = true; mSwitchingToVideo = true;
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment