我正在尝试从url获取我的字幕(.srt)文件并将其设置为addTimedTextSource()方法。但问题是addTimedTextSource()仅将subtile路径作为参数而不是url。 我在我的应用程序中使用了vitamio Player
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videobuffer);
mVideoView = (VideoView) findViewById(R.id.buffer);
pb = (ProgressBar) findViewById(R.id.probar);
testview=(TextView) findViewById(R.id.test);
downloadRateView = (TextView) findViewById(R.id.download_rate);
loadRateView = (TextView) findViewById(R.id.load_rate);
mVideoView.addTimedTextSource(subtitle_path);//I want to use URL for this part.
mVideoView.setTimedTextShown(true);
mVideoView.setOnTimedTextListener(new OnTimedTextListener() {
@Override
public void onTimedTextUpdate(byte[] pixels, int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void onTimedText(String text) {
// TODO Auto-generated method stub
testview.setText(text);
Log.d("test","test");
}
});
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoViewBuffer.this,
"Please edit VideoBuffer Activity, and set path"
+ " variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
uri = Uri.parse(path);
mVideoView.setVideoURI(uri);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnInfoListener(this);
mVideoView.setOnBufferingUpdateListener(this);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}
他们是否有任何其他方式添加url并在addtimedTextSource(subtitlefile)中传递它。