THEOplayer

@objc
public class THEOplayer : NSObject, EventDispatcherProtocol

The THEOplayer object

  • Create a new instance of THEOplayer.

    • Notes: This constructor is for the iOS SDK only

    Declaration

    Swift

    @objc
    public init(configuration: THEOplayerConfiguration? = nil)

    Parameters

    configuration

    Optional A configuration for the new THEOplayer

  • Create a new instance of THEOplayer with a frame.

    • Notes: This constructor is for the iOS SDK only

    Declaration

    Swift

    @objc
    public convenience init(with frame: CGRect, configuration : THEOplayerConfiguration? = nil)

    Parameters

    frame

    The frame rectangle, which describes the THEOplayer view’s location and size in its superview’s coordinate system.

    configuration

    Optional A configuration for the new THEOplayer

  • Create a new instance of THEOplayer.

    • Notes: This constructor is for the tvOS SDK only

  • Create a new instance of THEOplayer with a frame.

    • Notes: This constructor is for the tvOS SDK only

  • Create a new instance of THEOplayer with a frame.

    • Notes: This constructor is for the tvOS SDK only

  • Prepare THEOplayer. If you are using the SDK in a traditional app (e.g. not a client/server app) you should call this function in the AppDelegate’s application(_:didFinishLaunchingWithOptions:) method.

  • The frame rectangle, which describes the THEOplayer view’s location and size in its superview’s coordinate system.

    Declaration

    Swift

    @objc
    public var frame: CGRect { get set }
  • The bounds rectangle, which describes the THEOplayer view’s location and size in its own coordinate system.

    Declaration

    Swift

    @objc
    public var bounds: CGRect { get set }
  • The center of the THEOplayer view’s frame.

    Declaration

    Swift

    @objc
    public var center: CGPoint { get set }
  • An integer bit mask that determines how the THEOplayer view resizes itself when its superview’s bounds change.

    Declaration

    Swift

    @objc
    public var autoresizingMask: UIViewAutoresizing { get set }
  • abr

    Allows you to modify the player’s ABR behavior. See documentation for ABRConfiguration to see how this is done.

    Declaration

    Swift

    public var abr: ABRConfiguration { get set }
  • The list of Text Tracks

    Declaration

    Swift

    public var textTracks: TextTrackList { get }
  • The list of Audio Tracks

    Declaration

    Swift

    public var audioTracks: AudioTrackList { get }
  • The list of Video Tracks

    Declaration

    Swift

    public var videoTracks: VideoTrackList { get }
  • The length of the currently loaded video (in seconds)

    Declaration

    Swift

    public var duration: Double? { get }
  • Sets or returns if the video should automatically start playing

    Remark

    If you set autoplay to true, this will set preload to ‘auto’. Preload will be back to the previous state if you set autoplay back to false. If you want to use autoplay, you should not modify the preload or the autoplay won’t work.

    Declaration

    Swift

    @objc
    public var autoplay: Bool { get set }
  • Sets or Returns the current source of the video After invoking the setter, the player sets the provided playback source and applies the provided parameters in the source description. The source description is an object that should be constructed by the user and which should implement the SourceDescription interface.

    Declaration

    Swift

    @objc
    public var source: SourceDescription? { get set }
  • src

    Returns the current source URL of the video

    Declaration

    Swift

    @objc
    public var src: String? { get }
  • Sets or returns the volume of the video

    Declaration

    Swift

    @objc
    public var volume: Float { get set }
  • Sets or returns whether the audio output of the video is muted or not

    Declaration

    Swift

    @objc
    public var muted: Bool { get set }
  • Return whether the video is seeking or not.

    Declaration

    Swift

    @objc
    public var seeking: Bool { get }
  • Returns whether the video is paused or not.

    Declaration

    Swift

    @objc
    public var paused: Bool { get }
  • Returns whether the video has ended or not.

    Declaration

    Swift

    @objc
    public var ended: Bool { get }
  • Returns whether the player should preload a certain type of data. Default is set to none.

    • none : After setting the source, the player will not load the manifest nor any media files until the play method is invoked on the player.
    • metadata : After setting the source, the player will automatically load the manifest file and will wait for loading media files until the play method is invoked on the player.
    • auto : After setting the source, the player will load both the manifest files and enough media files until a sufficient playback buffer has been obtained.

    Declaration

    Swift

    public var preload: Preload { get }
  • Returns current playback rate of the player.

    1 referring to normal speed.

    Declaration

    Swift

    @objc
    public var playbackRate: Double { get }
  • Sets or returns the presentationMode of the player. Default is set to ‘inline’:

    • ‘inline’: the player will be shown at its original location.
    • ‘fullscreen’: the player will play in fullscreen.

    Declaration

    Swift

    public var presentationMode: PresentationMode { get set }
  • Returns the readystate of the player. Default is set to HAVE_NOTHING.

    • 0 - HAVE_NOTHING : The player has no information about the duration of its source.
    • 1 - HAVE_METADATA : The player has information about the duration of its source.
    • 2 - HAVE_CURRENT_DATA : The player has its current frame in its buffer.
    • 3 - HAVE_FUTURE_DATA : The player has enough data for immediate playback.
    • 4 - HAVE_ENOUGH_DATA : The player has enough data for continuous playback.

    Declaration

    Swift

    public var readyState: ReadyState { get }
  • Returns the last encountered player error.

    Declaration

    Swift

    @objc
    public var error: String? { get }
  • After invoking this method, the player starts playback.

    Declaration

    Swift

    @objc
    public func play()
  • After invoking this method, the player pauses playback.

    Declaration

    Swift

    @objc
    public func pause()
  • After invoking this method, the player stops playback completely and unloads all loaded resources.

    Declaration

    Swift

    public func stop (completionHandler: ((Bool?, Error?) -> Void)? = nil)

    Parameters

    completionHandler

    A optional closure to invoke when operation completes or fails. The closure take two optionals arguments A success flag and an error. If the operation completes, the success flag is true and the error is nil. If the operation fails, the success flag is false and the error indicates the problem.

  • Declaration

    Swift

    public func addEventListener<E>(type: EventType<E>, listener : @escaping (_ : E) -> ()) -> EventListener
  • Declaration

    Swift

    public func removeEventListener<E>(type: EventType<E>, listener: EventListener) where E : EventProtocol
  • Requests the current playback position in the video (in seconds)

    Declaration

    Swift

    public func requestCurrentTime(completionHandler: @escaping (Double?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Sets the current playback position in the video

    Declaration

    Swift

    @objc
    public func setCurrentTime(_ newValue: Double, completionHandler: ((Any?, Error?) -> Swift.Void)? = nil)

    Parameters

    newValue

    The new playback position in seconds

    completionHandler

    Optional A closure to invoke when operation completes or fails

  • Requests the height of the video in pixels for the current quality

    Declaration

    Swift

    public func requestVideoHeight(completionHandler: @escaping (Int?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Requests the width of the video in pixels for the current quality

    Declaration

    Swift

    public func requestVideoWidth(completionHandler: @escaping (Int?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Sets whether the player should preload a certain type of data.

    Declaration

    Swift

    public func setPreload(_ newValue: Preload, completionHandler: ((Any?, Error?) -> Swift.Void)? = nil)

    Parameters

    newValue

    The new preload value

    completionHandler

    Optional A closure to invoke when operation completes or fails

  • Requests the current ProgramDateTime of the player.

    Declaration

    Swift

    @objc
    public func requestCurrentProgramDateTime(completionHandler: @escaping (Date?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Sets the current ProgramDateTime of the player.

    Declaration

    Swift

    @objc
    public func setCurrentProgramDateTime(_ newValue: Date, completionHandler: ((Any?, Error?) -> Swift.Void)? = nil)

    Parameters

    newValue

    The new ProgramDateTime

    completionHandler

    Optional A closure to invoke when operation completes or fails

  • Sets the playback rate of the player.

    Declaration

    Swift

    @objc
    public func setPlaybackRate(_ newValue: Double, completionHandler: ((Any?, Error?) -> Swift.Void)? = nil)

    Parameters

    newValue

    The new playback rate

    completionHandler

    Optional A closure to invoke when operation completes or fails

  • Request the buffered TimeRanges of the player.

    Declaration

    Swift

    @objc
    public func requestBuffered(completionHandler: @escaping ([TimeRange]?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Request the played TimeRanges of the player.

    Declaration

    Swift

    @objc
    public func requestPlayed(completionHandler: @escaping ([TimeRange]?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Adds the THEOplayer view to the end of the parameter view’s list of subviews.

    Declaration

    Swift

    @objc
    public func addAsSubview(of view: UIView)

    Parameters

    view

    The view on which the THEOplayer view will be added as a subview.

  • Inserts the THEOplayer view at the specified index of the parameter view’s list of subviews.

    Declaration

    Swift

    @objc
    public func insertAsSubview(of view: UIView, at: Int)

    Parameters

    view

    The view on which the THEOplayer view will be added as a subview.

    at

    The index in the array of the subviews property at which to insert the THEOplayer view. Subview indices start at 0 and cannot be greater than the number of subviews.

  • Inserts the THEOplayer view below another view in the parameter view’s hierarchy.

    Declaration

    Swift

    @objc
    public func insertAsSubview(of view: UIView, belowSubview siblingSubview: UIView)

    Parameters

    view

    The view on which the THEOplayer view will be added as a subview.

    siblingSubview

    The sibling view that will be above the THEOplayer view.

  • Inserts the THEOplayer view above another view in the parameter view’s hierarchy.

    Declaration

    Swift

    @objc
    public func insertAsSubview(of view: UIView, aboveSubview siblingSubview: UIView)

    Parameters

    view

    The view on which the THEOplayer view will be added as a subview.

    siblingSubview

    The sibling view that will be behind the inserted THEOplayer view.

  • Returns a Boolean value indicating whether the THEOplayer is contained the given array of UIview.

    self.theoplayer.isContained(in: self.view.subviews)
    

    Declaration

    Swift

    @objc
    public func isContained(in views: [UIView]) -> Bool

    Parameters

    views

    The array of views in which search for the THEOplayer.

  • Requests Metrics data

    Declaration

    Swift

    @objc
    public func requestMetrics(completionHandler: @escaping (Any?,Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes to retreive Metrics or when an error is thrown

  • Request the seekable TimeRanges of the player.

    Declaration

    Swift

    @objc
    public func requestSeekable(completionHandler: @escaping ([TimeRange]?, Error?) -> Void)

    Parameters

    completionHandler

    A closure to invoke when operation completes or fails

  • Unloads the THEOplayer. All future calls to this object will throw an error.

    Declaration

    Swift

    @objc
    public func destroy()
  • ads

    An Ads object that contains information about the current and the scheduled advertisements.

    Declaration

    Swift

    public var ads: Ads { get }
  • pip

    A pip object to configure Picture-In-Picture.

    Declaration

    Swift

    public var pip: PictureInPicture? { get }
  • A related object to configure Related Content.

    Declaration

    Swift

    public var related: RelatedContent { get }
  • Turns on or off the coupling of fullscreen and device orientation. This means that landscape will be coupled to fullscreen mode and portrait will be couple to non-fullscreen mode. Switching rotation or fullscreen state will also trigger changin to the couple counterpart. Default is set to false.

    Declaration

    Swift

    @objc
    public var fullscreenOrientationCoupling: Bool { get set }
  • Add a JavaScript message listener When using a custom JavaScript file, you can communicate to native code through the window.webkit.messageHandlers.‘messageName’.postMessage() method.

    Declaration

    Swift

    @objc
    public func addJavascriptMessageListener(name: String, listener : @escaping (_ : [String:Any]) -> ())

    Parameters

    name

    The name of the message

    listener

    The callback invoked in native code.

  • Remove a JavaScript message listener previously added with addMessageListener(name:listener:)

    Declaration

    Swift

    @objc
    public func removeJavascriptMessageListener(name: String)

    Parameters

    name

    The name of the message

  • Evaluates a JavaScript string. The method sends the result of the script evaluation (or an error) to the completion handler. The completion handler always runs on the main thread.

    Declaration

    Swift

    @objc
    public func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((Any?, Error?) -> Void)? = nil)

    Parameters

    javaScriptString

    The JavaScript string to evaluate.

    completionHandler

    A block to invoke when script evaluation completes or fails.

  • vr

    An VR object to access and control 360/VR playback.

    Declaration

    Swift

    @available(iOS 11.0, *)
    public var vr: VR? { get set }
  • The Cache object to access the caching API.

    • Usage: THEOplayer.cache

    Declaration

    Swift

    @available(iOS 10.0, *)
    public static var cache: Cache
  • The Cast object helps you configure and control casting to external devices with THEOplayer.

    Declaration

    Swift

    public var cast: Cast? { get set }