Reputation: 638
I've got some .mp4 videos that have multiple audio tracks, each for a specific language.
I found this question on stackoverflow but the user didn't post his solution.
I was wondering how to select one audio track from the .mp4 video and play it without hearing the other audio tracks at the same time?
I have no restraints as if it needs to be a VideoView or an Activity based on an Intent.ACTION_VIEW.
Upvotes: 2
Views: 4468
Reputation: 1596
Use MediaPlayer.selectTrack(TrackIndex);
to get track index use
findTrackIndexFor(TrackInfo.MEDIA_TRACK_TYPE_AUDIO, MediaPlayer.getTrackInfo());
private int findTrackIndexFor(int mediaTrackType, TrackInfo[] trackInfo) {
int index = -1;
for (int i = 0; i < trackInfo.length; i++) {
if (trackInfo[i].getTrackType() == mediaTrackType) {
return i;
}
}
return index;
}
can you please post that multi-track video files for me.
Upvotes: 2