--- title: "Use the Android SDK" slug: "using-the-android-sdk" tags: ["Timeshift"] updated: 2026-10-16T13:28:56Z published: 2026-10-16T13:28:56Z canonical: "help.tritondigital.com/using-the-android-sdk" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.tritondigital.com/llms.txt > Use this file to discover all available pages before exploring further. # Use the Android SDK ## Basic Configuration When creating a Triton Player, configure the station information using the following basic settings. ### Broadcaster Use `TritonPlayer.SETTINGS_STATION_BROADCASTER` to specify the station broadcaster. ### Application Name (User-Agent) Use `TritonPlayer.SETTINGS_APP_NAME` to customize the application name included in the User-Agent header sent by the SDK. Default: `"CustomPlayer1"`. ### Station Name and Mount Use `TritonPlayer.SETTINGS_STATION_NAME` and `TritonPlayer.SETTINGS_STATION_MOUNT` to specify the Triton Digital station name and its mount name. You can get this information from the [Triton Console](/user/docs/streaming-console-1). ### Region When the SDK loads, it gets its station configuration from our provisioning servers. To speed up the process, we have provisioning servers in North America, Europe, and Asia. For best results, use `TritonPlayer.SETTINGS_PLAYER_SERVICES_REGION` to specify the provisioning servers that are closest to your stations: - North America: The default provisioning region. In this case, omit `TritonPlayer.SETTINGS_PLAYER_SERVICES_REGION`. - Asia: `"AP"`. - Europe: `"EU"`. This example specifies Triton servers in Asia: ```java // Create the player settings. Bundle settings = new Bundle(); settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER,    "Triton Digital"); settings.putString(TritonPlayer.SETTINGS_APP_NAME,               "CustomAppName"); settings.putString(TritonPlayer.SETTINGS_STATION_NAME,           "MOBILEFM"); settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT,          "MOBILEFM_AACV2"); settings.putString(TritonPlayer.SETTINGS_PLAYER_SERVICES_REGION, "AP"); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Autoplay *Autoplay* is when a station or stream plays without any user interaction to initiate the play. > [!WARNING] > Triton Digital strongly discourages the use of autoplay > > Autoplay can cause inaccurate measurements and can degrade the user’s experience. Triton Digital recommends that any initiation of audio content playback is determined by an overt user gesture, such as a tap or a click. If you do implement an autoplay strategy, you need to add the `autoplay = 1` value to the `targetingParams` object when calling `play()`. ```java // Create the player settings. Bundle settings = new Bundle(); settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital"); settings.putString(TritonPlayer.SETTINGS_APP_NAME,            "CustomAppName"); settings.putString(TritonPlayer.SETTINGS_STATION_NAME,        "MOBILEFM"); settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT,       "MOBILEFM_AACV2"); // Set autoplay HashMap targetingParams = new HashMap(); targetingParams.put("autoplay", "1"); settings.putSerializable(TritonPlayer.SETTINGS_TARGETING_PARAMS, targetingParams); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Audio Focus Use `TritonPlayer.SETTINGS_HANDLE_AUDIO_FOCUS` to enable or disable the automatic handling of the device audio focus. In case you want to control the audio focus manually, you can set this option to **false**. The default is **true**. Required: **No**. ##### Options (Boolean): - **Automatic** (TritonPlayer will handle any audio focus change automatically): `true` - **Manual** (TritonPlayer will ignore audio focus changes): `false` ```java // 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"); settings.putBoolean(TritonPlayer.SETTINGS_HANDLE_AUDIO_FOCUS, false); // Audio Focus handled manually // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Play a Station ```java // 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(); ``` ## Play a Specific HLS Mount ```java // Create the player settings. Bundle settings = new Bundle(); settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital"); settings.putString(TritonPlayer.SETTINGS_STATION_NAME,        "HLS_PLAYERS"); settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT,       "HLS_PLAYERSAAC"); settings.putString(TritonPlayer.SETTINGS_TRANSPORT,           TritonPlayer.TRANSPORT_HLS); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Change Station To play a new station, you must create a new player. ```java // 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(); ``` ## Target Audience for Audio Ads In this example, location tracking is enabled. The postal code will only be used if the user has disabled the location access in the O.S. See *StreamUrlBuilder* in the API reference for more targeting options. For details on the `bundle-id`, `store-id`, and `store-url` parameters, see [Device/Player Information](/user/docs/advertising-specification-parameters#deviceplayer-information). `AndroidManifest.xml` `<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />` ```java // Create the targeting parameters HashMap targetingParams = new HashMap(); targetingParams.put("bundle-id", "com.companyname.app"); // Required targetingParams.put("store-id", "com.companyname.app"); // Required targetingParams.put("store-url", "https://play.google.com/store/apps/details?id=com.companyname.app"); // Required 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(); ``` Example using DMP Segments: ```java //Add DMP SEGMENTS HashMap> dmpSegments = new HashMap(); dmpSegments.put("permutive", Arrays.asList(1234,5769)); dmpSegments.put("adobe", Arrays.asList(4321,8765)); // 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.putSerializable(TritonPlayer.SETTINGS_DMP_SEGMENTS, dmpSegments); 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(); ``` ## Change Playback Speed To change the playback speed of a podcast, use `changeSpeed` with a float value as the speed argument. This example changes the playback to 1.5 times the original speed: `tritonPlayer.changeSpeed(1.5f)` ## Stream While Muted You can configure the behavior of the stream while the player is muted. Use `TritonPlayer.SETTINGS_STREAM_WHILE_MUTED` to enable or disable the stream continuing to play when the user mutes the audio. The default is `true`. Options: - Stream stops when muted: `false` - Stream continues when muted but the user does not hear audio: `true` ```java // Create the player settings. Bundle settings = new Bundle(); settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER, "Triton Digital"); settings.putString(TritonPlayer.SETTINGS_APP_NAME,            "CustomAppName"); settings.putString(TritonPlayer.SETTINGS_STATION_NAME,        "MOBILEFM"); settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT,       "MOBILEFM_AACV2"); // Set stream while muted. settings.putBoolean(TritonPlayer.SETTINGS_STREAM_WHILE_MUTED, true); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Token Authorization (Self-Signed) In order for re-creation of the tokens on reconnect to work, either of the following parameters are required: - `TritonPlayer.SETTINGS_AUTH_SECRET_KEY` - `TritonPlayer.SETTINGS_AUTH_KEY_ID` If all of the parameters are filled in, then you don't have to generate the token yourself (although you can if you want to). ```java // Create the targeting parameters HashMap 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 authorization token String token = AuthUtil.createJwtToken("MySecretKey", "MySecretKeyId", true, "foo@bar.com", targetingParams); // Create the player settings. Bundle settings = new Bundle(); 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"); settings.putString(TritonPlayer.SETTINGS_AUTH_SECRET_KEY,        "1234566"); settings.putString(TritonPlayer.SETTINGS_AUTH_KEY_ID,            "ABCDEF"); settings.putBoolean(TritonPlayer.SETTINGS_AUTH_REGISTERED_USER,  true/false); settings.putString(TritonPlayer.SETTINGS_AUTH_USER_ID,           null); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Receive Stream Metadata (Cue Points) ```java // 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(); ``` ## Display Sync Banners ```java 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); } ``` ## Play an On-Demand Stream ```java // Create the player settings. Bundle settings = new Bundle(); settings.putString(TritonPlayer.SETTINGS_STREAM_URL, "https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3"); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Play on Google Cast Devices The Triton Digital Mobile SDK supports [Google Cast](http://www.google.com/cast/) devices for both live and on-demand streams, but not on-demand advertising. There are a few devices supporting the Google Cast protocol, such as the Chromecast player and Nexus player. ### Basic Media Receiver The sample app in the ZIP file shows how to do a basic implementation. ### Styled Media Receiver More complex to implement than the Basic Media Receiver. Useful links: - [https://developers.google.com/cast/docs/styled_receiver](https://developers.google.com/cast/docs/styled_receiver) - [https://www.binpress.com/building-android-google-cast-sender-app/](https://www.binpress.com/building-android-google-cast-sender-app/) ## Get the Station’s Song History ```java public class SongHistoryExample extends Activity implements CuePointHistory.CuePointHistoryListener {    private CuePointHistory mCuePointHistory;    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        // Init the cue point history object        mCuePointHistory = new CuePointHistory();        mCuePointHistory.setListener(this);        mCuePointHistory.setCueTypeFilter(CuePoint.CUE_TYPE_VALUE_TRACK);        mCuePointHistory.setMaxItems(10);        mCuePointHistory.setMount("MOBILEFM");        // Request the track history        mCuePointHistory.request();    }    @Override    public void onCuePointHistoryReceived(CuePointHistory src, List cuePoints) {        // Handle history here    }    @Override    public void onCuePointHistoryFailed(CuePointHistory src, int errorCode) {        // Handle errors here    } } ``` ## Display On-Demand Ads Over the App Interstitials can either be video or audio ads. `AndroidManifest.xml` ```java ``` **MyActivity.java** ```java AdRequestBuilder adRequestBuilder = new AdRequestBuilder(this)        .enableLocationTracking(true)        .setHost("https://cmod-world.live.streamtheworld.com")        .addQueryParameter(AdRequestBuilder.YEAR_OF_BIRTH, 1990)        .addQueryParameter(AdRequestBuilder.GENDER, 'm')        .addQueryParameter(AdRequestBuilder.STATION_ID, "23193"); // Create the interstitial instance Interstitial interstitial = new Interstitial(this); //Optional if you want to display the ad countdown timer: interstitial.setEnableCountDownDisplay(true); // Display an interstitial ad interstitial.showAd(adRequestBuilder); // When exiting your activity interstitial.release(); ``` You can also specify `bundle-id`, `store-id`, and `store-url` to On-Demand Ads as follows: ```java AdRequestBuilder adRequestBuilder = new AdRequestBuilder(this)        .setHost("https://cmod-world.live.streamtheworld.com")        .addQueryParameter(AdRequestBuilder.STATION_ID, "12345")        .addQueryParameter(AdRequestBuilder.ASSET_TYPE, AdRequestBuilder.ASSET_TYPE_VALUE_VIDEO)        .addQueryParameter(AdRequestBuilder.TYPE, AdRequestBuilder.TYPE_VALUE_MIDROLL)        // Add bundle-id, store-id and store-url        .addQueryParameter(AdRequestBuilder.BUNDLE_ID, "com.tritondigital.tritonradio")        .addQueryParameter(AdRequestBuilder.STORE_ID, "1234567890")        .addQueryParameter(AdRequestBuilder.STORE_URL, URLEncoder.encode("https://play.google.com/store/apps/details?id=com.tritondigital.tritonradio", "UTF-8")); // Create the interstitial instance Interstitial interstitial = new Interstitial(this); // Display an interstitial ad interstitial.showAd(adRequestBuilder); ``` ## Display On-Demand Ads with Custom UI This is much more complex than using the Interstitial class. There is an example in the sample application in the ZIP file. ## Custom TTags – Player Custom TTags (e.g., `mobile:ford`) can be applied to streaming URLs by adding an array to the settings parameter `SETTINGS_TTAGS`. ```java // 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"); String[] tTags = {"mobile:android","cola:diet"}; settings.putStringArray(TritonPlayer.SETTINGS_TTAGS,tTags); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Custom TTags – On Demand Ads Custom TTags (e.g., `mobile:ford`) can be applied to On Demand URLs by calling `addTTags( String[] )` on `AdRequestBuilder`. ```java // Optional Custom TTags String[] tTags = { "mobile:android", "car:suv" }; AdRequestBuilder adRequestBuilder = new AdRequestBuilder(this)        .enableLocationTracking(true)        .setHost("https://cmod-world.live.streamtheworld.com")        .addQueryParameter(AdRequestBuilder.YEAR_OF_BIRTH, 1990)        .addQueryParameter(AdRequestBuilder.GENDER, 'm')        .addQueryParameter(AdRequestBuilder.STATION_ID, "23193")        .addTtags(tTags); // Create the interstitial instance Interstitial interstitial = new Interstitial(this); // Display an interstitial ad interstitial.showAd(adRequestBuilder); // When exiting your activity interstitial.release(); ``` ## Multi-listener ID Provides a way to send multiple user or device identifiers, in addition to the main listener ID (`lsid` parameter). The latter is still used by Triton for frequency capping, measurement etc., while the other IDs can be provided to third-party demand platforms in order to improve monetization. The values for the `LISTENER_ID_TYPE` are: - `ListenerIdType.PPID` - `ListenerIdType.IDFA` - `ListenerIdType.GAID` - `ListenerIdType.APP` Example: ```java 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"); // Add the targeting parameters HashMap targetingParams = new HashMap(); targetingParams.put(StreamUrlBuilder.DIST, "triton-dist-param"); targetingParams.put(StreamUrlBuilder.LISTENER_ID_TYPE, StreamUrlBuilder.ListenerIdType.PPID.getListenerIdType()); targetingParams.put(StreamUrlBuilder.LISTENER_ID_VALUE, "550e8400-e29b-41d4-a716-446655443658"); settings.putSerializable(TritonPlayer.SETTINGS_TARGETING_PARAMS, targetingParams); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Low Delay and Adaptive Buffering When set to `-1 / AUTO MODE` the SDK uses a small (two second) buffer window on initial connection, reducing the amount of delay between playback and real-time. (This is useful for sporting events, live contests, etc.) Because the connection has a small buffer window, if there is network congestion or low bandwidth the buffer will increase by a factor of two if the device cannot maintain proper connection. When set to a value greater than zero (`>0`) the SDK will buffer that many seconds of audio before beginning playback. Use `SettingsLowDelayKey` with an NSNumber object for this feature. Valid values: `-1` (AUTO mode), `0` (Disabled) , `2` to `60` seconds. By default the feature is disabled (` 0 `). ```java // Create the player settings. Bundle settings = new Bundle(); Integer lowDelayValue = 2; settings.putString(TritonPlayer.SETTINGS_STATION_BROADCASTER,   "Triton Digital"); settings.putString(TritonPlayer.SETTINGS_STATION_NAME,          "MOBILEFM"); settings.putString(TritonPlayer.SETTINGS_STATION_MOUNT,         "MOBILEFM_AACV2"); settings.putInt(TritonPlayer.SETTINGS_LOW_DELAY,                lowDelayValue); // Create the player. TritonPlayer player = new TritonPlayer(this, settings); player.play(); ``` ## Timeshift For more information about Timeshift Radio, see the [Streaming Specification](/user/docs/timeshift-radio). For the Timeshift stream to work, use following property: `TritonPlayer.SETTINGS_STATION_MOUNT` ### Seek Forward or Backward To seek forward and backward use the `seek()` function, which takes a value in seconds as a parameter. If the parameter is positive, you seek forward; if it is negative you seek backward. If the value is zero then you seek to the live point. Example: `seek(-10), seek(10), seek(0)` ```java // Create the player settings. Bundle settings = new Bundle(); settings.putBoolean(TritonPlayer.SETTINGS_TIMESHIFT_ENABLED, true); 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(); ... player.seek(10); ``` ### Seek To Live To return to the live stream use the `seekToLive()` function. This will stop the Timeshift stream and connect again to the live stream. ### Get Cloud Stream To get the programs associated with the station use the `getCloudStreamInfo()` function. When the list of programs is received, a notification is sent to the `OnCloudStreamInfoReceivedListener` in the MediaPlayer class. The JSON object looks like this: ```java {     "maximumRewindTimeSec": 10800,     "programs": {           "name": "program",           "program_episode_id": "99999-1678715517259",           "properties": {                 "cue_id": "23337",                 "cue_time_start": "1678715517259",                 "cue_title": "ProgramStart",                 "program_id": "99999",                 "program_time_start": "1678715517259",                 "program_title": "Messy Gossip with Blork",                 "stw_cached": "false",                 "stw_original_type": "stwcue"           }     } } ``` ### Play Program Use `playProgram(String programId)` to select a specific program. The `programId` is the `program_episode_id` that is in the returned JSON object. ### DIST Parameter To use the dist parameter with Timeshift you need to add both timeshifting parameters: - `StreamUrlBuilder.DIST` : used when the stream is connected in live mode. - `StreamUrlBuilder.DIST_TIMESHIFT` : used when the stream is in Timeshift mode. Example of how to add the parameters: ```java // Create the targeting parameters HashMap targetingParams = new HashMap(); targetingParams.put(StreamUrlBuilder.DIST_TIMESHIFT, "timeshift-dist-param"); targetingParams.put(StreamUrlBuilder.DIST, "triton-dist-param"); // Create the player settings. Bundle settings = new Bundle(); 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(); ```