我在lib下使用了
compile 'de.mrmaffen:libvlc-android:2.1.12@aar'
这就是我创建媒体播放器的方式
// Create LibVLC
// TODO: make this more robust, and sync with audio demo
ArrayList<String> options = new ArrayList<String>();
//options.add("--subsdec-encoding <encoding>");
options.add("--aout=opensles");
options.add("--audio-time-stretch"); // time stretching
options.add("-vvv"); // verbosity
libvlc = new LibVLC(this, options);
// Creating media player
mMediaPlayer = new MediaPlayer(libvlc);
mMediaPlayer.setEventListener(mPlayerListener);
// Seting up video output
final IVLCVout vout = mMediaPlayer.getVLCVout();
vout.setVideoView(mVideoView);
//vout.setSubtitlesView(mSurfaceSubtitles);
vout.setWindowSize(mWidth, mHeight);
vout.addCallback(this);
vout.attachViews();
// vout.setSubtitlesView(tv_subtitle);
Media m = new Media(libvlc, Uri.parse(media));
mMediaPlayer.setMedia(m);
mMediaPlayer.play();
我尝试获得如下字幕:
// MediaPlayer.getSpuTracks() - Get the list of available spu (subtitle) tracks.
MediaPlayer.TrackDescription[] trackDescriptions = mMediaPlayer.getSpuTracks();
for (int i = 1; i < trackDescriptions.length; i++) {
MediaPlayer.TrackDescription description = trackDescriptions[i];
Log.i(TAG, "loadSpuTrack " + description.name + ", id " + description.id);
}
但它为我提供了null,我确定我有字幕。还有其他的电影来获得字幕吗?