OTVAVPlayer
public class OTVAVPlayer : AVPlayer
-
Network analytics for the player
Declaration
Swift
@objc public private(set) var networkAnalytics: OTVNetworkAnalytics? { get }
-
Playback analytics for the player
Declaration
Swift
@objc 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 public var subtitleView: UIView? { get set }
-
Private init with AVPlayerItem which should not be called outside. Creates an instance of
OTVAVPlayer
using 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
item
AVPlayerItem
item to be played. -
Creates an instance of
OTVAVPlayer
using 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
URL
URL of the content to be played.
-
Creates an instance of
OTVAVPlayer
using 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 theOTVDRMManager
to 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
public convenience init(playerItem item: OTVAVPlayerItem? = nil)
Parameters
item
OTVAVPlayerItem
item 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
public func setLicenseDelegate(_ delegate: OTVLicenseDelegate)
Parameters
delegate
An 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
item
AVPlayerItem
to be played.
-
Returns an array of tracks available for the specified type.
Declaration
Swift
@objc public func tracks(type: OTVTrackType) -> [OTVTrackInfo]
Parameters
type
The type of tracks to return
-
Returns the selected track index for the specified type, or -1 if nothing is selected.
Declaration
Swift
@objc public func selectedTrack(type: OTVTrackType) -> Int
Parameters
type
The type of track to return
-
Selects the specified track
Declaration
Swift
@objc public func selectTrack(type: OTVTrackType, index: Int)
Parameters
type
The type of the track to select
index
The index of the track to select
-
Deselects the specified track.
Declaration
Swift
@objc public func deselectTrack(type: OTVTrackType, index: Int)
Parameters
type
The type of the track to deselect
index
The 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 public func register(tracksChangedListener: OTVTracksChangedListener)
Parameters
tracksChangedListener
The listener
-
Unregisters a listener for when the tracks available change
Declaration
Swift
@objc public func unregister(tracksChangedListener: OTVTracksChangedListener)
Parameters
tracksChangedListener
The listener
-
Add an external SRT subttile from a given URL
Declaration
Swift
@objc(addSubtitleWithUrl:mimeType:language:) public func addSubtitleWithUrl(subtitleURL: String, mimeType: String, language: String)
Parameters
subtitleURL
The URL of the subtitle
mimeType
The mimeType of the subtitle
language
The Language of the subtitle