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