ATVVideoPlayer
@interface ATVVideoPlayer : NSObject
Video player that is capable to play VAST 2 video ads and showing subtitles in SRT format.
-
Callback for video player events.
Declaration
Objective-C
@property (readwrite, nonatomic) id<ATVVideoPlayerDelegate> delegate;
Swift
weak var delegate: ATVVideoPlayerDelegate! { get set }
-
VAST Ad schedule configuration. The schedule should be configured before video start.
Declaration
Objective-C
@property (readwrite, strong, nonatomic) ATVAdSchedule *adSchedule;
Swift
var adSchedule: ATVAdSchedule! { get set }
-
SRT subtitle configuation. Call reloadSubtitle if you modify it after video start.
Declaration
Objective-C
@property (readwrite, strong, nonatomic) ATVSubtitleConfig *subtitle;
Swift
var subtitle: ATVSubtitleConfig! { get set }
-
Customize the overlay view. Useful for showing logo when playing video. The overlay layer is not shown when playing video ad.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) int *overlayView;
Swift
var overlayView: UnsafeMutablePointer<Int32>! { get set }
-
Bind the view controller with the video player.
Declaration
Objective-C
- (void)presentWithController:(id)controller;
Swift
func present(withController controller: Any!)
Parameters
controller
controller to be binded.
-
Play video.
Declaration
Objective-C
- (void)playWithMediaItem:(ATVMediaItem *)item startPosition:(NSInteger)startPosition;
Swift
func play(with item: ATVMediaItem!, startPosition: Int)
Parameters
item
ATVMediaItem
startPosition
the starting position of video playback, default is 0
-
Switch subtitle by index. - parameter: index ATVSubtitleConfig subtitle array index
Declaration
Objective-C
- (void)switchSubtitle:(int)index;
Swift
func switchSubtitle(_ index: Int32)
Parameters
index
ATVSubtitleConfig subtitle array index
-
On/Off subtitle - parameter: on Boolean to determine subtitle on/off
Declaration
Objective-C
- (void)toggleSubtitle:(BOOL)on;
Swift
func toggleSubtitle(_ on: Bool)
Parameters
on
Boolean to determine subtitle on/off
-
Start the player.
Declaration
Objective-C
- (void)start;
Swift
func start()
-
Dismiss the player.
Declaration
Objective-C
- (void)dismiss;
Swift
func dismiss()
-
Get current Playing position
Declaration
Objective-C
- (double)currentPosition;
Swift
func currentPosition() -> Double
-
Get duration of video - returns: 0 will be returned when AVPlayerItem is nil
Declaration
Objective-C
- (double)videoDuration;
Swift
func videoDuration() -> Double
Return Value
0 will be returned when AVPlayerItem is nil
-
Get language code of closed captions. Select closed caption with setClosedCaption by this code. This method should be called after player start to play. - returns: list of language code in closed caption. Return empty array if no closed caption found.
Declaration
Objective-C
- (NSArray<NSString *> *)getClosedCaptionLanguageList;
Swift
func getClosedCaptionLanguageList() -> [String]!
Return Value
list of language code in closed caption. Return empty array if no closed caption found.
-
Set closed captions language. No effect if provided language not found. This method should be called after player start to play.
Declaration
Objective-C
- (BOOL)setClosedCaption:(NSString *)language;
Swift
func setClosedCaption(_ language: String!) -> Bool
Parameters
language
code getting from getClosedCaptionLanguageList
Return Value
Boolean to determine set closed caption success or not. Provide invalid code will return False
-
Get current selected closed caption. This method should be called after player start to play. - returns: selected language code.
Declaration
Objective-C
- (NSString *)currentClosedCaption;
Swift
func currentClosedCaption() -> String!
Return Value
selected language code.
-
Disable
Auto
options in subtitle control. This method should be called after player start to play.Declaration
Objective-C
- (void)disableAutoClosedCaptionOptions;
Swift
func disableAutoClosedCaptionOptions()