如何从android播放rtsp直播? (rtsp://形式someserver:端口/现场/ 001204A006F5.stream)

时间:2013-01-24 12:43:06

标签: android android-videoview android-video-player

我有这个视频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播放该链接?

0 个答案:

没有答案