TPLPlayer
@interface TPLPlayer : NSObject
TPLPlayer class to control and observe audio video content and receive timed metadata.
-
Set this property to be notified about Player events such as connection, and the playback status. All delegate callbacks are invoked on the main queue.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<TPLPlayerDelegate> delegate;
-
For a live stream, the latency to the source.
Declaration
Objective-C
@property (nonatomic, readonly) CMTime liveLatency;
-
Logging level for the player. Default is
TPLLogLevelError
.Declaration
Objective-C
@property (nonatomic) TPLLogLevel logLevel;
-
The logger used to log the Twilio Live Player SDK messages.
Declaration
Objective-C
@property (class, nonatomic, nonnull) id<TPLLogger> logger;
-
The audio-muting state of the Player. Default is
false
.Declaration
Objective-C
@property (nonatomic, getter=isMuted) BOOL muted;
-
Playback position.
Declaration
Objective-C
@property (nonatomic, readonly) CMTime position;
-
Represents Player’s playback status.
Declaration
Objective-C
@property (nonatomic, readonly) TPLPlayerState state;
-
Current quality being played, if any.
This property returns nil before an initial quality has been determined.
This property is key-value observable.
Declaration
Objective-C
@property (nonatomic, nullable) TPLPlayerQuality *quality;
-
Quality objects from the loaded source or empty if none are currently available. The qualities will be available after the
TPLPlayerStateReady
state has been entered. This contains the qualities that can be assigned toquality
. Note that this set will contain only qualities capable of being played on the current device and not all those present in the source stream.Declaration
Objective-C
@property (nonatomic, readonly, nonnull) NSArray<TPLPlayerQuality *> *availableQualities;
-
A PlayerStreamer SID.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nonnull) NSString *streamerSid;
-
Represents Player’s stats
Declaration
Objective-C
@property (nonatomic, readonly, nonnull) TPLPlayerStats *stats;
-
Native size of the current video source, in pixels. Default:
CGSizeZero
until the first frame is rendered.See
-[TPLPlayerDelegate player:didChangeVideoSize:]
Declaration
Objective-C
@property (nonatomic, readonly) CGSize videoSize;
-
Volume of the audio track, if any. Supported range: 0.0 to 1.0. Default: 1.0 (max).
Declaration
Objective-C
@property (nonatomic) float volume;
-
A Player SDK telemetry emitter. Reference the snippet below to subscribe to telemetry data in your application. This data can be used for reporting Player SDK events and metrics to your applications analytics.
Usage:
Subscribe the logger to events Player.telemetry.subscribe(subscriber) extension Subscriber: TelemetrySubscriber { func didReceiveTelemetryData(_ data: TelemetryData) { os_log("TELEMETRY : %@", log: log, type:.default, "\(data)") } }
Declaration
Objective-C
@property (class, nonatomic, readonly, nonnull) TPLTelemetry *telemetry;
-
Returns whether the Player SDK will apply high latency reduction strategies when high latency is detected. This property defaults to
true
. The Player SDK considers aPlayer.liveLatency
value greater than 3 seconds as an occurrence of high latency. When this property is enabled, the Player SDK will periodically inspectPlayer.liveLatency
and perform the following when high latency is observed:- If the live latency is between 3 and 5 seconds, the Player will increase the playback rate to a value that should not be perceptible to a user. The increased playback rate will allow the Player to catch up to the live source, and will be reverted once the live latency drops below 3 seconds. Application of this strategy may result in audio pitch distortion.
- If the live latency is above 5 seconds, the Player will seek ahead to near the end of the Player’s buffered content. The user will notice skips in the media content when this strategy is applied.
Declaration
Objective-C
@property (class, nonatomic, assign, unsafe_unretained, readwrite, getter=isHighLatencyReductionEnabled) BOOL highLatencyReductionEnabled;
-
A view that renders Player media content.
Declaration
Objective-C
@property (nonatomic, strong, nullable) TPLPlayerView *playerView;
-
Pauses playback.
state
transitions toTPLPlayerStateIdle
.Declaration
Objective-C
- (void)pause;
-
Starts or resumes playback of the current stream. On success depending on the type of stream the player state will change to
TPLPlayerStateBuffering
and thenTPLlayerStatePlaying
or justTPLPlayerStatePlaying
. On failure invokes the error delegate.Declaration
Objective-C
- (void)play;
-
Unavailable
TPLPlayer can not be created with init
Developers shouldn’t initialize this class directly.
TPLPlayer
can not be created with init.Declaration
Objective-C
- (null_unspecified instancetype)init;
-
Connect to a Live Stream with a Twilio Access Token and a delegate.
Declaration
Objective-C
+ (nonnull TPLPlayer *)connectWithAccessToken:(nonnull NSString *)accessToken delegate:(nullable id<TPLPlayerDelegate>) delegate;
Parameters
accessToken
The Twilio Access Token.
delegate
A delegate conforming to
TPLPlayerDelegate
for handling Player related events. @throws If the runtime IVS SDK version does not match the build time version.Return Value
An instance of
TPLPlayer
. -
API to return the SDK version.
Declaration
Objective-C
+ (nonnull NSString *)sdkVersion;
Return Value
Player sdk version of type string.