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 Attributes | Protected Member Functions | List of all members
com.tritondigital.player.TritonPlayer Class Reference

Plays a station provided by Triton Digital or an on-demand stream. More...

Inheritance diagram for com.tritondigital.player.TritonPlayer:

## Public Member Functions
| TritonPlayer (Context context, Bundle settings)
| Constructor.
int | getDuration ()
Bundle | getLastCuePoint ()
int | getLastErrorCode ()
boolean | isTimeshiftStreaming ()
int | getPosition ()
Bundle | getSettings ()
int | getState ()
float | getVolume ()
MediaPlayer | getMediaPlayer ()
boolean | isSeekable ()
boolean | isPausable ()
void | setVolume (float volume)
void | setMediaRoute (MediaRouter.RouteInfo routeInfo)
| Sets the media route to use for the current player instance.
String | getAlternateMount ()
| Returns the alternate mount used if the station is using content blocking.
String | getSideBandMetadataUrl ()
| Returns the Side Band MetaData Url.
String | getCastStreamingUrl ()
| Returns the Stream URL to cast to Google Cast devices.
Public Member Functions inherited from com.tritondigital.player.MediaPlayer
| MediaPlayer (Context context, Bundle settings)
| Constructor.
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 Attributes
static final String | SETTINGS_APP_NAME = PlayerConsts.APP_NAME
static final String | SETTINGS_STATION_BROADCASTER = PlayerConsts.STATION_BROADCASTER
static final String | SETTINGS_STATION_NAME = PlayerConsts.STATION_NAME
static final String | SETTINGS_STATION_MOUNT = PlayerConsts.STATION_MOUNT
static final String | SETTINGS_STREAM_URL = PlayerConsts.STREAM_URL
static final String | SETTINGS_STREAM_MIME_TYPE = PlayerConsts.MIME_TYPE
static final String | SETTINGS_AUTH_TOKEN = PlayerConsts.AUTH_TOKEN
static final String | SETTINGS_AUTH_KEY_ID = PlayerConsts.AUTH_KEY_ID
static final String | SETTINGS_AUTH_SECRET_KEY = PlayerConsts.AUTH_SECRET_KEY
static final String | SETTINGS_AUTH_REGISTERED_USER = PlayerConsts.AUTH_REGISTERED_USER
static final String | SETTINGS_AUTH_USER_ID = PlayerConsts.AUTH_USER_ID
static final String | SETTINGS_TARGETING_PARAMS = PlayerConsts.TARGETING_PARAMS
static final String | SETTINGS_TARGETING_LOCATION_TRACKING_ENABLED = PlayerConsts.TARGETING_LOCATION_TRACKING_ENABLED
static final String | SETTINGS_MEDIA_ITEM_METADATA = PlayerConsts.MEDIA_ITEM_METADATA
static final String | SETTINGS_TRANSPORT = PlayerConsts.TRANSPORT
static final String | MIME_TYPE_AAC = PlayerConsts.MIME_TYPE_AAC
static final String | MIME_TYPE_MPEG = PlayerConsts.MIME_TYPE_MPEG
static final String | TRANSPORT_FLV = PlayerConsts.TRANSPORT_FLV
static final String | TRANSPORT_HLS = PlayerConsts.TRANSPORT_HLS
static final String | TRANSPORT_SC = PlayerConsts.TRANSPORT_SC
static final String | SETTINGS_LOW_DELAY = PlayerConsts.LOW_DELAY
static final String | SETTINGS_TTAGS = PlayerConsts.TTAGS
static final String | SETTINGS_FORCE_DISABLE_EXOPLAYER = PlayerConsts.FORCE_DISABLE_EXOPLAYER
static final String | SETTINGS_PLAYER_SERVICES_REGION = PlayerConsts.PLAYER_SERVICES_REGION
static final String | SETTINGS_DMP_SEGMENTS = PlayerConsts.DMP_SEGMENTS
static final String | SETTINGS_HANDLE_AUDIO_FOCUS = PlayerConsts.HANDLE_AUDIO_FOCUS
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 | internalPause ()
void | internalPlay ()
void | internalPlay (boolean timeshiftStreaming)
void | internalRelease ()
void | internalSeekTo (int position, int original)
void | internalStop ()
void | internalChangeSpeed (Float speed)
String | makeTag ()
boolean | isEventLoggingEnabled ()
void | internalGetCloudStreamInfo ()
void | internalPlayProgram (String programId)

## Additional Inherited Members
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.
Protected Attributes inherited from com.tritondigital.player.MediaPlayer
final String | TAG = makeTag()
final Bundle | mSettings

## Detailed Description

Plays a station provided by Triton Digital or an on-demand stream.

Example - Play a Station
  // Create the player settings.
  Bundle settings = new Bundle();
  settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital");
  settings.putString(TritonPlayer.SETTINGS_STATION_NAME, "MOBILEFM");
  settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT, "MOBILEFM_AACV2");
  // Create the player.
  TritonPlayer player = new TritonPlayer(this, settings);
  player.play();
  com.tritondigital.player.TritonPlayer
  Plays a station provided by Triton Digital or an on-demand stream.
  Definition TritonPlayer.java:162
  com.tritondigital.player.TritonPlayer.SETTINGS_STATION_BROADCASTER
  static final String SETTINGS_STATION_BROADCASTER
  Definition TritonPlayer.java:172
  com.tritondigital.player.TritonPlayer.SETTINGS_STATION_MOUNT
  static final String SETTINGS_STATION_MOUNT
  Definition TritonPlayer.java:178
  com.tritondigital.player.TritonPlayer.SETTINGS_STATION_NAME
  static final String SETTINGS_STATION_NAME
  Definition TritonPlayer.java:175

Example - Change the Station
  // Release the current player instance.
  if (player != null)
  {
  player.release();
  }
  // Recreate the player with the next station settings.
  player = new TritonPlayer(this, nextStationSettings);
  player.play();
  com.tritondigital.player.MediaPlayer.release
  final void release()
  Releases the player resources.
  Definition MediaPlayer.java:648

Example - Target Audio Ads
  // Create the targeting parameters
  HashMap<String, String> targetingParams = new HashMap();
  targetingParams.put(StreamUrlBuilder.COUNTRY_CODE, "US");
  targetingParams.put(StreamUrlBuilder.POSTAL_CODE, "12345");
  targetingParams.put(StreamUrlBuilder.GENDER, "m");
  targetingParams.put(StreamUrlBuilder.YEAR_OF_BIRTH, "1990");
  // Create the player settings.
  Bundle settings = new Bundle();
  settings.putBoolean(TritonPlayer.SETTINGS_TARGETING_LOCATION_TRACKING_ENABLED, true);
  settings.putSerializable(TritonPlayer.SETTINGS_TARGETING_PARAMS, targetingParams);
  settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital");
  settings.putString(TritonPlayer.SETTINGS_STATION_NAME, "MOBILEFM");
  settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT, "MOBILEFM_AACV2");
  // Create the player.
  TritonPlayer player = new TritonPlayer(this, settings);
  player.play();
  com.tritondigital.player.StreamUrlBuilder
  Helps create station stream URLs.
  Definition StreamUrlBuilder.java:25
  com.tritondigital.player.StreamUrlBuilder.POSTAL_CODE
  static final String POSTAL_CODE
  String - Postal/ZIP code
  Definition StreamUrlBuilder.java:52
  com.tritondigital.player.StreamUrlBuilder.YEAR_OF_BIRTH
  static final String YEAR_OF_BIRTH
  int - Year of birth (1900 to 2005)
  Definition StreamUrlBuilder.java:87
  com.tritondigital.player.StreamUrlBuilder.COUNTRY_CODE
  static final String COUNTRY_CODE
  String - Country code (ISO 3166-1 alpha-2)
  Definition StreamUrlBuilder.java:62
  com.tritondigital.player.StreamUrlBuilder.GENDER
  static final String GENDER
  char - Gender ('m' or 'f')
  Definition StreamUrlBuilder.java:90
  com.tritondigital.player.TritonPlayer.SETTINGS_TARGETING_LOCATION_TRACKING_ENABLED
  static final String SETTINGS_TARGETING_LOCATION_TRACKING_ENABLED
  Definition TritonPlayer.java:201
  com.tritondigital.player.TritonPlayer.SETTINGS_TARGETING_PARAMS
  static final String SETTINGS_TARGETING_PARAMS
  Definition TritonPlayer.java:198

Example - Token Authorization (self signed)
  // Create the targeting parameters
  HashMap<String, String> targetingParams = new HashMap();
  targetingParams.put(StreamUrlBuilder.COUNTRY_CODE, "US");
  targetingParams.put(StreamUrlBuilder.POSTAL_CODE, "12345");
  targetingParams.put(StreamUrlBuilder.GENDER, "m");
  targetingParams.put(StreamUrlBuilder.YEAR_OF_BIRTH, "1990");
  // Create the authentication token
  String token = AuthUtil.createJwtToken("MySecretKey", "MySecretKeyId", true, "foo@bar.com", targetingParams);
  // Create the player settings.
  Bundle settings = new Bundle();
  settings.putBoolean(TritonPlayer.SETTINGS_TARGETING_LOCATION_TRACKING_ENABLED, true);
  settings.putSerializable(TritonPlayer.SETTINGS_TARGETING_PARAMS, targetingParams);
  settings.putString(TritonPlayer.SETTINGS_AUTH_TOKEN, token);
  settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital");
  settings.putString(TritonPlayer.SETTINGS_STATION_NAME, "MOBILEFM");
  settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT, "MOBILEFM_AACV2");
  // Create the player.
  TritonPlayer player = new TritonPlayer(this, settings);
  player.play();

Example - Receive Cue Points
  // Create a cue point listener.
  OnCuePointReceivedListener listener = new OnCuePointReceivedListener() {
  @Override
  public void onCuePointReceived(MediaPlayer player, Bundle cuePoint) {
  // Handle the cue points here.
  }
  };
  // Create the player.
  TritonPlayer player = new TritonPlayer(this, settings);
  player.setOnCuePointReceivedListener(listener);
  player.play();
  com.tritondigital.player.MediaPlayer
  Base class for a media player.
  Definition MediaPlayer.java:21
  com.tritondigital.player.MediaPlayer.OnCuePointReceivedListener
  Callback for receiving CuePoint.
  Definition MediaPlayer.java:30

Example - Display Sync Banners
  private SyncBannerView mSyncBannerView;
  @Override
  protected void onPause() {
  mSyncBannerView.onPause();
  super.onPause();
  }
  @Override
  protected void onResume() {
  super.onResume();
  mSyncBannerView.onResume();
  }
  @Override
  protected void onDestroy() {
  mSyncBannerView.release();
  super.onDestroy();
  }
  @Override
  public void onCuePointReceived(MediaPlayer player, Bundle cuePoint) {
  // Update the banner. See previous example on how to get cue points.
  mSyncBannerView.loadCuePoint(cuePoint);
  }
  private void initBanner() {
  // Get the banner from the layout and set its size.
  mSyncBannerView = (SyncBannerView)findViewById(mySyncBannerId);
  mSyncBannerView.setBannerSize(320, 50);
  }

Example - Play an On-Demand Stream
  // Create the player settings.
  Bundle settings = new Bundle();
  settings.putString(TritonPlayer.SETTINGS_STREAM_URL, "http://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3");
  // Create the player.
  TritonPlayer player = new TritonPlayer(this, settings);
  player.play();
  com.tritondigital.player.TritonPlayer.SETTINGS_STREAM_URL
  static final String SETTINGS_STREAM_URL
  Definition TritonPlayer.java:181

## Constructor & Destructor Documentation

## ◆ TritonPlayer()

com.tritondigital.player.TritonPlayer.TritonPlayer | ( | Context | context,
|  | Bundle | settings
| ) |  |

Constructor.

Exceptions

  IllegalArgumentException | if SETTINGS_STATION_MOUNT and SETTINGS_STREAM_URL are not set
  IllegalArgumentException | if SETTINGS_STATION_MOUNT and SETTINGS_STREAM_URL are both set

## Member Function Documentation

## ◆ getDuration()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getLastCuePoint()

Bundle com.tritondigital.player.TritonPlayer.getLastCuePoint | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getLastErrorCode()

int com.tritondigital.player.TritonPlayer.getLastErrorCode | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getPosition()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getSettings()

Bundle com.tritondigital.player.TritonPlayer.getSettings | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getState()

int com.tritondigital.player.TritonPlayer.getState | ( |  | ) |

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ getVolume()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalChangeSpeed()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalGetCloudStreamInfo()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPause()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlay() [1/2]

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlay() [2/2]

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalPlayProgram()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalRelease()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalSeekTo()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ internalStop()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isEventLoggingEnabled()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isPausable()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isSeekable()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ isTimeshiftStreaming()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ makeTag()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## ◆ setMediaRoute()

void com.tritondigital.player.TritonPlayer.setMediaRoute | ( | MediaRouter.RouteInfo | routeInfo | ) |

Sets the media route to use for the current player instance.

The route change is only effective on the next play().

Warning
  BETA. Only for live streams.

## ◆ setVolume()

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

Reimplemented from com.tritondigital.player.MediaPlayer.

## Member Data Documentation

## ◆ SETTINGS_STREAM_MIME_TYPE

final String com.tritondigital.player.TritonPlayer.SETTINGS_STREAM_MIME_TYPE = PlayerConsts.MIME_TYPE
| static

Needed by Google Cast. The default is MP3.

## ◆ SETTINGS_TARGETING_PARAMS

final String com.tritondigital.player.TritonPlayer.SETTINGS_TARGETING_PARAMS = PlayerConsts.TARGETING_PARAMS
| static

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

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