1. MediaPlayer the files to be played mainly include 3 sources:
A. Resource resources that the user has in advance in the application
For example: MP = MediaPlayer. Create (This, R.raw. Test);
B. media files stored in an SD card or other file path
For example: MP. Setdatasource ("/sdcard/test.mp3");
C. media files on the network
For example: MP. Setdatasource ("Http://www.citynorth.cn/music/confucius.mp3");
2.
Release () frees the resource that the player occupies and should be called as soon as possible when the player is no longer in use.
Reset () Restores the player from the error state and resumes to the idle state.
Prepare () and Prepareasync () provide both synchronous and asynchronous settings for the player to enter the prepare state, and it is important to note that if the MediaPlayer instance was created by the Create method, It is not necessary to call prepare () again before the first start of playback, because the Create method has already been called.
Start () is a way to actually start a file playback.
Pause () and stop () are relatively simple and play a role in pausing and stopping playback.
Seekto () is a positioning method that allows the player to start playing from the specified position, noting that the method is an asynchronous method, which means that the method returns does not mean that the location is complete, especially the network file that is playing, which is triggered when the real location is completed.
3.
MediaPlayer provides several ways to set up different listeners to better monitor the working state of the player in order to handle situations in a timely manner.
such as: Setoncompletionlistener (Mediaplayer.oncompletionlistener listener),
Setonerrorlistener ( Mediaplayer.onerrorlistener listener) and so on, the player needs to be set up to take into account the possible situation of the player set up monitoring and processing logic to maintain the robustness of the player.