Android VideoView不接受RTSP URI

时间:2014-09-15 02:05:17

标签: android stream android-mediaplayer rtsp android-videoview

长期用户,第一次发布海报。所以,感谢所有在此之前直接或间接帮助过的人。

我在尝试流式传输通过RTSP提供的mp4 / 3gp视频文件时遇到问题。我的POC的代码如下,但与我在此处找到的示例非常相似:

http://android-coding.blogspot.co.uk/2011/03/simple-example-using-videoview-to-play.html

String rtspLink = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vid_view_rtsp);
    VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
    myVideoView.setVideoURI(Uri.parse(rtspLink));
    myVideoView.setMediaController(new MediaController(this));
    myVideoView.requestFocus();
    myVideoView.start();
}

不幸的是,我发现的大多数例子都来自几年前,特别是2011年的这个例子。我正在测试物理上的三星S3(Android 4.3)。 我已经确认3gp文件确实存在,并且已经使用VLC成功传输了它。我对自己的MP4也有同样的问题。

生成的堆栈跟踪/ logcat如下:

09-15 02:16:07.520  25040-25040/org.chutchut.videoviewrtsp D/MediaPlayer﹕ setDataSource IOException happend :
    java.io.FileNotFoundException: No content provider: rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp
            at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:761)
            at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:665)
            at android.media.MediaPlayer.setDataSource(MediaPlayer.java:960)
            at android.widget.VideoView.openVideo(VideoView.java:264)
            at android.widget.VideoView.access$2000(VideoView.java:52)
            at android.widget.VideoView$6.surfaceCreated(VideoView.java:522)
            <.. snip ..>
09-15 02:16:07.520  25040-25040/org.chutchut.videoviewrtsp D/MediaPlayer﹕ Couldn't open file on client side, trying server side
09-15 02:16:07.530  25040-25040/org.chutchut.videoviewrtsp E/MediaPlayer﹕ Unable to to create media player
09-15 02:16:07.535  25040-25040/org.chutchut.videoviewrtsp W/VideoView﹕ Unable to open content: rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp
    java.io.IOException: setDataSource failed.: status=0x80000000
            at android.media.MediaPlayer._setDataSource(Native Method)
            at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1185)
            at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1130)
            at android.media.MediaPlayer.setDataSource(MediaPlayer.java:989)
            at android.widget.VideoView.openVideo(VideoView.java:264)
            at android.widget.VideoView.access$2000(VideoView.java:52)
            at android.widget.VideoView$6.surfaceCreated(VideoView.java:522)
            <.. snip ..>
09-15 02:16:07.535  25040-25040/org.chutchut.videoviewrtsp D/VideoView﹕ Error: 1,0

提前致谢!

0 个答案:

没有答案