octoshape.osa2.android.listeners
Interface StreamPlayerListener


public interface StreamPlayerListener

Listens for stream information and for URLs to play in a media player.

This listener must be set on a StreamPlayer object in order it to work properly. In the lifetime of a StreamPlayer object, one of the resolved... methods is called once and then the gotUrl may be called several times afterwards. In some cases, particularly if the StreamPlayer dispatched a non-normal problem, the same resolved... method that was called before may be called again.

Normally the resolved... method will be called right before the first gotUrl call, i.e. after the StreamPlayer has been requested to play. In order to have the resolved... method called earlier, i.e. without beginning to play, use the StreamPlayer.initialize(boolean) method.

The resolved... methods.

The resolved... methods give information about the stream type (live, live with DVR, or on-demand), the seek method (native seek, osa seek, or no seeking), and also about which media player the Octoshape client selected as the best to play the stream.

Native seek means that is it possible to use the selected media player's own method of seeking.

Osa-seek means it is possible to use the requestPlayLive... and requestPlayOnDemand... methods of a StreamPlayer, like for instance the StreamPlayer.requestPlayOndemandMediaTimePosition(long) method, to seek to a specific position in the stream.

The selected media player id will be one of the player ids added by the OctoshapeSystem.addPlayerNameAndVersion(String, String, String) method. If no players have been added, then the player id in the resolved.. method will be null.


Method Summary
 void gotNewOnDemandStreamDuration(long duration)
          Resets an on-demand file duration previously reported in a resolved... method.
 void gotUrl(java.lang.String url, long seekOffset, MediaPlayerListener listener)
          The Octoshape client is ready to play and it sent this URL to be played in a media player.
 void resolvedNativeSeek(boolean isLive, java.lang.String playerId)
          Called if the stream is seekable using the media player's own native seeking functionality.
 void resolvedNoSeek(boolean isLive, java.lang.String playerId)
          Called if it is not possible to seek in the stream.
 void resolvedOsaSeek(boolean isLive, long duration, java.lang.String playerId)
          Called if the stream is seekable using the StreamPlayer.requestPlay...
 

Method Detail

resolvedNativeSeek

void resolvedNativeSeek(boolean isLive,
                        java.lang.String playerId)
Called if the stream is seekable using the media player's own native seeking functionality.

Currently this is only possible for some on-demand streams. Called if the stream is a live stream with DVR, where the native DVR seeking functionalities should be used.

Parameters:
isLive - If the stream is a live stream or en on-demand stream.
playerId - The selected player id or null

resolvedOsaSeek

void resolvedOsaSeek(boolean isLive,
                     long duration,
                     java.lang.String playerId)
Called if the stream is seekable using the StreamPlayer.requestPlay... methods.

For live streams, this means that the stream is configured to have DVR functionality. Here the argument duration is the maximum DVR the stream is configured to have.

For on-demand streams the argument duration is the length of the file.

Parameters:
isLive - If the stream is a live stream or an on-demand stream.
duration - The duration of the seekable data in milliseconds.
playerId - The selected player id or null

resolvedNoSeek

void resolvedNoSeek(boolean isLive,
                    java.lang.String playerId)
Called if it is not possible to seek in the stream.

This is called for normal non-DVR live streams, and in rare cases for on-demand streams.

Parameters:
isLive - If the stream is a live stream or an on-demand stream.
playerId - The selected player id or null

gotNewOnDemandStreamDuration

void gotNewOnDemandStreamDuration(long duration)
Resets an on-demand file duration previously reported in a resolved... method.

In very rare cases the file duration may be adjusted after the resolved... method has been called. Currently the only situation this can happen in, is if the stream is a multi-stream, and the containing basestreams has not been encoded with the exact same length.

Parameters:
duration - Duration of on-demand file in milliseconds

gotUrl

void gotUrl(java.lang.String url,
            long seekOffset,
            MediaPlayerListener listener)
The Octoshape client is ready to play and it sent this URL to be played in a media player.

The seekOffset argument will only be set for osa-seek streams (on-demand or live DVR), i.e. where the resolvedOsaSeek(boolean, long, String) method has been called, and only if the play request that triggered this URL message was a request to play from a specific position in the file, like for instance StreamPlayer.requestPlayOndemandMediaTimePosition(long) or StreamPlayer.requestPlayLiveWithLatency(long). The argument holds the millisecond position in the file that the URL will begin to play.

The seekOffset argument is present because when using the StreamPlayer on-demand seek or live DVR methods it is not always possible for the client to seek to the exact requested position, as playing has to start on a new frame. The supplied URL will play at the closest new frame to what was requested and that seek offset is then given here. Note that the offset is always given in media time, even when the request was done using StreamPlayer.requestPlayOndemandPermilPosition(int), StreamPlayer.requestPlayOndemandTimePosition(long), or StreamPlayer.requestPlayLiveTimePosition(long).

For non-DVR live streams, the seekOffset will always be -1.

This method also gives a MediaPlayerListener} object that should be used to listen from the media player for playing this url.

Parameters:
url - The URL to play.
seekOffset - The actual seek offset / extra latency in milliseconds or -1 if unknown.
listener - Object to receive information about media player events.