1. Monitor Playback error
Class Myonerrorlistener implements Mediaplayer.onerrorlistener {@Overridepublic Boolean onError (MediaPlayer MP, int what, int extra) {/// Toast.maketext (systemvideoplayer.this, "Playback error Oh", Toast.length_short). Show ();//1. Playback of the video format is not supported-jump to the universal player to continue playing startvitamioplayer ();//2. When playing network video, the network interrupt---1. If the network is really broken, you can be prompted for the network is broken, 2. The network is intermittent, re-play//3. There is a blank in the middle of the local file---download to complete return true;}}
2. Overview of the Universal decoding framework
1.ffmpeg
2.VLC
3.Vitamio Universal decoding framework for direct use on Android and iOS platforms.
Vitamio can seamlessly play videos in common formats such as 720P or 1080P HD MKV,FLV,MP4,MOV,TS,RMVB, as well as cross-platform support for MMS, RTSP, RTMP, HLS (m3u8) on Android and IOS A variety of common video streaming protocols, including on-demand and live streaming.
It encapsulates the ffmpeg.
Integration of 3.Vitamio
1. Associated Vitamio Library
Compile project (': Vitamio ')
2. Copy the configuration of the function manifest file past permissions
<uses-permission android:name= "Android.permission.WAKE_LOCK"/><uses-permission android:name= " Android.permission.INTERNET "/><uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE "/ ><uses-permission android:name= "Android.permission.READ_EXTERNAL_STORAGE"/><uses-permission android: Name= "Android.permission.ACCESS_WIFI_STATE"/><uses-permission android:name= "Android.permission.READ_PHONE _state "/>
Configuration
<!--Don ' t forgot initactivity--><activity android:name= "Io.vov.vitamio.activity.InitActivity" Android:configchanges= "Orientation|screensize|smallestscreensize|keyboard|keyboardhidden|navigation" Android:launchmode= "Singletop" android:theme= "@android: Style/theme.notitlebar" android: Windowsoftinputmode= "Statealwayshidden"/>
3. Copy the system Systemvideoplayer, change the name Vitamiovideoplayer Import package is Vitamio package, Mediaplayer,videoview
Custom Vitamiovideoview inherits the Videoview of Vitamio
4. layout file Activitysystemvideoplayer.xml copy a renamed Activityvitamiovideoplayer.xml, and replace the videoview inside with the Vitamio Vitamiovideoview.
5. Initialize the Vitamio library before the layout file is loaded
Vitamio.isinitialized (this);
6. When the system player is playing an error, jump to Vitamiovideoplayer to play the question: can I play it directly with the Vitamio player?
Note: A, pass the data into Vtaimovideoplayer Player B and close the system player
Allow activity to display icons on the desktop and enter the software when you click on the icon
<category android:name= "Android.intent.category.LAUNCHER"/>
Advanced features of mobile AV 9--video player (2)