Android MediaPlayer

来源:互联网 发布:c语言数组程序设计例题 编辑:程序博客网 时间:2024/05/11 18:16

Method Name

Valid Sates

Invalid States

Comments

attachAuxEffect

{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Idle, Error}

This method must be called after setDataSource. Calling it does not change the object state.

getAudioSessionId

any

{}

This method can be called in any state and calling it does not change the object state.

getCurrentPosition

{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

getDuration

{Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

getVideoHeight

{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

getVideoWidth

{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

isPlaying

{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

pause

{Started, Paused, PlaybackCompleted}

{Idle, Initialized, Prepared, Stopped, Error}

Successful invoke of this method in a valid state transfers the object to the Paused state. Calling this method in an invalid state transfers the object to the Error state.

prepare

{Initialized, Stopped}

{Idle, Prepared, Started, Paused, PlaybackCompleted, Error}

Successful invoke of this method in a valid state transfers the object to the Prepared state. Calling this method in an invalid state throws an IllegalStateException.

prepareAsync

{Initialized, Stopped}

{Idle, Prepared, Started, Paused, PlaybackCompleted, Error}

Successful invoke of this method in a valid state transfers the object to the Preparing state. Calling this method in an invalid state throws an IllegalStateException.

release

any

{}

After release(), the object is no longer available.

reset

{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}

{}

After reset(), the object is like being just created.

seekTo

{Prepared, Started, Paused, PlaybackCompleted}

{Idle, Initialized, Stopped, Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

setAudioSessionId

{Idle}

{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}

This method must be called in idle state as the audio session ID must be known before calling setDataSource. Calling it does not change the object state.

setAudioStreamType

{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}

{Error}

Successful invoke of this method does not change the state. In order for the target audio stream type to become effective, this method must be called before prepare() or prepareAsync().

setAuxEffectSendLevel

any

{}

Calling this method does not change the object state.

setDataSource

{Idle}

{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}

Successful invoke of this method in a valid state transfers the object to the Initialized state. Calling this method in an invalid state throws an IllegalStateException.

setDisplay

any

{}

This method can be called in any state and calling it does not change the object state.

setSurface

any

{}

This method can be called in any state and calling it does not change the object state.

setVideoScalingMode

{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}

{Idle, Error}

Successful invoke of this method does not change the state.

setLooping

{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}

{Error}

Successful invoke of this method in a valid state does not change the state. Calling this method in an invalid state transfers the object to the Error state.

isLooping

any

{}

This method can be called in any state and calling it does not change the object state.

setOnBufferingUpdateListener

any

{}

This method can be called in any state and calling it does not change the object state.

setOnCompletionListener

any

{}

This method can be called in any state and calling it does not change the object state.

setOnErrorListener

any

{}

This method can be called in any state and calling it does not change the object state.

setOnPreparedListener

any

{}

This method can be called in any state and calling it does not change the object state.

setOnSeekCompleteListener

any

{}

This method can be called in any state and calling it does not change the object state.

setScreenOnWhilePlayingany

{}

This method can be called in any state and calling it does not change the object state.

setVolume

{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}

{Error}

Successful invoke of this method does not change the state.setWakeMode

any

{}

This method can be called in any state and calling it does not change the object state.

start

{Prepared, Started, Paused, PlaybackCompleted}

{Idle, Initialized, Stopped, Error}

Successful invoke of this method in a valid state transfers the object to the Started state. Calling this method in an invalid state transfers the object to the Error state.

stop

{Prepared, Started, Stopped, Paused, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method in a valid state transfers the object to the Stopped state. Calling this method in an invalid state transfers the object to the Error state.

getTrackInfo

{Prepared, Started, Stopped, Paused, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method does not change the state.

addTimedTextSource

{Prepared, Started, Stopped, Paused, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method does not change the state.

selectTrack

{Prepared, Started, Stopped, Paused, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method does not change the state.

deselectTrack

{Prepared, Started, Stopped, Paused, PlaybackCompleted}

{Idle, Initialized, Error}

Successful invoke of this method does not change the state.Public MethodsvoidaddTimedTextSource(Context context, Uri uri, String mimeType)
Adds an external timed text source file (Uri).
voidaddTimedTextSource(String path, String mimeType)
Adds an external timed text source file.
voidaddTimedTextSource(FileDescriptor fd, long offset, long length, String mimeType)
Adds an external timed text file (FileDescriptor).
voidaddTimedTextSource(FileDescriptor fd, String mimeType)
Adds an external timed text source file (FileDescriptor).
voidattachAuxEffect(int effectId)
Attaches an auxiliary effect to the player.
static MediaPlayercreate(Context context, Uri uri, SurfaceHolder holder)
Convenience method to create a MediaPlayer for a given Uri.
static MediaPlayercreate(Context context, int resid)
Convenience method to create a MediaPlayer for a given resource id.
static MediaPlayercreate(Context context, Uri uri)
Convenience method to create a MediaPlayer for a given Uri.
voiddeselectTrack(int index)
Deselect a track.
intgetAudioSessionId()
Returns the audio session ID.
intgetCurrentPosition()
Gets the current playback position.
intgetDuration()
Gets the duration of the file.
TrackInfo[]getTrackInfo()
Returns an array of track information.
intgetVideoHeight()
Returns the height of the video.
intgetVideoWidth()
Returns the width of the video.
booleanisLooping()
Checks whether the MediaPlayer is looping or non-looping.
booleanisPlaying()
Checks whether the MediaPlayer is playing.
voidpause()
Pauses playback.
voidprepare()
Prepares the player for playback, synchronously.
voidprepareAsync()
Prepares the player for playback, asynchronously.
voidrelease()
Releases resources associated with this MediaPlayer object.
voidreset()
Resets the MediaPlayer to its uninitialized state.
voidseekTo(int msec)
Seeks to specified time position.
voidselectTrack(int index)
Selects a track.
voidsetAudioSessionId(int sessionId)
Sets the audio session ID.
voidsetAudioStreamType(int streamtype)
Sets the audio stream type for this MediaPlayer.
voidsetAuxEffectSendLevel(float level)
Sets the send level of the player to the attached auxiliary effect .
voidsetDataSource(String path)
Sets the data source (file-path or http/rtsp URL) to use.
voidsetDataSource(Context context, Uri uri, Map<String, String> headers)
Sets the data source as a content Uri.
voidsetDataSource(Context context, Uri uri)
Sets the data source as a content Uri.
voidsetDataSource(FileDescriptor fd, long offset, long length)
Sets the data source (FileDescriptor) to use.
voidsetDataSource(FileDescriptor fd)
Sets the data source (FileDescriptor) to use.
voidsetDisplay(SurfaceHolder sh)
Sets the SurfaceHolder to use for displaying the video portion of the media.
voidsetLooping(boolean looping)
Sets the player to be looping or non-looping.
voidsetNextMediaPlayer(MediaPlayer next)
Set the MediaPlayer to start when this MediaPlayer finishes playback (i.e.
voidsetOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener listener)
Register a callback to be invoked when the status of a network stream's buffer has changed.
voidsetOnCompletionListener(MediaPlayer.OnCompletionListener listener)
Register a callback to be invoked when the end of a media source has been reached during playback.
voidsetOnErrorListener(MediaPlayer.OnErrorListener listener)
Register a callback to be invoked when an error has happened during an asynchronous operation.
voidsetOnInfoListener(MediaPlayer.OnInfoListener listener)
Register a callback to be invoked when an info/warning is available.
voidsetOnPreparedListener(MediaPlayer.OnPreparedListener listener)
Register a callback to be invoked when the media source is ready for playback.
voidsetOnSeekCompleteListener(MediaPlayer.OnSeekCompleteListener listener)
Register a callback to be invoked when a seek operation has been completed.
voidsetOnTimedTextListener(MediaPlayer.OnTimedTextListener listener)
Register a callback to be invoked when a timed text is available for display.
voidsetOnVideoSizeChangedListener(MediaPlayer.OnVideoSizeChangedListener listener)
Register a callback to be invoked when the video size is known or updated.
voidsetScreenOnWhilePlaying(boolean screenOn)
Control whether we should use the attached SurfaceHolder to keep the screen on while video playback is occurring.
voidsetSurface(Surface surface)
Sets the Surface to be used as the sink for the video portion of the media.
voidsetVideoScalingMode(int mode)
Sets video scaling mode.
voidsetVolume(float leftVolume, float rightVolume)
Sets the volume on this player.
voidsetWakeMode(Context context, int mode)
Set the low-level power management behavior for this MediaPlayer.
voidstart()
Starts or resumes playback.
voidstop()
Stops playback after playback has been stopped or paused.

0 0
原创粉丝点击