VideoPlayerDelegate
@protocol VideoPlayerDelegate <NSObject>
The VideoPlayerDelegate provides event callbacks for the VideoPlayer. VideoPlayerDelegate provides a small set of delegate methods in favor of notifications to allow multiple receivers of the VideoPlayer event callbacks since only one player is typically used in an application. - warning: These callbacks don’t necessarily occur on the main thread so make sure you wrap any UI code in a GCD block: @code dispatch_async(dispatch_get_main_queue(), ^{ // Update UI });
-
Callback triggered by this component to notify delegate about the state of the AVPlayer e.g. loading and priming its buffers for video playback, seeking, paused, reached end of file.
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer State:(VideoPlayerState)state;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, state: VideoPlayerState)
Parameters
videoplayer
the AVPlayer instance whose state is being reported
state
a state from the VideoPlayerState enumeration
-
Callback to inform delegate about current play time. This is called every 250 milliseconds.
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer updatedPosition:(NSTimeInterval)time;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, updatedPosition time: TimeInterval)
Parameters
videoplayer
AVPlayer instance
time
current time in the form of a CMTime
-
Callback to inform delegate that the video player has reached the end of file
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer reachedEndOfVideoFile:(AVPlayerItem *)videoAsset;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, reachedEndOfVideoFile videoAsset: AVPlayerItem!)
Parameters
videoplayer
AVPlayer instance
videoAsset
video item
-
Callback to inform that duration information is available. Duration is given in seconds.
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer DurationAvailable:(NSTimeInterval)duration;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, durationAvailable duration: TimeInterval)
Parameters
videoplayer
AVPlayer instance playing the video
duration
duration in seconds.
-
Callback to inform that track information in the asset loaded for playback is available.
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer TrackInfoAvailable:(NSArray<AVPlayerItemTrack *> *)tracks;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, trackInfoAvailable tracks: [AVPlayerItemTrack]!)
Parameters
videoplayer
AVPlayer instance playing the video
track
duration in seconds.
-
Callback to inform that loaded video time ranges are available. This can be used to calculate current playable duration
Declaration
Objective-C
- (void)VideoPlayer:(VideoPlayerView *)videoplayer LoadedTimeRanges:(NSArray *)ranges;
Swift
optional func videoPlayer(_ videoplayer: VideoPlayerView!, loadedTimeRanges ranges: [Any]!)
Parameters
videoplayer
AVPlayer instance playing the video
ranges
A list of loaded time ranges.