TritonPlayer Class Reference

Inherits from NSObject
Declared in TritonPlayer.h

Overview

TritonPlayer handles the playback of stations provided by Triton Digital. It also supports receiving CuePoint events with metadata for track information, ads etc.

Querying player information

  state

The current state of the player

@property (readonly) TDPlayerState state

Declared In

TritonPlayer.h

  playbackDuration

Returns the current playback duration in seconds. Not available for live streams.

@property (readonly) NSTimeInterval playbackDuration

Declared In

TritonPlayer.h

  currentPlaybackTime

Returns the current playback position in seconds.

@property (readonly) NSTimeInterval currentPlaybackTime

Declared In

TritonPlayer.h

  latestPlaybackTime

Returns the laters CMTime in a seekable range.

@property (readonly) CMTime latestPlaybackTime

Declared In

TritonPlayer.h

  isExecuting

Tells whether the player is streaming audio.

@property (readonly) BOOL isExecuting

Declared In

TritonPlayer.h

  error

When the player’s state is kTDPlayerStateError, this property contains the associated error. It’s nil for all other states.

@property (readonly) NSError *error

Declared In

TritonPlayer.h

– getAudioQueue

The underlying audio queue which playbacks the audio. Use this when you need to process or analyze the audio data. Ex. When building a spectrum analyzer.

- (AudioQueueRef)getAudioQueue

Return Value

The underlying AudioQueue

Declared In

TritonPlayer.h

– getLibVersion

Returns the current library version

- (NSString *)getLibVersion

Return Value

A string containing the current library version.

Declared In

TritonPlayer.h

– isNetworkReachable

Informs if the network is available.

- (BOOL)isNetworkReachable

Return Value

Whether the network is available.

Declared In

TritonPlayer.h

Location targeting

  targetingLocation

The most recent user location available for audience targeting.

@property (readonly) CLLocation *targetingLocation

Declared In

TritonPlayer.h

Handling interruptions

  shouldResumePlaybackAfterInterruption

When an interruption ends (phone call, alarm, siri etc.) this flags will be true when it is appropriate to resume playback without waiting for user input.

@property (readonly) BOOL shouldResumePlaybackAfterInterruption

Discussion

If the user ignored a call, it means that he/she wants to continue listening to the app and the flag will be YES. On the other side, if the interruption was caused by the Music app or other audio app being executed, it means that he/should explicitly play again to continue listening to the stream and the flag will retur NO.

Declared In

TritonPlayer.h

Creating a TritonPlayer

– initWithDelegate:andSettings:

Instantiate a new player using the specified settings

- (id)initWithDelegate:(id<TritonPlayerDelegate>)inDelegate andSettings:(NSDictionary *)settings

Parameters

inDelegate

The delegate for handling stream callbacks and CuePoint events

settings

A NSDictionary containing station parameters.

Declared In

TritonPlayer.h

Updating player settings

– updateSettings:

Update player settings. All the information passed overrides the current settings and will take effect the next time the play method is called.

- (void)updateSettings:(NSDictionary *)settings

Parameters

settings

A NSDictionary containing station parameters.

Discussion

When changing to a new station, this method must be called before calling play on the new station.

Declared In

TritonPlayer.h

Reproduction flow

– play

Plays the current stream with the configuration from the settings dictionary.

- (void)play

Declared In

TritonPlayer.h

– stop

Stops the current stream

- (void)stop

Declared In

TritonPlayer.h

– pause

Pauses the current stream. In case of a live stream, it’s the same as calling stop.

- (void)pause

Declared In

TritonPlayer.h

– seekToTimeInterval:

Moves the cursor to the specified time interval. Only works if the media is seekable.

- (void)seekToTimeInterval:(NSTimeInterval)interval

Parameters

interval

A time interval representing the time elapsed since the start of the audio

Declared In

TritonPlayer.h

– changePlaybackRate:

Moves the cursor to the specified time and invokes the block specified when the seek operation has either been completed or been interrupted. Only works if the media is seekable.

- (void)changePlaybackRate:(float)rate

Parameters

time

A CMTime representing the time elapsed since the start of the audio

completionHandler

The block to be executed when the seek operation has been completed or interrupted.

Declared In

TritonPlayer.h

Controlling the volume

– mute

Mute current playing audio

- (void)mute

Declared In

TritonPlayer.h

– unmute

Unumte current playing audio

- (void)unmute

Declared In

TritonPlayer.h

– setVolume:

Set volume of current playing audio

- (void)setVolume:(float)volume

Parameters

volume

a float between 0-1.

Declared In

TritonPlayer.h

– setAllowsExternalPlayback:

Set external playback on underlying AVPlayer

- (void)setAllowsExternalPlayback:(BOOL)allow

Declared In

TritonPlayer.h

– getCastStreamingUrl

Return the stream URL for Cast Devices

- (NSString *)getCastStreamingUrl

Declared In

TritonPlayer.h

– getSideBandMetadataUrl

Return the Side Band Metadata URL

- (NSString *)getSideBandMetadataUrl

Declared In

TritonPlayer.h

+ toStringState:

Format Player state into String

+ (NSString *)toStringState:(TDPlayerState)state

Parameters

player

state.

Declared In

TritonPlayer.h