public class

MediaController

extends DataStream
java.lang.Object
   ↳ org.ocast.core.DataStream
     ↳ org.ocast.core.media.MediaController

Class Overview

A dedicated DataStream that manages media control like playing a video, audio or loading picture

Summary

Nested Classes
interface MediaController.MediaControllerListener Provides informations on playback status (position, playing,...) and metadata (title, tracks,...)  
Public Constructors
MediaController(MediaController.MediaControllerListener listener)
Instanciate a MediaController
Public Methods
void getMetadata(Consumer<Metadata> onSuccess, Consumer<Throwable> onFailure)
Gets current media metadata.
void getPlaybackStatus(Consumer<PlaybackStatus> onSuccess, Consumer<Throwable> onFailure)
Gets current media status.
void mute(boolean enable, Runnable onSuccess, Consumer<Throwable> onFailure)
Mute the current playback
void onMessage(JSONObject message)
Subclass must implement this method to manage incoming messages
void pause(Runnable onSuccess, Consumer<Throwable> onFailure)
Pauses the current media playback
void play(double position, Runnable onSuccess, Consumer<Throwable> onFailure)
Plays the current media from a given position
void prepare(PrepareCommand command, Runnable onSuccess, Consumer<Throwable> onFailure)
Prepare a media playback
void resume(Runnable onSuccess, Consumer<Throwable> onFailure)
Resumes the current media playback
void seek(double position, Runnable onSuccess, Consumer<Throwable> onFailure)
Seeks the current media to a given position
void stop(Runnable onSuccess, Consumer<Throwable> onFailure)
Stops the current media playback
void track(Track track, Runnable onSuccess, Consumer<Throwable> onFailure)
enable or disable media Track track
void volume(double level, Runnable onSuccess, Consumer<Throwable> onFailure)
Sets the volume level
[Expand]
Inherited Methods
From class org.ocast.core.DataStream
From class java.lang.Object

Public Constructors

public MediaController (MediaController.MediaControllerListener listener)

Instanciate a MediaController

Parameters
listener the listener to be notified of metadata and playback status updates

Public Methods

public void getMetadata (Consumer<Metadata> onSuccess, Consumer<Throwable> onFailure)

Gets current media metadata.

Parameters
onSuccess to be called on success with the Metadata
onFailure to be called on error

public void getPlaybackStatus (Consumer<PlaybackStatus> onSuccess, Consumer<Throwable> onFailure)

Gets current media status.

Parameters
onSuccess to be called on success with the PlaybackStatus

public void mute (boolean enable, Runnable onSuccess, Consumer<Throwable> onFailure)

Mute the current playback

Parameters
enable true to mute, false to unmute

public void onMessage (JSONObject message)

Subclass must implement this method to manage incoming messages

Parameters
message the incoming message

public void pause (Runnable onSuccess, Consumer<Throwable> onFailure)

Pauses the current media playback

public void play (double position, Runnable onSuccess, Consumer<Throwable> onFailure)

Plays the current media from a given position

Parameters
position the position expressed as seconds since start

public void prepare (PrepareCommand command, Runnable onSuccess, Consumer<Throwable> onFailure)

Prepare a media playback

Parameters
command the data representing the media to be casted.
onSuccess to be called in case of success.
onFailure to be called in case of error

public void resume (Runnable onSuccess, Consumer<Throwable> onFailure)

Resumes the current media playback

public void seek (double position, Runnable onSuccess, Consumer<Throwable> onFailure)

Seeks the current media to a given position

Parameters
position the position expressed as seconds since start

public void stop (Runnable onSuccess, Consumer<Throwable> onFailure)

Stops the current media playback

public void track (Track track, Runnable onSuccess, Consumer<Throwable> onFailure)

enable or disable media Track track

Parameters
track the track information

public void volume (double level, Runnable onSuccess, Consumer<Throwable> onFailure)

Sets the volume level

Parameters
level a value in a [0..1] interval