How to play YouTube video in android? -


i have videoview , set uri of youtube video , set android.permission.internet got message when want play video .. "you can't play video"

this code piece video player

 mvideoview = (videoview) findviewbyid(r.id.skillvideo);             mvideoview.setvideouri(uri.parse("http://www.youtube.com/watch?v=1_pryg5hfyy"));         mvideoview.setmediacontroller(new mediacontroller(this));         mvideoview.requestfocus(); 

and videoview in xml layout file :

....  <videoview  android:id="@+id/skillvideo"              android:layout_width="wrap_content"             android:layout_height="200dp"></videoview>    .... 

in code here have done, removed mediacontrollers ui , ran youtube video stream threw rtsp , in layout there basic videoview needed button. can see in real action here on android.

markethttps://market.android.com/details?id=com.sbrecords&feature=search_result#?t=w251bgwsmswyldesimnvbs5zynjly29yzhmixq.. video_url = "rtsp://v7.cache3.c.youtube.com/cjgleny73wialwkeuryq8zkcqrmyjcakfeijbxytz29vz2xlsarsb3jlc3vsdhng6knb9mbh8svoda==/0/0/0/video.3gp";

    try {             final videoview videoview =(videoview)findviewbyid(r.id.videoview1);       //1   //mediacontroller = new mediacontroller(splashscreen.this);       //2   //mediacontroller.setanchorview(videoview);             // set video link (mp4 format )             uri video = uri.parse(video_url);             //videoview.setmediacontroller(mediacontroller);             videoview.setvideouri(video);             videoview.setonpreparedlistener(new onpreparedlistener() {                 public void onprepared(mediaplayer mp) {                     progressdialog.dismiss();                    videoview.start();                 }             });           }catch(exception e){               progressdialog.dismiss();              system.out.println("video play error :"+e.getmessage());          } // thread waste time while displaying splash screen thread splashthread = new thread() {     @override     public void run() {         try {             synchronized (this) {                 // wait given period of time                 wait(7450000);             }         } catch (interruptedexception ex) {         }          finish(); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -