OTVAVPlayer
@MainActor
public class OTVAVPlayer : AVPlayer
-
Network analytics for the player
Declaration
Swift
@objc @MainActor public private(set) var networkAnalytics: OTVNetworkAnalytics? { get } -
Playback analytics for the player
Declaration
Swift
@objc @MainActor public private(set) var playbackAnalytics: OTVPlaybackAnalytics? { get } -
A view for rendering non-native subtitles to. This view should be at least as large as the relevant AVPlayerLayer.videoRect, but no wider.
Declaration
Swift
@objc @MainActor public var subtitleView: UIView? { get set } -
Private init with AVPlayerItem which should not be called outside. Creates an instance of
OTVAVPlayerusing anAVPlayerItem. Make sure the item is initialized with OTVAVPlayerItem, otherwise a fatal error will be raised.Declaration
Swift
public override init(playerItem item: AVPlayerItem?)Parameters
itemAVPlayerItemitem to be played. -
Creates an instance of
OTVAVPlayerusing a URL.Note
Calling this function before loading theOTVSDK(withOTVSDK.load()orOTVSDK.load(licence)) will result in a playback error.Declaration
Swift
public override convenience init(url URL: URL)Parameters
URLURL of the content to be played.
-
Creates an instance of
OTVAVPlayerusing anOTVAVPlayerItem.Note
Calling this function before loading theOTVSDK(withOTVSDK.load()orOTVSDK.load(licence)) will result in a playback error. Creating a player instance with a non-nil playerItem means using theOTVDRMManagerto manage the shared license delegate. If the playerItem is nil, there is an option to call ‘setLicenseDelegate’ to pass a license delegate instance. This second license delegate instance can be used for the second player instance.Declaration
Swift
@MainActor public convenience init(playerItem item: OTVAVPlayerItem? = nil)Parameters
itemOTVAVPlayerItemitem to be played. -
Set license delegate to player to handle license request.
Note
This method attaches the license delegate to an clean player, which means it MUST be called on player created byOTVAVPlayer()without any paratemters. If there is only one player instance, this method has the same effect as callingOTVDRMManager.setLicenseDelegate(delegate). If there are more than one active player instance, calling this method is the only way to support encrypted stream playback on that player. The delegate is held using a zeroing-weak reference, so it have a value of nil after a it has been deallocated outside. Ensure the delegate is retained until it is not needed.Declaration
Swift
@MainActor public func setLicenseDelegate(_ delegate: OTVLicenseDelegate)Parameters
delegateAn instance of
OTVLicenseDelegate. -
Replaces the current item being played with another
AVPlayerItem.Note
the item should be anOTVAVPlayerItem, otherwise it will be ignored.Declaration
Swift
public override func replaceCurrentItem(with item: AVPlayerItem?)Parameters
itemAVPlayerItemto be played.
-
Returns an array of tracks available for the specified type.
Declaration
Swift
@objc @MainActor public func tracks(type: OTVTrackType) -> [OTVTrackInfo]Parameters
typeThe type of tracks to return
-
Returns the selected track index for the specified type, or -1 if nothing is selected.
Declaration
Swift
@objc @MainActor public func selectedTrack(type: OTVTrackType) -> IntParameters
typeThe type of track to return
-
Selects the specified track
Declaration
Swift
@objc @MainActor public func selectTrack(type: OTVTrackType, index: Int)Parameters
typeThe type of the track to select
indexThe index of the track to select
-
Deselects the specified track.
Declaration
Swift
@objc @MainActor public func deselectTrack(type: OTVTrackType, index: Int)Parameters
typeThe type of the track to deselect
indexThe index of the track to deselect
-
Registers a listener for when the tracks available change. The listener may be called at any point during playback.
Declaration
Swift
@objc @MainActor public func register(tracksChangedListener: OTVTracksChangedListener)Parameters
tracksChangedListenerThe listener
-
Unregisters a listener for when the tracks available change
Declaration
Swift
@objc @MainActor public func unregister(tracksChangedListener: OTVTracksChangedListener)Parameters
tracksChangedListenerThe listener
-
Add an external SRT subttile from a given URL
Declaration
Swift
@objc(addSubtitleWithUrl:mimeType:language:) @MainActor public func addSubtitleWithUrl(subtitleURL: String, mimeType: String, language: String)Parameters
subtitleURLThe URL of the subtitle
mimeTypeThe mimeType of the subtitle
languageThe Language of the subtitle
-
Provides text/subtitle styling configuration
Declaration
Swift
@objc @MainActor public func configureTextStyle(styling: OTVTextStyle)