API reference
Public classes
Name | Description |
---|---|
VdoCipher | Provides delegate setup method |
VdoAsset | Asset referenced with a video-id |
VdoError | Provides error message and code |
AssetPlaybackDelegate | Player events delegate |
ClosedCaption | Basic information about a closed caption of a video |
DownloadInfo | Encapsulates all the required information of a VdoAsset undergoes Download cycle |
DownloadInfoFilter | Defines filters to extract results from 'getListOfDownloads' Api |
MediaInfo | Basic information of a downloaded video |
VdoPlayerViewController | UIViewController embedded with VdoCipher player |
VdoPlayerViewControllerDelegate | Provides methods for callbacks from Vdo Player View with custom controls |
VdoViewManager | Supports SwiftUI |
PlayerView | ContentView integrated with AVPlayer |
class
VdoCipher
Properties
Name | Type | Description |
---|---|---|
preferredCaptionsLanguage | String? | 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. |
enablePiPMode | Bool | Enables/Disables Pip mode option on the UI Player |
enableAutoPlay | Bool | Enables/Disables auto-play mode of the assets on UI Player |
Methods
static func setPlaybackDelegate(delegate: AssetPlaybackDelegate)
static func getVdoPlayerViewController() -> VdoPlayerViewController
static func getListOfDownloads(filterBy filter: VdoFramework.DownloadInfoFilter = DownloadInfoFilter(
videoId: nil)) -> [VdoFramework.DownloadInfo]
static func setUIPlayerDelegate(_ delegate: VdoFramework.VdoPlayerViewControllerDelegate)
class
VdoAsset
Properties
Name | Type | Description |
---|---|---|
title | String | |
downloadState | VdoAsset.DownloadState | |
percentDownlaoded | Double | |
videoId | String | |
captions | [VdoFramework.ClosedCaption ] | |
duration | Double | |
aspectRatio | Double | |
posters | [VdoAsset.Poster ] | |
Poster | static struct - url - height | |
DownloadState | static enum - notDownloaded - downloading - downloaded - paused | |
Keys | static struct - videoId - percentDownloaded - downloadState | |
VideoQuality | class - 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
Name | Type | Description |
---|---|---|
message | string | |
code | int |
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
Name | Type |
---|---|
lang | string |
label | string |
captionName | string |
class
DownloadInfo
Properties
Name | Type |
---|---|
mediaInfo | VdoFramework.MediaInfo |
poster | string |
status | VdoAsset.DownloadState |
percentDownloaded | Double |
aspectRatio | Double |
class
DownloadInfoFilter
Properties
Name | Type |
---|---|
videoId | string |
downloadState | VdoAsset.DownloadState |
Initializer
init(videoId: [String]?, downloadState: [VdoFramework.VdoAsset.DownloadState] = [.paused, .downloaded, .downloading])
class
MediaInfo
Properties
Name | Type |
---|---|
videoId | string |
title | string |
mediaDescription | string |
duration | double |
class
VdoPlayerViewController
Methods
func enterFullscreen()
func exitFullscreen()
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.
- AssetDownloadProgress
- AssetDownloadStateChanged
- AssetPersistenceManagerDidRestoreState
- AssetDownloadFailed
ObservableObject class
VdoViewManager
Properties
Name | Type | Description |
---|---|---|
id | String | videoId |
loadError | VdoError | publishes an error message and code when VdoViewManager loads a video |
posterImage | URL | publishes an URL of best quality poster image |
title | String | publishes title of the video |
downloadState | VdoAsset.DownloadState | publishes download state of the video |
percentDownload | Double | publishes download progress of the video |
downloadError | VdoError | publishes 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
/**
`enablePiPMode` set this flag to enable/disable Picture-in-Picture (PiP) feature on supported devices.
Default value is `true`, enabling PiP on the UI Player of the SDK.
Background capability for Picture in Picture should be enabled (checked) in app's target `Info.plist`.
*/
@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: any 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() -> VdoFramework.VdoPlayerViewController
/// Best parctices - should be called in `viewDidAppear: Bool` method
@available(iOS 12.0, *)
public static func setUIPlayerDelegate(_ delegate: any 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 {
}
@objc public class VdoPlayerViewController : UIViewController {
@objc public func enterFullscreen()
@objc public func exitFullscreen()
}
/// `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
}