How to Stream Video from Http or RTSP Url in android

天涯浪子 提交于 2019-12-13 15:07:44

问题


I want to play a video from Http and Rtsp on android. currently i am trying with http link But when my activity starts, it just starts playing audio with blank black screen. No video is displaying. Here i have posted my code below. Thanks for any help in advance. and if anyone can provide a fresh running rtsp link for live streaming, i'll be very thankful.

    VideoView vidView = (VideoView)findViewById(R.id.myVideo);

    Uri stream = Uri.parse("http://www.androidbegin.com/tutorial/AndroidCommercial.3gp");

    vidView.setVideoURI(stream);

    MediaController vidControl = new MediaController(this);
    vidControl.setAnchorView(vidView);
    vidView.setMediaController(vidControl);
    vidView.requestFocus();
    vidView.start();

回答1:


You can easily do it via Vitamio Libary. Vitamio supports 720p/1080p HD, mp4, mkv, m4v, mov, flv, avi, rmvb, rm, ts, tp and many other video formats in Android and iOS. Almost all popular streaming protocols are supported by Vitamio, including HLS (m3u8), MMS, RTSP, RTMP, and HTTP.

You can download demo from here.




回答2:


If the VideoView does not work with your stream then you need to do it with ffmpeg



来源:https://stackoverflow.com/questions/27398350/how-to-stream-video-from-http-or-rtsp-url-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!