Mediaplayer for learning Android development tutorial in 21 days

This article introduces the use of mediaplayer. Mediaplayer can play audio and video. In addition, it can also play video through videoview. Although videoview is simpler and easier to use than mediaplayer, it is not as customizable as mediaplayer. It depends on the situation. Mediaplayer is easy to play audio, but surfaceview is required to play video. Surfaceview has more drawing advantages than ordinary custom view. It supports the full OpenGL es library. First, post a screenshot of the running results of the program in this article. The above is playing / stopping audio, and seekbar can be used to adjust the progress. The following is playing / stopping video, and seekbar can also be used to adjust the progress:

Source code of main.xml:

The source code of this program is a little long:

The above is the first introduction to mediaplayer in the 21 day Android development tutorial. I hope it will be helpful to your study.

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
分享
二维码
< <上一篇
下一篇>>