Android MediaPlayer Architecture — Introduction (1)

Source location of Java mediaplayer class: frameworks \ base \ media \ Java \ Android \ media \ mediaplayer.java

Let's first look at its constructor:

When the mediaplayer object is instantiated, a native will be called_ Setup method:

The corresponding native function can be found in the JNI code (frameworks \ base \ media \ JNI \ android_media_mediaplayer. CPP):

In JNI, you can see that SP < mediaplayer > MP = new mediaplayer(), the native mediaplayer, interacts with the media service to realize the real playback function.

Android in JNI function_ media_ MediaPlayer_ native_ In setup, a listener is set for mediaplayer to upload player events to the Java layer through callback so that users can handle them accordingly

Invalid Sign

In JNI code, jnimedia playerlistener class is a subclass of mediaplayerlistener, which implements the notify function. Its definition is as follows:

The transfer of callback events is mainly completed through the notify function. Let's take a look at the specific implementation process of this function:

The content of this article is very simple. It mainly has a basic understanding and understanding of how to associate the mediaplayer of Java layer, JNI layer and mediaplayer of native layer.

A brief two-point overview:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>