com.adobe.mediacore
Interface MediaPlayer

All Known Implementing Classes:
DefaultMediaPlayer

public interface MediaPlayer


Nested Class Summary
static interface MediaPlayer.AdPlaybackEventListener
          Interface definition of a set of callback to be invoked during ad playback.
static interface MediaPlayer.DRMEventListener
          Interface definition of a callback to be invoked when protected metadata becomes available.
static class MediaPlayer.Event
          Event types.
static interface MediaPlayer.EventListener
          Marker interface used to unify event listener registration
static interface MediaPlayer.PlaybackEventListener
          Interface definition of a set of callback to be invoked during playback.
static class MediaPlayer.PlayerState
          The player status.
static interface MediaPlayer.QOSEventListener
          Interface definition of a set of callback to be invoked during QoS.
static class MediaPlayer.Visibility
           
 
Field Summary
static long LIVE_POINT
          Constant used to define client live point.
 
Method Summary
 void addEventListener(MediaPlayer.Event event, MediaPlayer.EventListener listener)
          Adds a new event listener for specified event type.
 BufferControlParameters getBufferControlParameters()
           
 TimeRange getBufferedRange()
          Returns the buffered range.
 TextFormat getCCStyle()
           
 MediaPlayer.Visibility getCCVisibility()
           
 MediaPlayerItem getCurrentItem()
          Gets the current media player item.
 long getCurrentTime()
          The current playhead time as reported by the underlying components.
 DRMManager getDRMManager()
           
 NotificationHistory getNotificationHistory()
           
 PlaybackMetrics getPlaybackMetrics()
           
 TimeRange getPlaybackRange()
           
 TimeRange getSeekableRange()
          Returns the seekable range
 MediaPlayer.PlayerState getStatus()
          Returns the media player status.
 Timeline getTimeline()
          The current timeline containing both main content and associated alternate content (ads).
 MediaPlayerView getView()
          Returns the view where the media player will render the images.
 void pause()
          Pauses the playback of the current media item.
 void play()
          Initiates or resumes the playback of the current media item.
 void prepareToPlay()
          Prepares to play the current selected item.
 void prepareToPlay(long position)
          Prepares to play the current selected item.
 void registerAdClientFactory(AdClientFactory adClientFactory)
          Sets a custom AdvertisingFactory to be used in the ad placement process.
 void release()
          Releases media player object.
 void removeEventListener(MediaPlayer.Event event, MediaPlayer.EventListener listener)
          Removes an existing event listener for specified event type.
 void replaceCurrentItem(MediaResource mediaResource)
          Replaces the current media item or sets one if none exists.
 void reset()
          Resets the media player to its uninitialized state.
 void seek(long position)
          Moves the play head to specified position.
 void setABRControlParameters(ABRControlParameters params)
          Set the parameters that control the playback of MBR content.
 void setBufferControlParameters(BufferControlParameters params)
          Set the parameters that control the media player buffer.
 void setCCStyle(TextFormat textFormat)
          Sets the closed captioning style.
 void setCCVisibility(MediaPlayer.Visibility visibility)
          Sets the visibility of closed captioning.
 void setVolume(int volume)
          Change the media player volume.
 

Field Detail

LIVE_POINT

static final long LIVE_POINT
Constant used to define client live point. This can be passed as a position parameter for seek operation for live playback and will readjust the playback position to the client live point. Using this constant for video on demand on a seek operation will cause a seek to the beginning of the content.

See Also:
Constant Field Values
Method Detail

prepareToPlay

void prepareToPlay()
                   throws IllegalStateException
Prepares to play the current selected item. If the client calls play() directly and the media item is not yet ready to play, the media player will invoke this method automatically. Calling this function will eventually lead to enter playback using default values Video on demand content will start at 0 and live streaming will start from the client live point.

Throws:
IllegalStateException - if the media player is not in initialized mode.

prepareToPlay

void prepareToPlay(long position)
                   throws IllegalStateException
Prepares to play the current selected item. If the client calls play() directly and the media item is not yet ready to play, the media player will invoke this method automatically. Calling this function will eventually lead to enter playback at a specified position that is contained in the seekable range. If the specified position is not contained in the seekable range, this position will be readjusted to the default starting values. For video on demand, the position will be readjusted to the beginning of the content. For live content, the position will be readjusted to the client live point.

Parameters:
position - Position to enter the stream
Throws:
IllegalStateException - if the media player is not in initialized mode.

play

void play()
          throws IllegalStateException
Initiates or resumes the playback of the current media item. If the current media item is not yet ready to play it will invoke prepareToPlay first. If the current media item was paused, then invoking this command will resume the playback from where it was paused, otherwise it will start the playback from the beginning. If the current media item was already playing, calling this method will have no effect.

Throws:
IllegalStateException - if the media player is in a state different from PAUSED, READY or PLAYING state.

pause

void pause()
           throws IllegalStateException
Pauses the playback of the current media item. If the current media item was already paused, calling this method will have no effect. In order to resume the playback of the current media item, call play() method.

Throws:
IllegalStateException - if the media player is in a state different from PAUSED, READY or PLAYING state.

seek

void seek(long position)
          throws IllegalStateException
Moves the play head to specified position. The actual start position after seek may be different than the desired one due additional rules which may apply. For example seeking in the middle of an ad is not permitted and in this case the seek position will be adjusted to the beginning of the ad. Live playback accepts the usage of constant LIVE_POINT. Passing this as a position will make a seek operation to the client live point contained in the live window. As a reference, the client live point moves in time and it should be situated at the end of the live window - buffer length - 3 * target duration. Using the LIVE_POINT for video on demand content will cause the player to readjust the position to the beginning of the content. Given a desired seek position that is not included in the seekable range will cause the desired seek position to be readjusted to the nearest limit of the seekable range (either beginning or end) Developers should listen for SEEK_COMPLETE notification which will provide the adjusted position.

Parameters:
position - the desired position from where to start the playback
Throws:
IllegalStateException - if the media player is in a state different from PAUSED, READY or PLAYING state.

reset

void reset()
           throws IllegalStateException
Resets the media player to its uninitialized state. After calling this method, you will have to initialize it again by setting the media player item through replaceCurrentItem() method and calling prepareToPlay() method.

Throws:
IllegalStateException - if the media player was already released.

release

void release()
Releases media player object. IMPORTANT! The media player being released can't be used anymore. Invoking any method of the media player once has been released will result in an IllegalStateException being thrown. It will release the underlying resources associated with this media player object. It is considered good practice to call this method when you're done using it. In addition to unnecessary resources being held, failure to call this method immediately if a media player object is no longer needed may also lead to continuous battery consumption for mobile devices, and playback failure for other applications if no multiple instances of the same codec are supported on a device.


replaceCurrentItem

void replaceCurrentItem(MediaResource mediaResource)
                        throws IllegalStateException
Replaces the current media item or sets one if none exists. Use this method to specify the media to be played. The media resource contains information about the stream URL to be played alongside metadata (such as ad breaks information). The prepareToPlay() should be called afterwards.

Parameters:
mediaResource - the media resource to be set
Throws:
IllegalStateException - if the media player was already released.

getPlaybackRange

TimeRange getPlaybackRange()
                           throws IllegalStateException
Returns:
the actual playback range of the stream or an empty range if stream is not yet processed. This range includes also the duration of any additional content inserted into the stream (ads).
Throws:
IllegalStateException - if media player was already released.

getSeekableRange

TimeRange getSeekableRange()
                           throws IllegalStateException
Returns the seekable range

Returns:
the actual seekable range of the stream or an empty range if stream is not yet processed. Seeking should be performed only to a position inside this range. This range includes also the duration of any additional content inserted into the stream (ads).
Throws:
IllegalStateException - IllegalStateException if media player was already released.

getCurrentTime

long getCurrentTime()
                    throws IllegalStateException
The current playhead time as reported by the underlying components. The playhead time is calculated relative to the resolved stream, one which can contain multiple ads inserted.

Returns:
the current playhead position or 0 if not available.
Throws:
IllegalStateException - if the media player was already released.

getBufferedRange

TimeRange getBufferedRange()
                           throws IllegalStateException
Returns the buffered range.

Returns:
a time range indicating the period already buffered locally.
Throws:
IllegalStateException - if the media player was already released.

getTimeline

Timeline getTimeline()
                     throws IllegalStateException
The current timeline containing both main content and associated alternate content (ads). The timeline can update over time as more and more alternate content is placed on it.

Returns:
the current timeline interface which can be used to iterate through timeline items.
Throws:
IllegalStateException - if the media player was already released.

getView

MediaPlayerView getView()
                        throws IllegalStateException
Returns the view where the media player will render the images.

Returns:
the media player view which can be positioned and scaled
Throws:
IllegalStateException - if the media player was already released.

getCurrentItem

MediaPlayerItem getCurrentItem()
                               throws IllegalStateException
Gets the current media player item.

Returns:
the media player item which can be used for querying or changing media characteristics.
Throws:
IllegalStateException - if the media player item is not yet available or the media player was already released.

getStatus

MediaPlayer.PlayerState getStatus()
                                  throws IllegalStateException
Returns the media player status.

Returns:
the current status of the media player.
Throws:
IllegalStateException - if media player was already released.

setVolume

void setVolume(int volume)
               throws IllegalStateException
Change the media player volume. Ranges from 0 (silent) to 100 (full volume).

Parameters:
volume - the desired volume value to be set.
Throws:
IllegalStateException - if media player was already released.

setABRControlParameters

void setABRControlParameters(ABRControlParameters params)
                             throws IllegalStateException
Set the parameters that control the playback of MBR content.

Parameters:
params - instance of the ABRControlParameters containing the MBR control parameters.
Throws:
IllegalStateException - if media player was already released.

setBufferControlParameters

void setBufferControlParameters(BufferControlParameters params)
                                throws IllegalStateException
Set the parameters that control the media player buffer.

Parameters:
params - instance of the BufferControlParameters, containing the initial buffer time and the player buffer time.
Throws:
IllegalStateException - if media player was already released.

getBufferControlParameters

BufferControlParameters getBufferControlParameters()
                                                   throws IllegalStateException
Returns:
the current buffer control parameters, containing the initial buffer time and the player buffer time.
Throws:
IllegalStateException - if media player was already released.

registerAdClientFactory

void registerAdClientFactory(AdClientFactory adClientFactory)
Sets a custom AdvertisingFactory to be used in the ad placement process. This factory can create a custom ad provider, to be used in the ad resolving. It can also set a custom ad opportunity detector, that iterates through the timed metadata and creates a list of PlacementOpportunity. This opportunities will be resolved by the ad provider.

Parameters:
adClientFactory - the custom ad client factory.

getCCVisibility

MediaPlayer.Visibility getCCVisibility()
                                       throws IllegalStateException
Returns:
the current status of closed captions visibility. VISIBLE if closed captions should be displayed when available, or INVISIBLE if otherwise.
Throws:
IllegalStateException - if media player was already released.

setCCVisibility

void setCCVisibility(MediaPlayer.Visibility visibility)
                     throws IllegalStateException
Sets the visibility of closed captioning. This method is safe to use even if the current media stream doesn't have closed captions.

Parameters:
visibility - setting this to VISIBLE it will trigger the display of closed captions if available, setting this to INVISIBLE if will hide the close captions.
Throws:
IllegalStateException - if the media player was already released.

setCCStyle

void setCCStyle(TextFormat textFormat)
                throws IllegalStateException
Sets the closed captioning style. Used to control the closed captioning font, size, color, edge and opacity. This method is safe to use even if the current media stream doesn't have closed captions.

Parameters:
textFormat - TextFormat to be used
Throws:
IllegalStateException

getCCStyle

TextFormat getCCStyle()
                      throws IllegalStateException
Returns:
the current closed captioning style. If no style was previously set, it returns a TextFormat object with default values for each attribute.
Throws:
IllegalStateException - if media player was already released.

getDRMManager

DRMManager getDRMManager()
Returns:
returns the DRM manager associated with this player instance.

getPlaybackMetrics

PlaybackMetrics getPlaybackMetrics()
                                   throws IllegalStateException
Returns:
playback metrics
Throws:
IllegalStateException - if media player was already released.

getNotificationHistory

NotificationHistory getNotificationHistory()
Returns:
notification history object

addEventListener

void addEventListener(MediaPlayer.Event event,
                      MediaPlayer.EventListener listener)
Adds a new event listener for specified event type.

Parameters:
event - the type of events we want to monitor
listener - the listener which will be used when the specified event happened

removeEventListener

void removeEventListener(MediaPlayer.Event event,
                         MediaPlayer.EventListener listener)
Removes an existing event listener for specified event type.

Parameters:
event - the type of events we want to monitor
listener - the listener which will be used when the specified event happened