MediaPlayer Class

Definition

MediaPlayer class can be used to control playback of audio/video files and streams.

[Android.Runtime.Register("android/media/MediaPlayer", DoNotGenerateAcw=true)]
public class MediaPlayer : Java.Lang.Object, Android.Media.IAudioRouting, Android.Media.IVolumeAutomation, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/media/MediaPlayer", DoNotGenerateAcw=true)>]
type MediaPlayer = class
    inherit Object
    interface IAudioRouting
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IVolumeAutomation
Inheritance
MediaPlayer
Attributes
Implements

Remarks

MediaPlayer class can be used to control playback of audio/video files and streams.

MediaPlayer is not thread-safe. Creation of and all access to player instances should be on the same thread. If registering callbacks, the thread must have a Looper.

Topics covered here are: <ol> <li>State Diagram<li>Valid and Invalid States<li>Permissions<li>Register informational and error callbacks</ol>

<div class="special reference"> <h3>Developer Guides</h3>

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

</div>

"StateDiagram"><h3>State Diagram</h3>

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.

<img src="../../../images/mediaplayer_state_diagram.gif" alt="MediaPlayer State diagram" border="0" />

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

<ul> <li>When a MediaPlayer object is just created using new or after #reset() is called, it is in the <em>Idle</em> state; and after #release() is called, it is in the <em>End</em> state. Between these two states is the life cycle of the MediaPlayer object. <ul> <li>There is a subtle but important difference between a newly constructed MediaPlayer object and the MediaPlayer object after #reset() is called. It is a programming error to invoke methods such as #getCurrentPosition(), #getDuration(), #getVideoHeight(), #getVideoWidth(), #setAudioAttributes(AudioAttributes), #setLooping(boolean), #setVolume(float, float), #pause(), #start(), #stop(), #seekTo(long, int), #prepare() or #prepareAsync() in the <em>Idle</em> state for both cases. If any of these methods is called right after a MediaPlayer object is constructed, the user supplied callback method OnErrorListener.onError() won't be called by the internal player engine and the object state remains unchanged; but if these methods are called right after #reset(), the user supplied callback method OnErrorListener.onError() will be invoked by the internal player engine and the object will be transfered to the <em>Error</em> state. </li> <li>You must keep a reference to a MediaPlayer instance to prevent it from being garbage collected. If a MediaPlayer instance is garbage collected, #release will be called, causing any ongoing playback to stop. <li>You must call #release() once you have finished using an instance to release acquired resources, such as memory and codecs. Once you have called #release, you must no longer interact with the released instance. <li>MediaPlayer objects created using new is in the <em>Idle</em> state, while those created with one of the overloaded convenient create methods are <em>NOT</em> in the <em>Idle</em> state. In fact, the objects are in the <em>Prepared</em> state if the creation using create method is successful. </li> </ul> </li> <li>In general, some playback control operation may fail due to various reasons, such as unsupported audio/video format, poorly interleaved audio/video, resolution too high, streaming timeout, and the like. Thus, error reporting and recovery is an important concern under these circumstances. Sometimes, due to programming errors, invoking a playback control operation in an invalid state may also occur. Under all these error conditions, the internal player engine invokes a user supplied OnErrorListener.onError() method if an OnErrorListener has been registered beforehand via #setOnErrorListener(android.media.MediaPlayer.OnErrorListener). <ul> <li>It is important to note that once an error occurs, the MediaPlayer object enters the <em>Error</em> state (except as noted above), even if an error listener has not been registered by the application.</li> <li>In order to reuse a MediaPlayer object that is in the <em> Error</em> state and recover from the error, #reset() can be called to restore the object to its <em>Idle</em> state.</li> <li>It is good programming practice to have your application register a OnErrorListener to look out for error notifications from the internal player engine.</li> <li>IllegalStateException is thrown to prevent programming errors such as calling #prepare(), #prepareAsync(), or one of the overloaded setDataSource methods in an invalid state. </li> </ul> </li> <li>Calling #setDataSource(FileDescriptor), or #setDataSource(String), or #setDataSource(Context, Uri), or #setDataSource(FileDescriptor, long, long), or #setDataSource(MediaDataSource) transfers a MediaPlayer object in the <em>Idle</em> state to the <em>Initialized</em> state. <ul> <li>An IllegalStateException is thrown if setDataSource() is called in any other state.</li> <li>It is good programming practice to always look out for IllegalArgumentException and IOException that may be thrown from the overloaded setDataSource methods.</li> </ul> </li> <li>A MediaPlayer object must first enter the <em>Prepared</em> state before playback can be started. <ul> <li>There are two ways (synchronous vs. asynchronous) that the <em>Prepared</em> state can be reached: either a call to #prepare() (synchronous) which transfers the object to the <em>Prepared</em> state once the method call returns, or a call to #prepareAsync() (asynchronous) which first transfers the object to the <em>Preparing</em> state after the call returns (which occurs almost right away) while the internal player engine continues working on the rest of preparation work until the preparation work completes. When the preparation completes or when #prepare() call returns, the internal player engine then calls a user supplied callback method, onPrepared() of the OnPreparedListener interface, if an OnPreparedListener is registered beforehand via #setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener).</li> <li>It is important to note that the <em>Preparing</em> state is a transient state, and the behavior of calling any method with side effect while a MediaPlayer object is in the <em>Preparing</em> state is undefined.</li> <li>An IllegalStateException is thrown if #prepare() or #prepareAsync() is called in any other state.</li> <li>While in the <em>Prepared</em> state, properties such as audio/sound volume, screenOnWhilePlaying, looping can be adjusted by invoking the corresponding set methods.</li> </ul> </li> <li>To start the playback, #start() must be called. After #start() returns successfully, the MediaPlayer object is in the <em>Started</em> state. #isPlaying() can be called to test whether the MediaPlayer object is in the <em>Started</em> state. <ul> <li>While in the <em>Started</em> state, the internal player engine calls a user supplied OnBufferingUpdateListener.onBufferingUpdate() callback method if a OnBufferingUpdateListener has been registered beforehand via #setOnBufferingUpdateListener(OnBufferingUpdateListener). This callback allows applications to keep track of the buffering status while streaming audio/video.</li> <li>Calling #start() has no effect on a MediaPlayer object that is already in the <em>Started</em> state.</li> </ul> </li> <li>Playback can be paused and stopped, and the current playback position can be adjusted. Playback can be paused via #pause(). When the call to #pause() returns, the MediaPlayer object enters the <em>Paused</em> state. Note that the transition from the <em>Started</em> state to the <em>Paused</em> state and vice versa happens asynchronously in the player engine. It may take some time before the state is updated in calls to #isPlaying(), and it can be a number of seconds in the case of streamed content. <ul> <li>Calling #start() to resume playback for a paused MediaPlayer object, and the resumed playback position is the same as where it was paused. When the call to #start() returns, the paused MediaPlayer object goes back to the <em>Started</em> state.</li> <li>Calling #pause() has no effect on a MediaPlayer object that is already in the <em>Paused</em> state.</li> </ul> </li> <li>Calling #stop() stops playback and causes a MediaPlayer in the <em>Started</em>, <em>Paused</em>, <em>Prepared </em> or <em>PlaybackCompleted</em> state to enter the <em>Stopped</em> state. <ul> <li>Once in the <em>Stopped</em> state, playback cannot be started until #prepare() or #prepareAsync() are called to set the MediaPlayer object to the <em>Prepared</em> state again.</li> <li>Calling #stop() has no effect on a MediaPlayer object that is already in the <em>Stopped</em> state.</li> </ul> </li> <li>The playback position can be adjusted with a call to #seekTo(long, int). <ul> <li>Although the asynchronuous #seekTo(long, int) call returns right away, the actual seek operation may take a while to finish, especially for audio/video being streamed. When the actual seek operation completes, the internal player engine calls a user supplied OnSeekComplete.onSeekComplete() if an OnSeekCompleteListener has been registered beforehand via #setOnSeekCompleteListener(OnSeekCompleteListener).</li> <li>Please note that #seekTo(long, int) can also be called in the other states, such as <em>Prepared</em>, <em>Paused</em> and <em>PlaybackCompleted </em> state. When #seekTo(long, int) is called in those states, one video frame will be displayed if the stream has video and the requested position is valid. </li> <li>Furthermore, the actual current playback position can be retrieved with a call to #getCurrentPosition(), which is helpful for applications such as a Music player that need to keep track of the playback progress.</li> </ul> </li> <li>When the playback reaches the end of stream, the playback completes. <ul> <li>If the looping mode was being set to <var>true</var> with #setLooping(boolean), the MediaPlayer object shall remain in the <em>Started</em> state.</li> <li>If the looping mode was set to <var>false </var>, the player engine calls a user supplied callback method, OnCompletion.onCompletion(), if a OnCompletionListener is registered beforehand via #setOnCompletionListener(OnCompletionListener). The invoke of the callback signals that the object is now in the <em> PlaybackCompleted</em> state.</li> <li>While in the <em>PlaybackCompleted</em> state, calling #start() can restart the playback from the beginning of the audio/video source.</li> </ul>

"Valid_and_Invalid_States"><h3>Valid and invalid states</h3>

<table border="0" cellspacing="0" cellpadding="0"> <tr><td>Method Name </p></td> <td>Valid States </p></td> <td>Invalid States </p></td> <td>Comments </p></td></tr> <tr><td>attachAuxEffect </p></td> <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Idle, Error}</p></td> <td>This method must be called after setDataSource. Calling it does not change the object state. </p></td></tr> <tr><td>getAudioSessionId </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>getCurrentPosition </p></td> <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>getDuration </p></td> <td>{Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>getVideoHeight </p></td> <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>getVideoWidth </p></td> <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>isPlaying </p></td> <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>pause </p></td> <td>{Started, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Prepared, Stopped, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Paused</em> state. Calling this method in an invalid state transfers the object to the <em>Error</em> state.</p></td></tr> <tr><td>prepare </p></td> <td>{Initialized, Stopped}</p></td> <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Prepared</em> state. Calling this method in an invalid state throws an IllegalStateException.</p></td></tr> <tr><td>prepareAsync </p></td> <td>{Initialized, Stopped}</p></td> <td>{Idle, Prepared, Started, Paused, PlaybackCompleted, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Preparing</em> state. Calling this method in an invalid state throws an IllegalStateException.</p></td></tr> <tr><td>release </p></td> <td>any </p></td> <td>{}</p></td> <td>After #release(), you must not interact with the object. </p></td></tr> <tr><td>reset </p></td> <td>{Idle, Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}</p></td> <td>{}</p></td> <td>After #reset(), the object is like being just created.</p></td></tr> <tr><td>seekTo </p></td> <td>{Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Stopped, Error}</p></td> <td>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 <em>Error</em> state. </p></td></tr> <tr><td>setAudioAttributes </p></td> <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>Successful invoke of this method does not change the state. In order for the target audio attributes type to become effective, this method must be called before prepare() or prepareAsync().</p></td></tr> <tr><td>setAudioSessionId </p></td> <td>{Idle}</p></td> <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}</p></td> <td>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. </p></td></tr> <tr><td>setAudioStreamType (deprecated)</p></td> <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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().</p></td></tr> <tr><td>setAuxEffectSendLevel </p></td> <td>any</p></td> <td>{}</p></td> <td>Calling this method does not change the object state. </p></td></tr> <tr><td>setDataSource </p></td> <td>{Idle}</p></td> <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Initialized</em> state. Calling this method in an invalid state throws an IllegalStateException.</p></td></tr> <tr><td>setDisplay </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setSurface </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setVideoScalingMode </p></td> <td>{Initialized, Prepared, Started, Paused, Stopped, PlaybackCompleted}</p></td> <td>{Idle, Error}</p></td> <td>Successful invoke of this method does not change the state.</p></td></tr> <tr><td>setLooping </p></td> <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>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 <em>Error</em> state.</p></td></tr> <tr><td>isLooping </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setOnBufferingUpdateListener </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setOnCompletionListener </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setOnErrorListener </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setOnPreparedListener </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setOnSeekCompleteListener </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setPlaybackParams</p></td> <td>{Initialized, Prepared, Started, Paused, PlaybackCompleted, Error}</p></td> <td>{Idle, Stopped}</p></td> <td>This method will change state in some cases, depending on when it's called. </p></td></tr> <tr><td>setScreenOnWhilePlaying</></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state. </p></td></tr> <tr><td>setVolume </p></td> <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Error}</p></td> <td>Successful invoke of this method does not change the state. <tr><td>setWakeMode </p></td> <td>any </p></td> <td>{}</p></td> <td>This method can be called in any state and calling it does not change the object state.</p></td></tr> <tr><td>start </p></td> <td>{Prepared, Started, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Stopped, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Started</em> state. Calling this method in an invalid state transfers the object to the <em>Error</em> state.</p></td></tr> <tr><td>stop </p></td> <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>Successful invoke of this method in a valid state transfers the object to the <em>Stopped</em> state. Calling this method in an invalid state transfers the object to the <em>Error</em> state.</p></td></tr> <tr><td>getTrackInfo </p></td> <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>Successful invoke of this method does not change the state.</p></td></tr> <tr><td>addTimedTextSource </p></td> <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>Successful invoke of this method does not change the state.</p></td></tr> <tr><td>selectTrack </p></td> <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>Successful invoke of this method does not change the state.</p></td></tr> <tr><td>deselectTrack </p></td> <td>{Prepared, Started, Stopped, Paused, PlaybackCompleted}</p></td> <td>{Idle, Initialized, Error}</p></td> <td>Successful invoke of this method does not change the state.</p></td></tr>

</table>

"Permissions"><h3>Permissions</h3>

One may need to declare a corresponding WAKE_LOCK permission android.R.styleable#AndroidManifestUsesPermission &lt;uses-permission&gt; element.

This class requires the android.Manifest.permission#INTERNET permission when used with network-based content.

"Callbacks"><h3>Callbacks</h3>

Applications may want to register for informational and error events in order to be informed of some internal state update and possible runtime errors during playback or streaming. Registration for these events is done by properly setting the appropriate listeners (via calls to #setOnPreparedListener(OnPreparedListener) setOnPreparedListener, #setOnVideoSizeChangedListener(OnVideoSizeChangedListener) setOnVideoSizeChangedListener, #setOnSeekCompleteListener(OnSeekCompleteListener) setOnSeekCompleteListener, #setOnCompletionListener(OnCompletionListener) setOnCompletionListener, #setOnBufferingUpdateListener(OnBufferingUpdateListener) setOnBufferingUpdateListener, #setOnInfoListener(OnInfoListener) setOnInfoListener, #setOnErrorListener(OnErrorListener) setOnErrorListener, etc). In order to receive the respective callback associated with these listeners, applications are required to create MediaPlayer objects on a thread with its own Looper running (main UI thread by default has a Looper running).

Java documentation for android.media.MediaPlayer.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

MediaPlayer()

Default constructor.

MediaPlayer(Context)

Default constructor with context.

MediaPlayer(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

MediaErrorIo
MediaErrorMalformed
MediaErrorTimedOut
MediaErrorUnsupported
MediaMimetypeTextSubrip

MIME type for SubRip (SRT) container.

VideoScalingModeScaleToFit
Obsolete.

Specifies a video scaling mode.

VideoScalingModeScaleToFitWithCropping
Obsolete.

Specifies a video scaling mode.

Properties

AudioSessionId

Returns the audio session ID. -or- Sets the audio session ID.

Class

Returns the runtime class of this Object.

(Inherited from Object)
CurrentPosition

Gets the current playback position.

Duration

Gets the duration of the file.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsPlaying

Checks whether the MediaPlayer is playing.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Looping

Checks whether the MediaPlayer is looping or non-looping. -or- Sets the player to be looping or non-looping.

Metrics

Return Metrics data about the current player.

PeerReference (Inherited from Object)
PlaybackParams

Gets the playback params, containing the current playback rate. -or- Sets playback rate using PlaybackParams.

PreferredDevice

Returns the selected output specified by #setPreferredDevice.

RoutedDevice

Returns an AudioDeviceInfo identifying the current routing of this MediaPlayer Note: The query is only valid if the MediaPlayer is currently playing.

SyncParams

Gets the A/V sync mode. -or- Sets A/V sync mode.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Timestamp

Get current playback position as a MediaTimestamp.

VideoHeight

Returns the height of the video.

VideoWidth

Returns the width of the video.

Methods

AddOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener, Handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this MediaPlayer.

AddTimedTextSource(Context, Uri, String)

Adds an external timed text source file (Uri).

AddTimedTextSource(FileDescriptor, Int64, Int64, String)

Adds an external timed text file (FileDescriptor).

AddTimedTextSource(FileDescriptor, String)

Adds an external timed text source file (FileDescriptor).

AddTimedTextSource(String, String)

Adds an external timed text source file.

AttachAuxEffect(Int32)

Attaches an auxiliary effect to the player.

ClearOnMediaTimeDiscontinuityListener()

Clears the listener previously set with #setOnMediaTimeDiscontinuityListener(OnMediaTimeDiscontinuityListener) or #setOnMediaTimeDiscontinuityListener(OnMediaTimeDiscontinuityListener, Handler)

ClearOnSubtitleDataListener()

Clears the listener previously set with #setOnSubtitleDataListener(OnSubtitleDataListener) or #setOnSubtitleDataListener(OnSubtitleDataListener, Handler).

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Create(Context, Int32, AudioAttributes, Int32)

Same factory method as #create(Context, int) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Create(Context, Int32)

Convenience method to create a MediaPlayer for a given resource id.

Create(Context, Uri, ISurfaceHolder, AudioAttributes, Int32)

Same factory method as #create(Context, Uri, SurfaceHolder) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Create(Context, Uri, ISurfaceHolder)

Convenience method to create a MediaPlayer for a given Uri.

Create(Context, Uri)

Convenience method to create a MediaPlayer for a given Uri.

CreateVolumeShaper(VolumeShaper+Configuration)
DeselectTrack(Int32)

Deselect a track.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetDrmInfo()

Retrieves the DRM Info associated with the current source

GetDrmPropertyString(String)

Read a DRM engine plugin String property value, given the property name string.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetKeyRequest(Byte[], Byte[], String, MediaDrmKeyType, IDictionary<String,String>)

A key request/response exchange occurs between the app and a license server to obtain or release keys used to decrypt encrypted content.

GetSelectedTrack(MediaTrackType)

Returns the index of the audio, video, or subtitle track currently selected for playback, The return value is an index into the array returned by #getTrackInfo(), and can be used in calls to #selectTrack(int) or #deselectTrack(int).

GetTrackInfo()

Returns an array of track information.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Pause()

Pauses playback.

Prepare()

Prepares the player for playback, synchronously.

PrepareAsync()

Prepares the player for playback, asynchronously.

PrepareDrm(UUID)

Prepares the DRM for the current source

ProvideKeyResponse(Byte[], Byte[])

A key response is received from the license server by the app, then it is provided to the DRM engine plugin using provideKeyResponse.

Release()

Releases resources associated with this MediaPlayer object.

ReleaseDrm()

Releases the DRM session

RemoveOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

Reset()

Resets the MediaPlayer to its uninitialized state.

RestoreKeys(Byte[])

Restore persisted offline keys into a new session.

SeekTo(Int32)

Seeks to specified time position.

SeekTo(Int64, MediaPlayerSeekMode)

Moves the media to specified time position by considering the given mode.

SelectTrack(Int32)

Selects a track.

SetAudioAttributes(AudioAttributes)

Sets the audio attributes for this MediaPlayer.

SetAudioStreamType(Stream)

Sets the audio stream type for this MediaPlayer.

SetAuxEffectSendLevel(Single)

Sets the send level of the player to the attached auxiliary effect.

SetDataSource(AssetFileDescriptor)

Sets the data source (AssetFileDescriptor) to use.

SetDataSource(Context, Uri, IDictionary<String,String>, IList<HttpCookie>)

Sets the data source as a content Uri.

SetDataSource(Context, Uri, IDictionary<String,String>)

Sets the data source as a content Uri.

SetDataSource(Context, Uri)

Sets the data source as a content Uri.

SetDataSource(FileDescriptor, Int64, Int64)

Sets the data source (FileDescriptor) to use.

SetDataSource(FileDescriptor)

Sets the data source (FileDescriptor) to use.

SetDataSource(MediaDataSource)

Sets the data source (MediaDataSource) to use.

SetDataSource(String)

Sets the data source (file-path or http/rtsp URL) to use.

SetDataSourceAsync(AssetFileDescriptor)
SetDataSourceAsync(Context, Uri, IDictionary<String,String>, IList<HttpCookie>)
SetDataSourceAsync(Context, Uri, IDictionary<String,String>)
SetDataSourceAsync(Context, Uri)
SetDataSourceAsync(FileDescriptor, Int64, Int64)
SetDataSourceAsync(FileDescriptor)
SetDataSourceAsync(MediaDataSource)
SetDataSourceAsync(String)
SetDisplay(ISurfaceHolder)

Sets the SurfaceHolder to use for displaying the video portion of the media.

SetDrmPropertyString(String, String)

Set a DRM engine plugin String property value.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetNextMediaPlayer(MediaPlayer)

Set the MediaPlayer to start when this MediaPlayer finishes playback (i.

SetOnBufferingUpdateListener(MediaPlayer+IOnBufferingUpdateListener)

Register a callback to be invoked when the status of a network stream's buffer has changed.

SetOnCompletionListener(MediaPlayer+IOnCompletionListener)

Register a callback to be invoked when the end of a media source has been reached during playback.

SetOnDrmConfigHelper(MediaPlayer+IOnDrmConfigHelper)

Register a callback to be invoked for configuration of the DRM object before the session is created.

SetOnDrmInfoListener(MediaPlayer+IOnDrmInfoListener, Handler)

Register a callback to be invoked when the DRM info is known.

SetOnDrmInfoListener(MediaPlayer+IOnDrmInfoListener)

Register a callback to be invoked when the DRM info is known.

SetOnDrmPreparedListener(MediaPlayer+IOnDrmPreparedListener, Handler)

Register a callback to be invoked when the DRM object is prepared.

SetOnDrmPreparedListener(MediaPlayer+IOnDrmPreparedListener)

Register a callback to be invoked when the DRM object is prepared.

SetOnErrorListener(MediaPlayer+IOnErrorListener)

Register a callback to be invoked when an error has happened during an asynchronous operation.

SetOnInfoListener(MediaPlayer+IOnInfoListener)

Register a callback to be invoked when an info/warning is available.

SetOnMediaTimeDiscontinuityListener(MediaPlayer+IOnMediaTimeDiscontinuityListener, Handler)

Sets the listener to be invoked when a media time discontinuity is encountered.

SetOnMediaTimeDiscontinuityListener(MediaPlayer+IOnMediaTimeDiscontinuityListener)

Sets the listener to be invoked when a media time discontinuity is encountered.

SetOnPreparedListener(MediaPlayer+IOnPreparedListener)

Register a callback to be invoked when the media source is ready for playback.

SetOnSeekCompleteListener(MediaPlayer+IOnSeekCompleteListener)

Register a callback to be invoked when a seek operation has been completed.

SetOnSubtitleDataListener(MediaPlayer+IOnSubtitleDataListener, Handler)

Sets the listener to be invoked when a subtitle track has new data available.

SetOnSubtitleDataListener(MediaPlayer+IOnSubtitleDataListener)

Sets the listener to be invoked when a subtitle track has new data available.

SetOnTimedMetaDataAvailableListener(MediaPlayer+IOnTimedMetaDataAvailableListener)

Register a callback to be invoked when a selected track has timed metadata available.

SetOnTimedTextListener(MediaPlayer+IOnTimedTextListener)

Register a callback to be invoked when a timed text is available for display.

SetOnVideoSizeChangedListener(MediaPlayer+IOnVideoSizeChangedListener)

Register a callback to be invoked when the video size is known or updated.

SetPreferredDevice(AudioDeviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the output from this MediaPlayer.

SetScreenOnWhilePlaying(Boolean)

Control whether we should use the attached SurfaceHolder to keep the screen on while video playback is occurring.

SetSurface(Surface)

Sets the Surface to be used as the sink for the video portion of the media.

SetVideoScalingMode(VideoScalingMode)

Sets video scaling mode.

SetVolume(Single, Single)

Sets the volume on this player.

SetWakeMode(Context, WakeLockFlags)

Set the low-level power management behavior for this MediaPlayer.

Start()

Starts or resumes playback.

Stop()

Stops playback after playback has been started or paused.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

BufferingUpdate
Completion
DrmInfoEvent
DrmPrepared
Error
Info
MediaTimeDiscontinuity
Prepared
RoutingChanged
SeekComplete
SubtitleData
TimedMetaDataAvailable
TimedText
VideoSizeChanged

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to