This article translated from: http://developer.android.com/guide/topics/ui/index.html
Android Multimedia Framework supports playing a variety of popular media types, so it is easy to integrate audio, video, and images into applications. You can use mediaplayer APIs to play back media files (raw resources) stored in application resources, media files from independent file systems, or data streams over network connections.
This article describes how to write a media playback application that interacts with users, and how to enable the system to achieve good performance and user experience.
Note: Only the audio data can be played to the standard output device. At present, it is mainly mobile device microphones or Bluetooth headsets. Audio files cannot be played during audio sessions.
Basic
The following classes are used to play sound and video in the android framework:
Mediaplayer: this class is the main API for playing sound and video.
Audiomanager: This class manages audio resources and audio output on devices.
List Declaration
Before using mediaplayer for development on an application, make sure that the Application List contains declarations that allow the use of relevant functions.
1. Internet permission: to use mediaplayer to play Internet-based content streams, applications must apply for Internet access permissions.
<Uses-Permission Android: Name = "android. Permission. Internet"/>
2. wake lock permission: if the player application needs to remain in the dimming state, or sleep state of the processor, or use mediaplayer. setscreenonwhileplaying () or mediaplayer. the setwakemode () method must apply for this permission.
<Uses-permissionandroid: Name = "android. Permission. wake_lock"/>