[Android] MediaPlayer: Prevent IllegalStateException
Geoffrey Métais
git at videolan.org
Mon Jun 3 10:30:25 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 3 10:15:37 2019 +0200| [9ec511130e6165c0452ac718bfbe27b518693613] | committer: Geoffrey Métais
MediaPlayer: Prevent IllegalStateException
> https://code.videolan.org/videolan/vlc-android/commit/9ec511130e6165c0452ac718bfbe27b518693613
---
libvlc/src/org/videolan/libvlc/MediaPlayer.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 073094c68..6abc3e995 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -36,6 +36,10 @@ import android.net.Uri;
import android.os.Build;
import android.util.SparseArray;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.libvlc.util.DisplayManager;
import org.videolan.libvlc.util.VLCUtil;
@@ -44,10 +48,6 @@ import org.videolan.libvlc.util.VLCVideoLayout;
import java.io.File;
import java.io.IOException;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
-
@SuppressWarnings("unused, JniMissingFunction")
public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
@@ -1050,9 +1050,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
public void setVideoTrackEnabled(boolean enabled) {
if (!enabled) {
setVideoTrack(-1);
- } else if (getVideoTrack() == -1) {
+ } else if (!isReleased() && hasMedia() && getVideoTrack() == -1) {
final MediaPlayer.TrackDescription tracks[] = getVideoTracks();
-
if (tracks != null) {
for (MediaPlayer.TrackDescription track : tracks) {
if (track.id != -1) {
More information about the Android
mailing list