Android media server Parsing 1-media player service structure, android1-media

Source: Internet
Author: User

Android media server Parsing 1-media player service structure, android1-media

The following is one of the four services registered by media server: structure diagram of MediaPlayerService

1. In the figure, the proxy object BpMediaPlayerService of MediaPlayerService is not found. For this part, refer to the Binder proxy object acquisition.

2. The figure mainly shows the MediaPlayer part of MeidaPlayerService. It can be seen that the MediaPlayer is created and the proxy object is obtained, if you have a wealth of imagination, you can basically guess the playing process of the MediaPlayer.

3. The next Weibo Post hopes to analyze the audio-related items during MediaPlayer playback.

4. If you cannot see or understand the figure, please contact us via email.


Why does android use service to play mediaplayer?

The activity you mentioned is actually executed in the background by default, so your concert is always running, but if I want to disable the activity and remove it from the system process directly, then you won't hear your music. Why do we need to open a service? Most people tend to do this. In the general programming mode mvc, most people tend to put service-oriented functions in the background for running. The service also has its specific functions, which can be separated from the activity or separately.

Android judges that the mediaplayer has been played in the service.

Add a listener for the MediaPlayer object after playing:

MMediaPlayer. setOnCompletionListener (new OnCompletionListener (){

@ Override
Public void onCompletion (MediaPlayer mp ){
Log. d ("tag", "playback completed ");
// Add your own code as needed...

}
});

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.