Package org.mozilla.geckoview
Class MediaSession
Object
org.mozilla.geckoview.MediaSession
The MediaSession API provides media controls and events for a GeckoSession. This includes support
for the DOM Media Session API and regular HTML media content.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Implement this delegate to receive media session events.static class
The representation of a media element's metadata.static class
Flags for supported media session features.static class
The representation of a media session's metadata.static @interface
static class
Holds the details of the media session's playback state. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isActive()
Get whether the media session is active.void
muteAudio
(boolean mute) Set whether audio should be muted.void
Select and play the next track.void
pause()
Pause playback for the media session.void
play()
Start playback for the media session.void
Select and play the previous track.void
Seek backward by a sensible number of seconds.void
Seek forward by a sensible number of seconds.void
seekTo
(double time, boolean fast) Seek to a specific time.void
skipAd()
Skip the advertisement that is currently playing.void
stop()
Stop playback for the media session.
-
Constructor Details
-
MediaSession
-
-
Method Details
-
isActive
public boolean isActive()Get whether the media session is active. Only active media sessions can be controlled.Changes in the active state are notified via
MediaSession.Delegate.onActivated(org.mozilla.geckoview.GeckoSession, org.mozilla.geckoview.MediaSession)
andMediaSession.Delegate.onDeactivated(org.mozilla.geckoview.GeckoSession, org.mozilla.geckoview.MediaSession)
respectively.- Returns:
- True if this media session is active, false otherwise.
- See Also:
-
pause
public void pause()Pause playback for the media session. -
stop
public void stop()Stop playback for the media session. -
play
public void play()Start playback for the media session. -
seekTo
public void seekTo(double time, boolean fast) Seek to a specific time. Prefer using fast seeking when calling this in a sequence. Don't use fast seeking for the last or only call in a sequence.- Parameters:
time
- The time in seconds to move the playback time to.fast
- Whether fast seeking should be used.
-
seekForward
public void seekForward()Seek forward by a sensible number of seconds. -
seekBackward
public void seekBackward()Seek backward by a sensible number of seconds. -
nextTrack
public void nextTrack()Select and play the next track. Move playback to the next item in the playlist when supported. -
previousTrack
public void previousTrack()Select and play the previous track. Move playback to the previous item in the playlist when supported. -
skipAd
public void skipAd()Skip the advertisement that is currently playing. -
muteAudio
public void muteAudio(boolean mute) Set whether audio should be muted. Muting audio is supported by default and does not require the media session to be active.- Parameters:
mute
- True if audio for this media session should be muted.
-