android - How to display a Video from an URL -


i have button on main tab of apps attempts launch video url via second activity

i have tested blank activity , displayed 'hello' when said button click. removed 'hello' editext , added codes java file suggested in similar post.

when video btn clicked, message ;can't play video, ok'

i have tested youtube link valid link. yet logcat error message include :

10-07 09:04:36.785: i/mediaplayer(11397): path null 10-07 09:04:36.795: d/mediaplayer(11397): setdatasource ioexception happend :  10-07 09:04:36.795: d/mediaplayer(11397):  java.io.filenotfoundexception: no content provider: http://youtu.be/rfrg1xfoxeq  

where go here ?

an xml second activity follows :-

<videoview     android:id="@+id/videoview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content" />  </tablelayout> 

corresponding java file

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_serve_motion_up_together);     string videopath2 = "http://youtu.be/rfrg1xfoxeq";     videoview videoview1 = (videoview) findviewbyid(r.id.videoview1);      videoview1.setvideouri(uri.parse(videopath2));     videoview1.setmediacontroller(new mediacontroller(this));     videoview1.setvisibility(1);     videoview1.bringtofront();     videoview1.requestfocus();     videoview1.start();         } 

logcat

10-07 09:04:36.765: d/dalvikvm(11397): gc_concurrent freed 97k, 12% free 9619k/10887k, paused 13ms+2ms, total 47ms 10-07 09:04:36.785: v/mediaplayer(11397): constructor 10-07 09:04:36.785: v/mediaplayer(11397): setlistener 10-07 09:04:36.785: i/mediaplayer(11397): path null 10-07 09:04:36.795: d/mediaplayer(11397): setdatasource ioexception happend :  10-07 09:04:36.795: d/mediaplayer(11397): java.io.filenotfoundexception: no content provider: http://youtu.be/rfrg1xfoxeq 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.content.contentresolver.opentypedassetfiledescriptor(contentresolver.java:710) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.content.contentresolver.openassetfiledescriptor(contentresolver.java:614) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.media.mediaplayer.setdatasource(mediaplayer.java:929) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.widget.videoview.openvideo(videoview.java:235) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.widget.videoview.access$2000(videoview.java:51) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.widget.videoview$6.surfacecreated(videoview.java:478) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.surfaceview.updatewindow(surfaceview.java:591) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.surfaceview.access$000(surfaceview.java:81) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.surfaceview$3.onpredraw(surfaceview.java:173) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.viewtreeobserver.dispatchonpredraw(viewtreeobserver.java:707) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1944) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1113) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4481) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.choreographer$callbackrecord.run(choreographer.java:725) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.choreographer.docallbacks(choreographer.java:555) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.choreographer.doframe(choreographer.java:525) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.os.handler.handlecallback(handler.java:615) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.os.handler.dispatchmessage(handler.java:92) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.os.looper.loop(looper.java:137) 10-07 09:04:36.795: d/mediaplayer(11397):   @ android.app.activitythread.main(activitythread.java:4867) 10-07 09:04:36.795: d/mediaplayer(11397):   @ java.lang.reflect.method.invokenative(native method) 10-07 09:04:36.795: d/mediaplayer(11397):   @ java.lang.reflect.method.invoke(method.java:511) 10-07 09:04:36.795: d/mediaplayer(11397):   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1007) 10-07 09:04:36.795: d/mediaplayer(11397):   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:774) 10-07 09:04:36.795: d/mediaplayer(11397):   @ dalvik.system.nativestart.main(native method) 10-07 09:04:36.795: d/mediaplayer(11397): couldn't open file on client side, trying server side 10-07 09:04:36.795: v/mediaplayer(11397): setvideosurfacetexture 10-07 09:04:36.795: v/mediaplayer(11397): mediaplayer::setaudiostreamtype 10-07 09:04:36.795: v/mediaplayer(11397): setvideosurfacetexture 10-07 09:04:36.795: v/mediaplayer(11397): prepareasync 10-07 09:04:36.825: d/progressbar(11397): setprogressdrawable mprogressdrawable = null, d = android.graphics.drawable.layerdrawable@41b6d730needupdate = false 10-07 09:04:36.825: d/progressbar(11397): setprogress = 0 10-07 09:04:36.825: d/progressbar(11397): setprogress = 0, fromuser = false 10-07 09:04:36.825: d/progressbar(11397): mprogress = 0mindeterminate = false, mmin = 0, mmax = 100 10-07 09:04:36.835: w/resourcetype(11397): failure getting entry 0x010802c9 (t=7 e=713) in package 0 (error -75) 10-07 09:04:36.935: e/spannablestringbuilder(11397): span_exclusive_exclusive spans cannot have 0 length 10-07 09:04:36.935: e/spannablestringbuilder(11397): span_exclusive_exclusive spans cannot have 0 length 10-07 09:04:40.699: v/mediaplayer(11397): message received msg=100, ext1=1, ext2=-2147483648 10-07 09:04:40.699: e/mediaplayer(11397): error (1, -2147483648) 10-07 09:04:40.699: v/mediaplayer(11397): callback application 10-07 09:04:40.699: v/mediaplayer(11397): callback 10-07 09:04:40.699: e/mediaplayer(11397): error (1,-2147483648) 10-07 09:04:40.699: d/videoview(11397): error: 1,-2147483648 10-07 09:04:40.719: w/resourcetype(11397): failure getting entry 0x010802c9 (t=7 e=713) in package 0 (error -75) 

tia

cch4adt

try this:

string link = "http://youtu.be/rfrg1xfoxeq"; setcontentview(r.layout.mediaplayer); videoview videoview = (videoview) findviewbyid(r.id.video); mediacontroller mc = new mediacontroller(this); mc.setanchorview(videoview); mc.setmediaplayer(videoview); uri video = uri.parse(link); videoview.setmediacontroller(mc); videoview.setvideouri(video); videoview.start(); 

i'm not sure work, worth try


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -