Android多媒体框架(multimedia framework)
> Note: You can play back the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call.
Wake Lock Permission - If your player application needs to keep the screen from dimming or the processor from sleeping, or uses the MediaPlayer.setScreenOnWhilePlaying()
or MediaPlayer.setWakeMode()
methods, you must request this permission.
> To avoid hanging your UI thread, spawn another thread to prepare the MediaPlayer
and notify the main thread when done.
Another aspect of a MediaPlayer
that you should keep in mind is that it's state-based.
> At that point, as the diagram illustrates, you can move between the Started, Paused andPlaybackCompleted states by calling such methods as start()
, pause()
, and seekTo()
, amongst others. When you call stop()
, however, notice that you cannot call start()
again until you prepare the MediaPlayer
again.
<待续>