Triton Mobile SDK for Android 3.5.1 This is a custom android player made by Triton Digital

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
com.tritondigital.player.SbmPlayer Class Reference

Side-Band Metadata player. More...

Inheritance diagram for com.tritondigital.player.SbmPlayer:

## Public Member Functions
| SbmPlayer (Context context, Bundle settings)
| Constructor.
boolean | isTimeshiftStreaming ()
int | getOffset ()
| Returns the metadata/audio offset in milliseconds.
void | setOffset (int offset)
| Sets the offset in milliseconds of to apply to the side band player to synchronise it with you media stream.
boolean | isPausable ()
int | getDuration ()
int | getPosition ()
float | getVolume ()
boolean | isSeekable ()
void | setVolume (float volume)
Public Member Functions inherited from com.tritondigital.player.MediaPlayer
| MediaPlayer (Context context, Bundle settings)
| Constructor.
Bundle | getSettings ()
| Returns the settings of this player.
int | getState ()
| Returns the player's state.
Bundle | getLastCuePoint ()
| Returns the last received cue point.
int | getLastErrorCode ()
| Returns the last error code.
OnCuePointReceivedListener | getOnCuePointReceivedListener ()
| Returns the cue point listener.
OnMetaDataReceivedListener | getMetadataListener ()
| Returns the metadata listener.
OnInfoListener | getOnInfoListener ()
| Returns the info listener.
OnStateChangedListener | getOnStateChangedListener ()
| Returns the state changed listener.
OnAnalyticsReceivedListener | getAnalyticsReceivedListener ()
OnCloudStreamInfoReceivedListener | getCloudStreamInfoReceivedListener ()
void | setOnCuePointReceivedListener (OnCuePointReceivedListener listener)
| Sets the cue point event listener.
void | setOnMetaDataReceivedListener (OnMetaDataReceivedListener listener)
| Sets the cue point event listener.
void | setOnInfoListener (OnInfoListener listener)
| Sets the info listener.
void | setOnStateChangedListener (OnStateChangedListener listener)
| Sets the state changed listener.
void | setOnAnalyticsReceivedListener (OnAnalyticsReceivedListener listener)
| Sets the analytics changed listener.
void | setOnCloudStreamInfoReceivedListener (OnCloudStreamInfoReceivedListener listener)
| Sets the timeshift programs listener.
final void | seekTo (int position, int original)
| Seek to the provided position.
final void | seekTo (int position)
| Seek to the provided position.
void | seek (int delta)
| Seek to a time from the current position.
final void | seekToLive ()
void | getCloudStreamInfo ()
void | playProgram (String programId)
final void | play ()
final void | play (boolean timeshiftStreaming)
| Starts the playback.
final void | pause ()
| Pauses the playback so it can be resumed at the same position by calling play().
final void | changeSpeed (Float speed)
final void | stop ()
| Stops the playback.
final void | release ()
| Releases the player resources.
int | getErrorCode ()

## Static Public Member Functions
static String | generateSbmId ()
| Generates a Side-Band Metadata session ID.
Static Public Member Functions inherited from com.tritondigital.player.MediaPlayer
static boolean | isPlayValidInState (int state)
| Returns true if a play request is valid in the provided state.
static boolean | isTransitionValid (int state0, int state1)
| Returns true if the provided state transition is valid.
static String | debugErrorToStr (int errorCode)
| Utility method to convert an error code to a debug string.
static String | debugInfoToStr (int info)
| Utility method to convert an info code to a debug string.
static String | debugStateToStr (int state)
| Utility method to convert the player state to a debug string.

## Static Public Attributes
static final String | SETTINGS_SBM_URL = PlayerConsts.SBM_URL
Static Public Attributes inherited from com.tritondigital.player.MediaPlayer
static final int | ERROR_LOW_LEVEL_PLAYER_ERROR = 210
| Error code indicating an error in the OS player or Google Cast.
static final int | ERROR_CONNECTION_FAILED = 211
| Error code indicating a connection problem to the server.
static final int | ERROR_CONNECTION_TIMEOUT = 408
| Error code indicating than the connection has timed out.
static final int | ERROR_UNEXPECTED_END_OF_MEDIA = 213
| Error code indicating the end of a media which shouldn't occur on live streaming.
static final int | ERROR_UNEXPECTED_END_OF_MEDIA_ANDROID_PLAYER = 214
| Error code indicating the end of a media which shouldn't occur on live streaming.
static final int | ERROR_EXOPLAYER_BUFFER_RECONNECT = 212
| Error code indicating that low delay increased 3 times an still did not fill the buffer.
static final int | ERROR_EXOPLAYER_BUFFER_TIMEOUT = 218
| Error code indicating buffer timed out.
static final int | ERROR_EXOPLAYER_ON_ERROR = 219
| Error code indicating buffer timed out.
static final int | ERROR_GEOBLOCKED = 453
| Error code indicating that the stream can't be used in the user location.
static final int | ERROR_INVALID_URL = 216
| Error code indicating that the URL isn't in a valid format.
static final int | ERROR_NO_NETWORK = 217
| Error code indicating the lack of network connectivity.
static final int | ERROR_NOT_FOUND = 404
| Error code indicating that the input source couldn't be found.
static final int | ERROR_SERVICE_UNAVAILABLE = 503
| Error code indicating that no server is available.
static final int | STATE_COMPLETED = 200
| The end of the media source has been reached (on-demand only)
static final int | STATE_CONNECTING = 201
| The player is connecting to the server or buffering.
static final int | STATE_ERROR = 202
| An error has occurred.
static final int | STATE_PLAYING = 203
| The playback is started.
static final int | STATE_RELEASED = 204
| The resources have been released and this player instance can no longer be used.
static final int | STATE_STOPPED = 205
| The playback is stopped.
static final int | STATE_PAUSED = 206
| The playback is paused (on-demand only)
static final int | DURATION_LIVE_STREAM = Integer.MAX_VALUE
| Live stream.
static final int | DURATION_UNKNOWN = -1
| Unknown duration.
static final int | POSITION_UNKNOWN = 0
| Unknown position.
static final float | VOLUME_DUCK = 0.2f
| Ducked volume.
static final float | VOLUME_MUTE = 0.0f
| Muted volume.
static final float | VOLUME_NORMAL = 1.0f
| Normal volume.
static final int | INFO_ALTERNATE_MOUNT = 270
| A the player has connected to an alternate mount.
static final int | INFO_SEEK_COMPLETED = 271
| A seek operation has completed.
static final int | INFO_DURATION_CHANGED = 272
| Media duration changed (extra=duration)
static final int | INFO_SEEKABLE_CHANGED = 273
| Seekable state change (0=false / 1=true)
static final int | INFO_SEEK_STARTED = 274
| A seek operation has begun.
static final int | INFO_BUFFERING_START = 275
| Temporarily pausing playback internally in order to buffer more data.
static final int | INFO_BUFFERING_COMPLETED = 276
| The playback is resumed after filling buffers.
static final int | ERROR_END_OF_MEDIA = ERROR_UNEXPECTED_END_OF_MEDIA

## Protected Member Functions
void | internalPlay ()
void | internalPlay (boolean timeshiftStreaming)
void | internalStop ()
void | internalRelease ()
void | internalChangeSpeed (Float speed)
void | internalGetCloudStreamInfo ()
void | internalPlayProgram (String programId)
String | makeTag ()
boolean | isEventLoggingEnabled ()
void | internalPause ()
void | internalSeekTo (int position, int original)

## Additional Inherited Members
Protected Attributes inherited from com.tritondigital.player.MediaPlayer
final String | TAG = makeTag()
final Bundle | mSettings

## Detailed Description

Side-Band Metadata player.

Note
  For special cases only. Most clients will never have to use this class.

This player connects to a Triton server and downloads the cue points linked to an audio stream session. SBM needs to be enabled on the server side.

Session ID (sbmid)
  The same session ID (sbmid) must be provided to the audio URL and SBM URL parameters. Use SbmPlayer.generateSbmId() to create it. The current SbmPlayer implementation doesn't support updating the ID; therefore, you must create a new instance on each play request.

Example

public class SbmPlayerActivity extends Activity implements
MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener,
SbmPlayer.OnCuePointReceivedListener
{
private static final String SBM_URL = "http://1651.live.preprod01.streamtheworld.net:80/HLS_TEST_SBM";
private static final String STREAM_URL = "http://1651.live.preprod01.streamtheworld.net:80/HLS_TEST_SC";
private MediaPlayer mMediaPlayer;
private SbmPlayer mSbmPlayer;
private boolean mPlayRequested;
private StreamUrlBuilder mStreamUrlBuilder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
setContentView(layout);
// Create the Android player
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setOnErrorListener(this);
mMediaPlayer.setOnPreparedListener(this);
// Add your tracking parameters here.
mStreamUrlBuilder = new StreamUrlBuilder(this)
.enableLocationTracking(true)
.setHost(STREAM_URL);
}
@Override
protected void onDestroy() {
mMediaPlayer.release();
releaseSbmPlayer();
super.onDestroy();
}
@Override
public boolean onError(MediaPlayer androidPlayer, int what, int extra) {
releaseSbmPlayer();
return false;
}
@Override
public void onPrepared(MediaPlayer androidPlayer) {
if (!isFinishing()) {
androidPlayer.start();
if (mSbmPlayer != null) {
mSbmPlayer.play();
}
}
}
@Override
public void onCuePointReceived(MediaPlayer sbmPlayer, Bundle cuePoint) {
// Do something here
}
public void startPlayback() {
if (!mPlayRequested) {
mPlayRequested = true;
try {
// Create SBM and player URLS. We calling "mStreamUrlBuilder.build()"
// every time to refresh the location and the advertising ID.
String sbmid = SbmPlayer.generateSbmId();
String streamUrl = mStreamUrlBuilder.build() + "&sbmid=" + sbmid;
String sbmUrl = SBM_URL + "?sbmid=" + sbmid;
// Create SBM player
Bundle sbmPlayerSettings = new Bundle();
sbmPlayerSettings.putString(SbmPlayer.SETTINGS_STREAM_URL, sbmUrl);
mSbmPlayer = new SbmPlayer(this, sbmPlayerSettings);
mSbmPlayer.setOnCuePointReceivedListener(this);
// Create Android Player
mMediaPlayer.setDataSource(this, Uri.parse(streamUrl));
mMediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void stopPlayback() {
// Ignore double stop requests.
if (!mPlayRequested) {
return;
}
mPlayRequested = false;
mMediaPlayer.reset();
releaseSbmPlayer();
}
private void releaseSbmPlayer() {
mCuePointIdx = 0;
mPlayRequested = false;
if (mSbmPlayer != null) {
mSbmPlayer.release();
mSbmPlayer = null;
}
}
}
com.tritondigital.player.MediaPlayer
Base class for a media player.
Definition MediaPlayer.java:21
com.tritondigital.player.MediaPlayer.release
final void release()
Releases the player resources.
Definition MediaPlayer.java:648
com.tritondigital.player.MediaPlayer.setOnCuePointReceivedListener
void setOnCuePointReceivedListener(OnCuePointReceivedListener listener)
Sets the cue point event listener.
Definition MediaPlayer.java:373
com.tritondigital.player.SbmPlayer
Side-Band Metadata player.
Definition SbmPlayer.java:148
com.tritondigital.player.StreamUrlBuilder
Helps create station stream URLs.
Definition StreamUrlBuilder.java:25
com.tritondigital.player.StreamUrlBuilder.enableLocationTracking
StreamUrlBuilder enableLocationTracking(boolean enable)
Enables the location tracking using the device's location manager.
Definition StreamUrlBuilder.java:396
com.tritondigital.player.StreamUrlBuilder.setHost
StreamUrlBuilder setHost(String host)
Sets server host with the mount.
Definition StreamUrlBuilder.java:483
com.tritondigital.player.StreamUrlBuilder.build
String build()
Returns an URL from the previously set data.
Definition StreamUrlBuilder.java:414
com.tritondigital.player.MediaPlayer.OnCuePointReceivedListener
Callback for receiving CuePoint.
Definition MediaPlayer.java:30

## Member Function Documentation

## ◆ generateSbmId()

static String com.tritondigital.player.SbmPlayer.generateSbmId | ( |  | ) |
| static

Generates a Side-Band Metadata session ID.

The same session ID (sbmid) must be provided to the audio URL and SBM URL parameters.

## ◆ getDuration()

int com.tritondigital.player.SbmPlayer.getDuration | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getPosition()

int com.tritondigital.player.SbmPlayer.getPosition | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getVolume()

float com.tritondigital.player.SbmPlayer.getVolume | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalChangeSpeed()

void com.tritondigital.player.SbmPlayer.internalChangeSpeed | ( | Float | speed | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalGetCloudStreamInfo()

void com.tritondigital.player.SbmPlayer.internalGetCloudStreamInfo | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPause()

void com.tritondigital.player.SbmPlayer.internalPause | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlay() [1/2]

void com.tritondigital.player.SbmPlayer.internalPlay | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlay() [2/2]

void com.tritondigital.player.SbmPlayer.internalPlay | ( | boolean | timeshiftStreaming | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlayProgram()

void com.tritondigital.player.SbmPlayer.internalPlayProgram | ( | String | programId | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalRelease()

void com.tritondigital.player.SbmPlayer.internalRelease | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalSeekTo()

void com.tritondigital.player.SbmPlayer.internalSeekTo | ( | int | position,
|  | int | original
| ) |  |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalStop()

void com.tritondigital.player.SbmPlayer.internalStop | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isEventLoggingEnabled()

boolean com.tritondigital.player.SbmPlayer.isEventLoggingEnabled | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isPausable()

boolean com.tritondigital.player.SbmPlayer.isPausable | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isSeekable()

boolean com.tritondigital.player.SbmPlayer.isSeekable | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isTimeshiftStreaming()

boolean com.tritondigital.player.SbmPlayer.isTimeshiftStreaming | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ makeTag()

String com.tritondigital.player.SbmPlayer.makeTag | ( |  | ) |
| protected

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ setVolume()

void com.tritondigital.player.SbmPlayer.setVolume | ( | float | volume | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

The documentation for this class was generated from the following file:

- sdk/src/main/java/com/tritondigital/player/SbmPlayer.java