@AnyThread public class MediaElement extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
MediaElement.Delegate
This interface allows apps to handle media events.
|
static class |
MediaElement.LoadProgressInfo
Data class that indicates infomation about a media load progress event.
|
static class |
MediaElement.Metadata
Data class with the Metadata associated to a Media Element.
|
Modifier and Type | Field and Description |
---|---|
protected MediaElement.Delegate |
mDelegate |
static int |
MEDIA_ERROR_ABORTED
The fetching of the associated resource was aborted by the user's request.
|
static int |
MEDIA_ERROR_DECODE
Despite having previously been determined to be usable,
an error occurred while trying to decode the media resource, resulting in an error.
|
static int |
MEDIA_ERROR_NETWORK
Some kind of network error occurred which prevented the media from being
successfully fetched, despite having previously been available.
|
static int |
MEDIA_ERROR_NETWORK_NO_SOURCE
Media source not found or unable to select any of the child elements
for playback during resource selection.
|
static int |
MEDIA_ERROR_SRC_NOT_SUPPORTED
The associated resource or media provider object has been found to be unsuitable.
|
static int |
MEDIA_READY_STATE_HAVE_CURRENT_DATA
Data is available for the current playback position,
but not enough to actually play more than one frame.
|
static int |
MEDIA_READY_STATE_HAVE_ENOUGH_DATA
Enough data is available—and the download rate is high enough that the media
can be played through to the end without interruption.
|
static int |
MEDIA_READY_STATE_HAVE_FUTURE_DATA
Data for the current playback position as well as for at least a little
bit of time into the future is available.
|
static int |
MEDIA_READY_STATE_HAVE_METADATA
Enough of the media resource has been retrieved that the metadata
attributes are available.
|
static int |
MEDIA_READY_STATE_HAVE_NOTHING
No information is available about the media resource.
|
static int |
MEDIA_STATE_ABORT
Sent when playback is aborted; for example, if the media is playing
and is restarted from the beginning, this event is sent.
|
static int |
MEDIA_STATE_EMPTIED
The media has become empty.
|
static int |
MEDIA_STATE_ENDED
Sent when playback completes.
|
static int |
MEDIA_STATE_PAUSE
Sent when the playback state is changed to paused.
|
static int |
MEDIA_STATE_PLAY
The media is no longer paused, as a result of the play method, or the autoplay attribute.
|
static int |
MEDIA_STATE_PLAYING
Sent when the media has enough data to start playing, after the play event,
but also when recovering from being stalled, when looping media restarts,
and after seeked, if it was playing before seeking.
|
static int |
MEDIA_STATE_SEEKED
Sent when a seek operation completes.
|
static int |
MEDIA_STATE_SEEKING
Sent when a seek operation begins.
|
static int |
MEDIA_STATE_STALLED
Sent when the user agent is trying to fetch media data,
but data is unexpectedly not forthcoming.
|
static int |
MEDIA_STATE_SUSPEND
Sent when loading of the media is suspended.
|
static int |
MEDIA_STATE_WAITING
Sent when the requested operation (such as playback) is delayed
pending the completion of another operation (such as a seek).
|
protected GeckoSession |
mSession |
protected long |
mVideoId |
Modifier and Type | Method and Description |
---|---|
MediaElement.Delegate |
getDelegate()
Gets the current the media callback handler.
|
void |
pause()
Pauses the media.
|
void |
play()
Plays the media.
|
void |
seek(double time)
Seek the media to a given time.
|
void |
setDelegate(MediaElement.Delegate delegate)
Sets the media callback handler.
|
void |
setMuted(boolean muted)
Mutes the media.
|
void |
setPlaybackRate(double playbackRate)
Sets the playback rate at which the media will be played.
|
void |
setVolume(double volume)
Set the volume at which the media will be played.
|
public static final int MEDIA_STATE_PLAY
public static final int MEDIA_STATE_PLAYING
public static final int MEDIA_STATE_PAUSE
public static final int MEDIA_STATE_ENDED
public static final int MEDIA_STATE_SEEKING
public static final int MEDIA_STATE_SEEKED
public static final int MEDIA_STATE_STALLED
public static final int MEDIA_STATE_SUSPEND
public static final int MEDIA_STATE_WAITING
public static final int MEDIA_STATE_ABORT
public static final int MEDIA_STATE_EMPTIED
public static final int MEDIA_READY_STATE_HAVE_NOTHING
public static final int MEDIA_READY_STATE_HAVE_METADATA
public static final int MEDIA_READY_STATE_HAVE_CURRENT_DATA
public static final int MEDIA_READY_STATE_HAVE_FUTURE_DATA
public static final int MEDIA_READY_STATE_HAVE_ENOUGH_DATA
public static final int MEDIA_ERROR_NETWORK_NO_SOURCE
public static final int MEDIA_ERROR_ABORTED
public static final int MEDIA_ERROR_NETWORK
public static final int MEDIA_ERROR_DECODE
public static final int MEDIA_ERROR_SRC_NOT_SUPPORTED
@NonNull protected final GeckoSession mSession
protected final long mVideoId
@Nullable protected MediaElement.Delegate mDelegate
@Nullable public MediaElement.Delegate getDelegate()
public void setDelegate(@Nullable MediaElement.Delegate delegate)
delegate
- An implementation of MediaDelegate.public void pause()
public void play()
public void seek(double time)
time
- Seek time in seconds.public void setVolume(double volume)
volume
- A Volume value. It must fall between 0 and 1, where 0 is effectively muted
and 1 is the loudest possible value.public void setMuted(boolean muted)
muted
- True in order to mute the audio.public void setPlaybackRate(double playbackRate)
playbackRate
- The rate at which the media will be played.
A value of 1.0 indicates normal speed.