MediaPlayer

Class of android.media · MediaPlayer.java · Android's reference

public class MediaPlayer

Plays audio, through the runtime's audio (snx.android.media.Audio): prepare reads the source and opens a stream of it, which FFmpeg decodes as it plays. A source with no audio that decodes (a video's picture alone, a format the runtime lacks) prepares as a clip with no length, and its playback completes at once, so an app's flow goes on as after a short clip. No picture is drawn.

Nested types

Page 1 2

Fields

public static final int MEDIA_ERROR_UNKNOWN = 1 source
public static final int MEDIA_ERROR_SERVER_DIED = 100 source
public static final int MEDIA_ERROR_IO = -1004 source
public static final int MEDIA_ERROR_MALFORMED = -1007 source
public static final int MEDIA_ERROR_UNSUPPORTED = -1010 source
public static final int MEDIA_ERROR_TIMED_OUT = -110 source
public static final int MEDIA_INFO_UNKNOWN = 1 source
public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3 source
public static final int MEDIA_INFO_BUFFERING_START = 701 source
public static final int MEDIA_INFO_BUFFERING_END = 702 source
public static final int SEEK_PREVIOUS_SYNC = 0 source
public static final int SEEK_NEXT_SYNC = 1 source
public static final int SEEK_CLOSEST_SYNC = 2 source
public static final int SEEK_CLOSEST = 3 source

Constructors

public MediaPlayer() source

Methods

public static MediaPlayer create(Context context, Uri uri) source
public static MediaPlayer create(Context context, int resid) source
public void setDataSource(Context context, Uri uri) throws IOException source
public void setDataSource(String path) throws IOException source

A path, or a file: URI, is opened as Android opens it before its decoder sees it, so a missing file is FileNotFoundException; another scheme (http, rtsp) is taken as it is, with no audio. A drive's path ("C:\..." or "C:/...") is a path, not a URI of scheme "C": the app's files have such paths on a Windows host

public void setDataSource(FileDescriptor fd) throws IOException source
public void setDataSource(FileDescriptor fd, long offset, long length) throws IOException source
public void setDataSource(android.content.res.AssetFileDescriptor afd) throws IOException source
public void prepare() throws IOException source
public void prepareAsync() source
public void start() source
public void pause() source
public void stop() source
public void reset() source
public void release() source
public void seekTo(int msec) source
public void seekTo(long msec, int mode) source
public boolean isPlaying() source
public int getCurrentPosition() source
public int getDuration() source
public int getVideoWidth() source
public int getVideoHeight() source
public int getAudioSessionId() source
public void setAudioSessionId(int sessionId) source
public boolean isLooping() source
public void setLooping(boolean looping) source

Page 1 2


Made from ScarletNX's Sail at 166ad3910f80. The framework is ScarletNX's (GPL-3.0-or-later); the parts that follow the Android Open Source Project's sources (Apache-2.0) say so in their files.