Android: videoview

Source: Internet
Author: User

OnlineCodeMost of them are similar:

 Private   Static  Progressdialog;  Public  String video_url;  Private  Mediacontroller; @ override  Protected   Void  Oncreate (bundle savedinstancestate ){  //  Todo auto-generated method stub      Super . Oncreate (savedinstancestate); setcontentview (R. layout. videoalbum); progressdialog = Progressdialog. Show (showvideo. This , "", "Buffering video ...", True  ); Getwindow (). setformat (pixelformat. translucent); video_url = "Http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4" ;  Try  {  Final Videoview = (Videoview) findviewbyid (R. Id. video_viewid); mediacontroller =New Mediacontroller (showvideo. This  ); 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 ());}} 

However, when running on a simulator, there are only sound and no images, but there is no problem on the real machine.

Play MP4 video from server android

Playing online video and audio in Android
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.