Skip to main content

API reference

Public classes

NameDescription
VdoCipherProvides delegate setup method
VdoAssetAsset referenced with a video-id
VdoErrorProvides error message and code
AssetPlaybackDelegatePlayer events delegate
ClosedCaptionBasic information about a closed caption of a video
DownloadInfoEncapsulates all the required information of a VdoAsset undergoes Download cycle
DownloadInfoFilterDefines filters to extract results from 'getListOfDownloads' Api
MediaInfoBasic information of a downloaded video
VdoPlayerViewControllerDelegateProvides methods for callbacks from Vdo Player View with custom controls
VdoViewManagerSupports SwiftUI
PlayerViewContentView integrated with AVPlayer

class VdoCipher

Properties

NameTypeDescription
preferredCaptionsLanguageString?If more than one captions are available, you can provide a preferred caption language by setting the two letter language code. If not set, default value will be device first language.
enablePiPModeBoolEnables/Disables Pip mode option on the UI Player
enableAutoPlayBoolEnables/Disables auto-play mode of the assets on UI Player

Methods

static func setPlaybackDelegate(delegate: AssetPlaybackDelegate)
static func getVdoPlayerViewController() -> UIViewController
static func getListOfDownloads(filterBy filter: VdoFramework.DownloadInfoFilter = DownloadInfoFilter(
videoId: nil)) -> [VdoFramework.DownloadInfo]
static func setUIPlayerDelegate(_ delegate: VdoFramework.VdoPlayerViewControllerDelegate)

class VdoAsset

Properties

NameTypeDescription
titleString
downloadStateVdoAsset.DownloadState
percentDownlaodedDouble
videoIdString
captions[VdoFramework.ClosedCaption]
durationDouble
aspectRatioDouble
posters[VdoAsset.Poster]
Posterstatic struct
- url
- height
DownloadStatestatic enum
- notDownloaded
- downloading
- downloaded
- paused
Keysstatic struct
- videoId
- percentDownloaded
- downloadState
VideoQualityclass
- resolution
- bitrate
- active

Methods

static func createAsset(videoId: String, playerId: String? = nil, onLoad: @escaping (VdoFramework.VdoAsset?, VdoError?) -> Void)
func playOnline(otp: String, playbackInfo: String, defaultVideoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)
func playOnline(token: String, defaultVideoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)
func enableManualAdaptation(_ activeQuality: VideoQuality)
func enableAutoAdaptation()
func playOffline()
func getDownloadState() -> VdoAsset.DownloadState
func deleteDownload()
func cancelDownload()
func pauseDownload()
func resumeDownload()
func startDownload(otp: String, playbackInfo: String, videoQuality: VideoQuality? = nil)
func startDownload(token: String, videoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)
func getVideoQualities() -> [VdoAsset.VideoQuality]
func setCaption(_ caption: VdoFramework.ClosedCaption?) -> Bool
func getCurrentEnabledCaption() -> VdoFramework.ClosedCaption?

class VdoError

Properties

NameTypeDescription
messagestring
codeint

protocol AssetPlaybackDelegate

Callbacks

func streamPlaybackManager(playerReadyToPlay player: AVFoundation.AVPlayer)
func streamPlaybackManager(playerCurrentItemDidChange player: AVFoundation.AVPlayer)
func streamLoadError(error: VdoError)
optional func streamPlaybackManager(qualityChangedTo quality: VdoFramework.VdoAsset.VideoQuality?)

class ClosedCaption

Properties

NameType
langstring
labelstring
captionNamestring

class DownloadInfo

Properties

NameType
mediaInfoVdoFramework.MediaInfo
posterstring
statusVdoAsset.DownloadState
percentDownloadedDouble
aspectRatioDouble

class DownloadInfoFilter

Properties

NameType
videoIdstring
downloadStateVdoAsset.DownloadState

Initializer

    init(videoId: [String]?, downloadState: [VdoFramework.VdoAsset.DownloadState] = [.paused, .downloaded, .downloading])

class MediaInfo

Properties

NameType
videoIdstring
titlestring
mediaDescriptionstring
durationdouble

protocol VdoPlayerViewControllerDelegate

VdoPlayerViewControllerDelegate provides methods for callbacks from Vdo Player View with custom controls.

Callbacks

optional func didClosePlayer(controller: UIViewController)

Optional method, if implemneted will be called when user taps close button on the fullscreen presented Vdo Player view, with custom controls.

optional func didDismissAlert()

Optional method, if implemneted will be called immediately when the alert presented on the Vdo Player view, is dismissed.

optional func didTapPlay(for id: String)
optional func didTapPause(for id: String)
optional func didTapForward(for id: String)
optional func didTapBackward(for id: String)
optional func didTapClose(for id: String)
optional func didTapEnterFullScreen(for id: String)
optional func didTapExitFullScreen(for id: String)
optional func didTapPip(for id: String)
optional func didTapAirplay(for id: String)
optional func didSeek(for id: String, to time: Float64)
optional func didChangePlayerRate(for id: String, to speed: Float)
optional func didChangeCaption(for id: String, to name: String, code: String)
optional func didChangeChapter(for id: String, to name: String, at time: Float64)
optional func didUpdatePlayback(for id: String, toTime time: Float64)
optional func didSetAdaptation(for id: String, to quality: VdoFramework.VdoAsset.VideoQuality?)
optional func playbackDidPlayToEnd(for id: String)

Notifications

NSNotification.Name is extended to have three new static properties.

  1. AssetDownloadProgress

  2. AssetDownloadStateChanged

  3. AssetPersistenceManagerDidRestoreState

  4. AssetDownloadFailed


ObservableObject class VdoViewManager

Properties

NameTypeDescription
idStringvideoId
loadErrorVdoErrorpublishes an error message and code when VdoViewManager loads a video
posterImageURLpublishes an URL of best quality poster image
titleStringpublishes title of the video
downloadStateVdoAsset.DownloadStatepublishes download state of the video
percentDownloadDoublepublishes download progress of the video
downloadErrorVdoErrorpublishes an error message and code when VdoViewManager is downloading a video

Methods

init(videoId: String, otp: String, playbackInfo: String)
func initiatePlayback(onReadyToPlay: @escaping (VdoFramework.PlayerView?, VdoFramework.VdoError?) -> Void)
func initiateDownload()
func deleteDownload()
func cancelDownload()

The entire swiftinterface file for reference

import AVFoundation
import AVKit
import Combine
import CoreMedia
import Foundation
import MediaPlayer
import ObjectiveC
import SwiftOnoneSupport
import SwiftUI
import UIKit
import VdoFramework.Swift
import AVKit
import _Concurrency

//
// VdoFramework.h
// VdoFramework
//
// Created by Vibhav Sinha on 17/07/21.
//

//! Project version number for VdoFramework.
public var VdoFrameworkVersionNumber: Double

//! Project version string for VdoFramework.
public let VdoFrameworkVersionString: String
/// AssetPlaybackDelegate provides a common interface for AssetPlaybackManager to provide callbacks to its delegate.
@objc(AssetPlaybackDelegate) public protocol AssetPlaybackDelegate {

/// This is called when the internal AVPlayer in AssetPlaybackManager is ready to start playback.
func streamPlaybackManager(playerReadyToPlay player: AVPlayer)

/// This is called when the internal AVPlayer's currentItem has changed.
func streamPlaybackManager(playerCurrentItemDidChange player: AVPlayer)

/// This is called when an error is encountered while playback
func streamLoadError(error: VdoFramework.VdoError)

/// This is called when quality change is observed, nil object will be passed incase auto quality is set
@objc optional func streamPlaybackManager(qualityChangedTo quality: VdoFramework.VdoAsset.VideoQuality?)
}

@objc final public class ClosedCaption : NSObject, Codable {

public let lang: String?

public let label: String?

public let captionName: String?

override public func isEqual(_ object: Any?) -> Bool

override public var hash: Int { get }
}

/// Encapsulates all the required information of a VdoAsset undergoes Download cycle
@objc public class DownloadInfo : NSObject {

@objc public let mediaInfo: VdoFramework.MediaInfo

@objc public let poster: String?

@objc public var status: VdoFramework.VdoAsset.DownloadState

@objc public var percentDownloaded: Double

@objc public let aspectRatio: Double
}

///
/// Defines filters to extract requested results from 'getListOfDownloads' Api
public class DownloadInfoFilter : NSObject {

/// Set this property to attain DownloadInfo of only mentioned videoIds.
public let videoId: [String]?

/// Required property to get DownloadInfo of Assets falling under same DownloadState.
public let downloadState: [VdoFramework.VdoAsset.DownloadState]

public init(videoId: [String]?, downloadState: [VdoFramework.VdoAsset.DownloadState] = [.paused, .downloaded, .downloading])
}

@objc public class MediaInfo : NSObject {

@objc public let videoId: String

@objc public let title: String?

@objc public let mediaDescription: String?

@objc public let duration: Double
}

@available(iOS 13.0.0, *)
public struct PlayerView : View {

public let player: AVPlayer
}

public struct Poster : Codable {

public let url: String?

public let height: Double?
}

@objc public class VdoAsset : NSObject {

@objc public var title: String?

@objc public var downloadState: VdoFramework.VdoAsset.DownloadState

@objc public var percentDownload: Double

@objc public var lastPlaybackTime: CMTime { get }

@objc public private(set) var captions: [VdoFramework.ClosedCaption]? { get }

public let videoId: String

public var duration: Double?

public private(set) var aspectRatio: Double? { get }

public var posters: [VdoFramework.Poster]?

@objc public class VideoQuality : NSObject {

final public let resolution: String

final public let bitrate: UInt

public var active: Bool { get }
}

@available(*, deprecated, message: "Use createAsset(videoId: String, onLoad: @escaping (VdoAsset?, VdoError?) -> Void) instead")
@objc public static func makeAsset(videoId: String, onLoad: @escaping (VdoFramework.VdoAsset) -> Void)

@objc public static func createAsset(videoId: String, playerId: String? = nil, onLoad: @escaping (VdoFramework.VdoAsset?, VdoFramework.VdoError?) -> Void)

@objc public func getVideoQualities() -> [VdoFramework.VdoAsset.VideoQuality]

@objc public func playOnline(otp: String, playbackInfo: String, defaultVideoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)

@objc public func playOnline(token: String, defaultVideoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)

@objc public func enableAutoAdaptation()

@objc public func enableManualAdaptation(_ activeQuality: VdoFramework.VdoAsset.VideoQuality)

@objc public func playOffline()

@objc public func getDownloadState() -> VdoFramework.VdoAsset.DownloadState

@objc public func deleteDownload()

@objc public func cancelDownload()

@objc public func startDownload(otp: String, playbackInfo: String, videoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)

@objc public func startDownload(token: String, videoQuality: VdoFramework.VdoAsset.VideoQuality? = nil)

@objc public func pauseDownload()

@objc public func resumeDownload()
}

/// Extends `Asset` to conform to the `Equatable` protocol.
extension VdoAsset {

public static func == (lhs: VdoFramework.VdoAsset, rhs: VdoFramework.VdoAsset) -> Bool
}

/**
Extends `Asset` to add a simple download state enumeration used by the sample
to track the download states of Assets.
*/
extension VdoAsset {

@objc(DownloadState) public enum DownloadState : Int, RawRepresentable {

/// The asset is not downloaded at all.
case notDownloaded

/// The asset has a download in progress.
case downloading

/// The asset is downloaded and saved on diek.
case downloaded

/// The asset download task is paused.
case paused
}
}

/**
Extends `Asset` to define a number of values to use as keys in dictionary lookups.
*/
extension VdoAsset {

@objc public class Keys : NSObject {

/**
Key for the Asset name, used for `AssetDownloadProgressNotification` and
`AssetDownloadStateChangedNotification` Notifications as well as
AssetListManager.
*/
@objc public static let videoId: String

/**
Key for the Asset download percentage, used for
`AssetDownloadProgressNotification` Notification.
*/
@objc public static let percentDownloaded: String

/**
Key for the Asset download state, used for
`AssetDownloadStateChangedNotification` Notification.
*/
@objc public static let downloadState: String

/**
Key for the error message, used for `AssetDownloadFailed` Notification.
*/
@objc public static let message: String

/**
Key for the error code, used for `AssetDownloadFailed` Notification.
*/
@objc public static let code: String
}
}

extension VdoAsset {

@objc public func setCaption(_ caption: VdoFramework.ClosedCaption?) -> Bool

@objc public func getCurrentEnabledCaption() -> VdoFramework.ClosedCaption?
}

@objc public class VdoCipher : NSObject {

public enum LogLevel : Comparable {

case info

case warning

case error
}

public static var logLevel: VdoFramework.VdoCipher.LogLevel

@objc public static var preferredCaptionsLanguage: String?

@objc public static var enableClipStat: Bool

@objc public static var enablePiPMode: Bool

/// `enableAutoPlay` set this boolean flag to enable/disable auto play of an asset
/// on calling `playOnline(otp:, playbackInfo:, defaultVideoQuality:)` method of `VdoAsset` object,
/// while using the `UI VdoPlayer` of the SDK.
@objc public static var enableAutoPlay: Bool

@objc public static func setPlaybackDelegate(delegate: VdoFramework.AssetPlaybackDelegate)

/// Filtered List of Downloads
///
/// - Parameter filter: 'DownloadInfoFilter'
/// - Returns: Array of 'DownloadInfo'
public static func getListOfDownloads(filterBy filter: VdoFramework.DownloadInfoFilter = DownloadInfoFilter(videoId: nil)) -> [VdoFramework.DownloadInfo]

@available(iOS 12.0, *)
public static func getVdoPlayerViewController() -> UIViewController

/// Best parctices - should be called in `viewDidAppear: Bool` method
@available(iOS 12.0, *)
public static func setUIPlayerDelegate(_ delegate: VdoFramework.VdoPlayerViewControllerDelegate)

/**
Enumerates type of values that can be provided for a playback session
*/
public enum PlaybackProperty : String {

case totalPlayed

case totalCovered
}

/// This Api provides values of playback properties like
/// 'totalPlayed' and 'totalCovered' of the current playback session.
///
/// - Parameter property: Enum PlaybackProperty
/// - Returns: NSDictionary
@available(*, deprecated, message: "Api will be removed in an upcoming release")
public static func getValueOfPlaybackProperty(_ property: VdoFramework.VdoCipher.PlaybackProperty) -> [String : Any]?
}

@objc public class VdoError : NSObject {

public var message: String

public var code: Int
}

extension VdoError : LocalizedError {
}

/// `VdoPlayerViewControllerDelegate` provides the methods for callbacks from the Vdo player view with custom controls.
@objc public protocol VdoPlayerViewControllerDelegate {

@objc optional func didClosePlayer(controller: UIViewController)

@objc optional func didDismissAlert()

@objc optional func didTapPlay(for id: String)

@objc optional func didTapPause(for id: String)

@objc optional func didTapForward(for id: String)

@objc optional func didTapBackward(for id: String)

@objc optional func didTapClose(for id: String)

@objc optional func didTapEnterFullScreen(for id: String)

@objc optional func didTapExitFullScreen(for id: String)

@objc optional func didTapPip(for id: String)

@objc optional func didTapAirplay(for id: String)

@objc optional func didSeek(for id: String, to time: Float64)

@objc optional func didChangePlayerRate(for id: String, to speed: Float)

@objc optional func didChangeCaption(for id: String, to name: String, code: String)

@objc optional func didChangeChapter(for id: String, to name: String, at time: Float64)

@objc optional func didSetAdaptation(for id: String, to quality: VdoFramework.VdoAsset.VideoQuality?)

/// Player periodic callback - receive callbacks as playback progresses, giving the time at which playback session is currently playing
@objc optional func didUpdatePlayback(for id: String, toTime time: Float64)

/// Player playback item played/reached to its end time
@objc optional func playbackDidPlayToEnd(for id: String)
}

@available(iOS 13.0, *)
public class VdoViewManager : ObservableObject {

public let id: String

@Published public var loadError: VdoFramework.VdoError?

@Published public var posterImage: URL?

@Published public var title: String?

@Published public var downloadState: VdoFramework.VdoAsset.DownloadState?

@Published public var percentDownload: Double?

@Published public var downloadError: VdoFramework.VdoError?

public init(videoId: String, otp: String, playbackInfo: String)

public init(videoId: String, token: String)

public func initiatePlayback(onReadyToPlay: @escaping (VdoFramework.PlayerView?, VdoFramework.VdoError?) -> Void)

public func initiateDownload()

public func deleteDownload()

public func cancelDownload()
}

extension NSNotification.Name {

/// Notification for when download progress has changed.
public static let AssetDownloadProgress: Notification.Name

/// Notification for when the download state of an Asset has changed.
public static let AssetDownloadStateChanged: Notification.Name

/// Notification for when AssetPersistenceManager has completely restored its state.
public static let AssetPersistenceManagerDidRestoreState: Notification.Name

/// Notification for when the download Asset has failed.
public static let AssetDownloadFailed: Notification.Name
}