Java android.media MediaPlayer fields, constructors, methods, implement or subclass

Example usage for Java android.media MediaPlayer fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.media MediaPlayer.

The text is from its open source code.

Subclass

android.media.MediaPlayer has subclasses.
Click this link to see all its subclasses.

Field

intVIDEO_SCALING_MODE_SCALE_TO_FIT
Specifies a video scaling mode.
intMEDIA_ERROR_UNKNOWN
Unspecified media player error.
intMEDIA_ERROR_SERVER_DIED
Media server died.
intMEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK
The video is streamed and its container is not valid for progressive playback i.e the video's index (e.g moov atom) is not at the start of the file.
intMEDIA_ERROR_IO
File or network related operation errors.
intMEDIA_ERROR_MALFORMED
Bitstream is not conforming to the related coding standard or file spec.
intMEDIA_ERROR_UNSUPPORTED
Bitstream is conforming to the related coding standard or file spec, but the media framework does not support the feature.
intMEDIA_ERROR_TIMED_OUT
Some operation takes too long to complete, usually more than 3-5 seconds.
intMEDIA_INFO_UNKNOWN
Unspecified media player info.
intMEDIA_INFO_VIDEO_RENDERING_START
The player just pushed the very first video frame for rendering.
intMEDIA_INFO_VIDEO_TRACK_LAGGING
The video is too complex for the decoder: it can't decode frames fast enough.
intMEDIA_INFO_BUFFERING_START
MediaPlayer is temporarily pausing playback internally in order to buffer more data.
intMEDIA_INFO_BUFFERING_END
MediaPlayer is resuming playback after filling buffers.
intMEDIA_INFO_BAD_INTERLEAVING
Bad interleaving means that a media has been improperly interleaved or not interleaved at all, e.g has all the video samples first then all the audio ones.
intMEDIA_INFO_NOT_SEEKABLE
The media cannot be seeked (e.g live stream)
intMEDIA_INFO_METADATA_UPDATE
A new set of metadata is available.
intMEDIA_INFO_UNSUPPORTED_SUBTITLE
Subtitle track was not supported by the media framework.
intMEDIA_INFO_SUBTITLE_TIMED_OUT
Reading the subtitle track takes too long.

Constructor

MediaPlayer()
Default constructor.

Method

MediaPlayercreate(Context context, Uri uri)
Convenience method to create a MediaPlayer for a given Uri.
MediaPlayercreate(Context context, int resid)
Convenience method to create a MediaPlayer for a given resource id.
MediaPlayercreate(Context context, int resid, AudioAttributes audioAttributes, int audioSessionId)
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.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
intgetAudioSessionId()
Returns the audio session ID.
intgetCurrentPosition()
Gets the current playback position.
intgetDuration()
Gets the duration of the file.
PlaybackParamsgetPlaybackParams()
Gets the playback params, containing the current playback rate.
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.
voidsetAudioSessionId(int sessionId)
Sets the audio session ID.
voidsetAudioStreamType(int streamtype)
Sets the audio stream type for this MediaPlayer.
voidsetDataSource(String path)
Sets the data source (file-path or http/rtsp URL) to use.
voidsetDataSource(@NonNull AssetFileDescriptor afd)
Sets the data source (AssetFileDescriptor) to use.
voidsetDataSource(FileDescriptor fd)
Sets the data source (FileDescriptor) to use.
voidsetDataSource(MediaDataSource dataSource)
Sets the data source (MediaDataSource) to use.
voidsetDataSource(@NonNull Context context, @NonNull Uri uri)
Sets the data source as a content Uri.
voidsetDataSource(String path, Map headers)
Sets the data source (file-path or http/rtsp URL) to use.
voidsetDataSource(@NonNull Context context, @NonNull Uri uri, @Nullable Map headers)
Sets the data source as a content Uri.
voidsetDataSource(String path, Map headers, List cookies)
voidsetDataSource(FileDescriptor fd, long offset, long length)
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(OnBufferingUpdateListener listener)
Register a callback to be invoked when the status of a network stream's buffer has changed.
voidsetOnCompletionListener(OnCompletionListener listener)
Register a callback to be invoked when the end of a media source has been reached during playback.
voidsetOnErrorListener(OnErrorListener listener)
Register a callback to be invoked when an error has happened during an asynchronous operation.
voidsetOnInfoListener(OnInfoListener listener)
Register a callback to be invoked when an info/warning is available.
voidsetOnPreparedListener(OnPreparedListener listener)
Register a callback to be invoked when the media source is ready for playback.
voidsetOnSeekCompleteListener(OnSeekCompleteListener listener)
Register a callback to be invoked when a seek operation has been completed.
voidsetOnVideoSizeChangedListener(OnVideoSizeChangedListener listener)
Register a callback to be invoked when the video size is known or updated.
voidsetPlaybackParams(@NonNull PlaybackParams params)
Sets playback rate using PlaybackParams .
voidsetSurface(Surface surface)
Sets the Surface to be used as the sink for the video portion of the media.
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 started or paused.