我有这个视频url rtsp:// someserver:port / live / 001204A006F5.stream并希望从Android媒体播放器播放相同内容。我已经编写了以下代码片段,但是android正在显示一个带有msg“无法播放此视频”的对话框。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);`
videoPlayer = (VideoView) findViewById(R.id.videoPlayer);
videoPlayer.setOnPreparedListener(this);
videoPlayer.setOnCompletionListener(this);
videoPlayer.setKeepScreenOn(true);
Uri uri = Uri.parse("rtsp://someserver:port/live/001204A006F5.stream");
videoPlayer.setVideoURI(uri);
}
/** This callback will be invoked when the file is ready to play */
public void onPrepared(MediaPlayer vp) {
if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
videoPlayer.start();
}
我做错了吗?或者无法使用VideoView播放该链接?