VideoView not playing video from URL in Android -
i tried many links links show same error.but it's giving error "can't play video".
my code following
public class videodemo extends activity { private videoview video; private static final string path ="http://www.ustream.tv/embed/6540154?v=3&wmode=direct"; @override public void oncreate(bundle icicle) { setcontentview(r.layout.activity_main); videoview = (videoview) findviewbyid(r.id.videoview); try { // start mediacontroller mediacontroller mediacontroller = new mediacontroller( videodemo.this); mediacontroller.setanchorview(videoview); // url string videourl uri video = uri.parse(videourl); videoview.setmediacontroller(mediacontroller); videoview.setvideouri(video); videoview.start(); } catch (exception e) { log.e("error", e.getmessage()); e.printstacktrace(); } }
}
this because url using not 1 of video of media player plays video.
to play actual video first need find url. 1 way find use livestreamer.
install following instructions , can run command
livestreamer http://www.ustream.tv/embed/6540154 best --stream-url
the output of command url can use in videoview.
Comments
Post a Comment