[Android] Fix switch to video when track id is different than 0
Thomas Guillem
git at videolan.org
Fri May 22 10:02:10 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri May 22 10:01:21 2015 +0200| [78da820fee87ff40c1eb3e65dd20e9d036e37ad4] | committer: Thomas Guillem
Fix switch to video when track id is different than 0
Fixes #14429
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=78da820fee87ff40c1eb3e65dd20e9d036e37ad4
---
libvlc/jni/libvlcjni-track.c | 30 +++++++++++++++++---
libvlc/src/org/videolan/libvlc/LibVLC.java | 2 +-
.../vlc/gui/video/VideoPlayerActivity.java | 6 ++--
3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/libvlc/jni/libvlcjni-track.c b/libvlc/jni/libvlcjni-track.c
index 7338f8e..c6cdba4 100644
--- a/libvlc/jni/libvlcjni-track.c
+++ b/libvlc/jni/libvlcjni-track.c
@@ -279,12 +279,34 @@ jint Java_org_videolan_libvlc_LibVLC_getVideoTracksCount(JNIEnv *env, jobject th
return -1;
}
-jint Java_org_videolan_libvlc_LibVLC_setVideoTrack(JNIEnv *env, jobject thiz, jint index)
+jint Java_org_videolan_libvlc_LibVLC_setVideoTrackEnabled(JNIEnv *env, jobject thiz, jboolean enabled)
{
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
- if (mp)
- return libvlc_video_set_track(mp, index);
- return -1;
+ if (!mp)
+ return -1;
+ if (!enabled)
+ return libvlc_video_set_track(mp, -1);
+ else
+ {
+ int i_id = -1;
+ libvlc_track_description_t *tracks, *tracks_itr;
+
+ tracks_itr = tracks = libvlc_video_get_track_description(mp);
+ if (!tracks)
+ return -1;
+
+ while (tracks_itr)
+ {
+ if (tracks_itr->i_id != -1)
+ {
+ i_id = tracks_itr->i_id;
+ break;
+ }
+ tracks_itr = tracks_itr->p_next;
+ }
+ libvlc_track_description_list_release(tracks);
+ return libvlc_video_set_track(mp, i_id);
+ }
}
jobject Java_org_videolan_libvlc_LibVLC_getSpuTrackDescription(JNIEnv *env, jobject thiz)
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 09a5bfb..23e1203 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -633,7 +633,7 @@ public class LibVLC {
public native int getVideoTracksCount();
- public native int setVideoTrack(int index);
+ public native int setVideoTrackEnabled(boolean enabled);
public native int addSubtitleTrack(String path);
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 52e0e08..a644051 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1682,7 +1682,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
if (mHardwareAccelerationError)
return;
mSwitchingView = true;
- mLibVLC.setVideoTrack(-1);
+ mLibVLC.setVideoTrackEnabled(false);
// Show the MainActivity if it is not in background.
if (showUI && getIntent().getAction() != null
&& getIntent().getAction().equals(Intent.ACTION_VIEW)) {
@@ -2866,8 +2866,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVideoPlay
mMediaListPlayer.playIndex(savedIndexPosition, wasPaused);
seek(intentPosition, mediaLength);
} else {
- mLibVLC.setVideoTrack(-1);
- mLibVLC.setVideoTrack(0);
+ mLibVLC.setVideoTrackEnabled(false);
+ mLibVLC.setVideoTrackEnabled(true);
// AudioService-transitioned playback for item after sleep and resume
if(!mLibVLC.isPlaying())
mMediaListPlayer.playIndex(savedIndexPosition);
More information about the Android
mailing list