/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * MediaPlayer class can be used to control playback * of audio/video files and streams. An example on how to use the methods in * this class can be found in {@link android.widget.VideoView}. * *

Topics covered here are: *

    *
  1. State Diagram *
  2. Valid and Invalid States *
  3. Permissions *
  4. Register informational and error callbacks *
* *
*

Developer Guides

*

For more information about how to use MediaPlayer, read the * Media Playback developer guide.

*
* * *

State Diagram

* *

Playback control of audio/video files and streams is managed as a state * machine. The following diagram shows the life cycle and the states of a * MediaPlayer object driven by the supported playback control operations. * The ovals represent the states a MediaPlayer object may reside * in. The arcs represent the playback control operations that drive the object * state transition. There are two types of arcs. The arcs with a single arrow * head represent synchronous method calls, while those with * a double arrow head represent asynchronous method calls.

* *

MediaPlayer State diagram

* *

From this state diagram, one can see that a MediaPlayer object has the * following states:

*