android - Unable to play Youtube stream via VideoView. How do I fix this? -
i'm trying play youtube video using videoview. gives me "can not play video" error. doing wrong in code below. url using regular youtube url : http://www.youtube.com/watch?v=q7u30li-ooc
public void oncreate(bundle icicle) { super.oncreate(icicle); getwindow().setformat(pixelformat.translucent); setcontentview(r.layout.main); //init components use mvideoview = (videoview) findviewbyid(r.id.video); text = (textview)findviewbyid(r.id.textview1); //get uri data videodemo activity bundle uristream = getintent().getextras(); videouri = uristream.getstring("urivalue"); //set texfield uri string text.settext(videouri); //mvideoview.setvideopath(videouri); //provide videoview component file path , play mvideoview.setvideouri(uri.parse(videouri)); mvideoview.setmediacontroller(new mediacontroller(this)); mvideoview.requestfocus(); mvideoview.start(); }
no need create separate video view can play youtube videos directly using intent
startactivity(newintent(intent.action_view,uri.parse("video url")));
Comments
Post a Comment