Recently, we need to test whether Android supports streaming media playing through the HLS protocol. Some examples on the Internet are used to play local files, and some online files are not streaming media using the HLS protocol. According to the updated description of Android3.0, Android3.0 has started to support most of the HLS streaming media types, so we did a test.
The key code is as follows: www.2cto.com
[Java]
Private void playVideo (){
String strPath = "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8 ";
// MvdView. setVideoPath (strPath );
<Span style = "white-space: pre"> </span> Uri uri = Uri. parse (strPath );
MvdView. setVideoURI (uri); // mvdView is a videoView control.
MvdView. setMediaController (new MediaController (this ));
// MvdView. requestFocus ();
MvdView. start ();
}
Private void stopPlay (){
MvdView. stopPlayback ();
}
The error "unable to play the video" is always reported after the video is added. It turns out that the app has no permission to access the network. Add the following statement to the AndroidManifest. xml file:
[Html]
<Uses-permission android: name = "android. permission. INTERNET"/>
The video will soon be played out. However, when performing a bit rate adaptive test, it is not found that the video will automatically switch to a low bit rate when the network environment is poor.
The tested Android versions include Android 2.3, 4.0, and 4.1.