Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Casanowow Life for love
VLC-Android
Commits
abfa12b0
Commit
abfa12b0
authored
Mar 02, 2012
by
Sébastien Toque
Browse files
Audio track selection for multi-track audio files
parent
19ccff83
Changes
4
Hide whitespace changes
Inline
Side-by-side
vlc-android/jni/libvlcjni.c
View file @
abfa12b0
...
...
@@ -719,6 +719,48 @@ jint Java_org_videolan_vlc_LibVLC_getAudioTracksCount(JNIEnv *env, jobject thiz)
return
-
1
;
}
jobjectArray
Java_org_videolan_vlc_LibVLC_getAudioTrackDescription
(
JNIEnv
*
env
,
jobject
thiz
)
{
libvlc_media_player_t
*
mp
=
getMediaPlayer
(
env
,
thiz
);
if
(
!
mp
)
return
NULL
;
int
i_nbTracks
=
libvlc_audio_get_track_count
(
mp
)
-
1
;
if
(
i_nbTracks
<
0
)
i_nbTracks
=
0
;
jobjectArray
array
=
(
*
env
)
->
NewObjectArray
(
env
,
i_nbTracks
,
(
*
env
)
->
FindClass
(
env
,
"java/lang/String"
),
NULL
);
libvlc_track_description_t
*
first
=
libvlc_audio_get_track_description
(
mp
);
libvlc_track_description_t
*
desc
=
first
!=
NULL
?
first
->
p_next
:
NULL
;
unsigned
i
;
for
(
i
=
0
;
i
<
i_nbTracks
;
++
i
)
{
jstring
name
=
(
*
env
)
->
NewStringUTF
(
env
,
desc
->
psz_name
);
(
*
env
)
->
SetObjectArrayElement
(
env
,
array
,
i
,
name
);
desc
=
desc
->
p_next
;
}
libvlc_track_description_list_release
(
first
);
return
array
;
}
jint
Java_org_videolan_vlc_LibVLC_getAudioTrack
(
JNIEnv
*
env
,
jobject
thiz
)
{
libvlc_media_player_t
*
mp
=
getMediaPlayer
(
env
,
thiz
);
if
(
mp
)
return
libvlc_audio_get_track
(
mp
);
return
-
1
;
}
jint
Java_org_videolan_vlc_LibVLC_setAudioTrack
(
JNIEnv
*
env
,
jobject
thiz
,
jint
index
)
{
libvlc_media_player_t
*
mp
=
getMediaPlayer
(
env
,
thiz
);
if
(
mp
)
return
libvlc_audio_set_track
(
mp
,
index
);
return
-
1
;
}
jint
Java_org_videolan_vlc_LibVLC_getVideoTracksCount
(
JNIEnv
*
env
,
jobject
thiz
)
{
libvlc_media_player_t
*
mp
=
getMediaPlayer
(
env
,
thiz
);
...
...
vlc-android/res/layout/player.xml
View file @
abfa12b0
...
...
@@ -31,20 +31,42 @@
<TextView
android:id=
"@+id/player_overlay_title"
android:layout_width=
"0dp"
android:layout_height=
"
wrap_cont
ent"
android:layout_height=
"
fill_par
ent"
android:layout_weight=
"1"
android:gravity=
"left|center_vertical"
android:text=
"@string/title"
android:textColor=
"#ffffff"
android:textSize=
"15dip"
/>
<TextView
android:id=
"@+id/player_overlay_battery"
<ImageButton
android:id=
"@+id/player_overlay_audio"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:background=
"@drawable/header_icon_audio"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"right|center_vertical"
android:textColor=
"#ffffff"
android:textSize=
"15dip"
/>
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/player_overlay_systime"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"right|center_vertical"
android:textColor=
"#ffffff"
android:textSize=
"15dip"
/>
<TextView
android:id=
"@+id/player_overlay_battery"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"right|center_vertical"
android:textColor=
"#ffffff"
android:textSize=
"15dip"
/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
...
...
vlc-android/src/org/videolan/vlc/LibVLC.java
View file @
abfa12b0
...
...
@@ -346,6 +346,18 @@ public class LibVLC {
private
native
TrackInfo
[]
readTracksInfo
(
int
instance
,
String
mrl
);
public
native
int
getAudioTracksCount
();
public
native
String
[]
getAudioTrackDescription
();
public
native
int
getAudioTrack
();
public
native
int
setAudioTrack
(
int
index
);
public
native
int
getVideoTracksCount
();
public
native
int
getSpuTracksCount
();
/**
* Return true if there is a video track in the file
*/
...
...
vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
View file @
abfa12b0
...
...
@@ -30,8 +30,11 @@ import org.videolan.vlc.R;
import
org.videolan.vlc.Util
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog.Builder
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.pm.ActivityInfo
;
...
...
@@ -44,6 +47,7 @@ import android.os.Handler;
import
android.os.Message
;
import
android.os.PowerManager
;
import
android.os.PowerManager.WakeLock
;
import
android.text.format.DateFormat
;
import
android.util.Log
;
import
android.view.Display
;
import
android.view.MotionEvent
;
...
...
@@ -89,11 +93,13 @@ public class VideoPlayerActivity extends Activity {
private
boolean
mShowing
;
private
SeekBar
mSeekbar
;
private
TextView
mTitle
;
private
TextView
mSysTime
;
private
TextView
mBattery
;
private
TextView
mTime
;
private
TextView
mLength
;
private
TextView
mInfo
;
private
SeekBar
mWheel
;
private
ImageButton
mAudio
;
private
ImageButton
mLock
;
private
ImageButton
mSize
;
...
...
@@ -110,6 +116,7 @@ public class VideoPlayerActivity extends Activity {
private
int
mAudioDisplayRange
;
private
float
mTouchY
,
mVol
;
private
boolean
mIsAudioChanged
;
private
String
[]
mAudioTracks
;
//Wheel
private
static
final
int
WHEEL_DEAD_ZONE
=
7
;
...
...
@@ -133,6 +140,7 @@ public class VideoPlayerActivity extends Activity {
/* header */
mTitle
=
(
TextView
)
findViewById
(
R
.
id
.
player_overlay_title
);
mSysTime
=
(
TextView
)
findViewById
(
R
.
id
.
player_overlay_systime
);
mBattery
=
(
TextView
)
findViewById
(
R
.
id
.
player_overlay_battery
);
mTime
=
(
TextView
)
findViewById
(
R
.
id
.
player_overlay_time
);
...
...
@@ -146,6 +154,9 @@ public class VideoPlayerActivity extends Activity {
mWheel
.
setProgress
(
mMiddle
);
mWheel
.
setOnSeekBarChangeListener
(
mWheelListener
);
mAudio
=
(
ImageButton
)
findViewById
(
R
.
id
.
player_overlay_audio
);
mAudio
.
setOnClickListener
(
mAudioListener
);
mLock
=
(
ImageButton
)
findViewById
(
R
.
id
.
player_overlay_lock
);
mLock
.
setOnClickListener
(
mLockListener
);
...
...
@@ -545,6 +556,26 @@ public class VideoPlayerActivity extends Activity {
};
private
OnClickListener
mAudioListener
=
new
OnClickListener
()
{
public
void
onClick
(
View
v
)
{
if
(
mAudioTracks
==
null
||
mAudioTracks
.
length
<=
1
)
return
;
int
current
=
mLibVLC
.
getAudioTrack
()
-
1
;
Builder
builder
=
new
AlertDialog
.
Builder
(
VideoPlayerActivity
.
this
);
builder
.
setSingleChoiceItems
(
mAudioTracks
,
current
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
mLibVLC
.
setAudioTrack
(
which
+
1
);
}
});
builder
.
show
();
}
};
/**
*
*/
...
...
@@ -638,6 +669,13 @@ public class VideoPlayerActivity extends Activity {
mHandler
.
removeMessages
(
FADE_OUT
);
mHandler
.
sendMessageDelayed
(
msg
,
timeout
);
}
if
(
mAudioTracks
==
null
)
{
mAudioTracks
=
mLibVLC
.
getAudioTrackDescription
();
if
(
mAudioTracks
!=
null
&&
mAudioTracks
.
length
>
1
)
mAudio
.
setVisibility
(
View
.
VISIBLE
);
else
mAudio
.
setVisibility
(
View
.
GONE
);
}
updateOverlayPausePlay
();
}
...
...
@@ -699,6 +737,7 @@ public class VideoPlayerActivity extends Activity {
mSeekbar
.
setMax
(
length
);
mSeekbar
.
setProgress
(
time
);
mSysTime
.
setText
(
DateFormat
.
format
(
"kk:mm"
,
System
.
currentTimeMillis
()));
mTime
.
setText
(
Util
.
millisToString
(
time
));
mLength
.
setText
(
Util
.
millisToString
(
length
));
return
time
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment