[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Mon May 29 09:07:17 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 29 09:05:09 2017 +0200| [9d72641ab7865e181e09efc7c5516f0b58228005] | committer: Geoffrey Métais

Prevent NPE

> https://code.videolan.org/videolan/vlc-android/commit/9d72641ab7865e181e09efc7c5516f0b58228005
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java        | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index b6444911f..3b723bc8d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1645,16 +1645,15 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 break;
             case MediaPlayer.Event.ESAdded:
                 if (mMenuIdx == -1) {
-                    if (event.getEsChangedType() == Media.Track.Type.Audio) {
-                        MediaWrapper media = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
-                        setESTrackLists();
+                    MediaWrapper media = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
                         if (media == null)
                             return;
+                    if (event.getEsChangedType() == Media.Track.Type.Audio) {
+                        setESTrackLists();
                         int audioTrack = (int) media.getMetaLong(mMedialibrary, MediaWrapper.META_AUDIOTRACK);
                         if (audioTrack != 0 || mCurrentAudioTrack != -2)
                             mService.setAudioTrack(media.getId() == 0L ? mCurrentAudioTrack : audioTrack);
                     } else if (event.getEsChangedType() == Media.Track.Type.Text) {
-                        MediaWrapper media = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
                         setESTrackLists();
                         int spuTrack = (int) media.getMetaLong(mMedialibrary, MediaWrapper.META_SUBTITLE_TRACK);
                         if (spuTrack != 0 || mCurrentSpuTrack != -2)



More information about the Android mailing list