Skip to content
Product Documentation

Callbacks on iOS and tvOS

The Arc Mobile Video module for iOS and tvOS offers a huge number of different callbacks to hook into the player’s behavior. The callbacks are available with both the ArcMediaPlayerViewController and the AVPlayerViewController, though specific callbacks may only be available for certain view controllers.

By using the AVPlayerController to control video playback (as opposed to the player view controller or AVPlayer directly), you can register for and receive callbacks for many player and ad lifecycle events. These can be used to update your app’s UI, perform analytics, and anything else you can think of.

The tables below are split into four columns, for the two player view controllers (ArcMediaPlayerViewController and AVPlayerViewController), and the two supported platforms (iOS and tvOS).

All of the delegate functions have empty default implementations, so implement only the ones you’re interested in. The sample app implements them by adding entries to an event timeline table while a video plays.

AdDelegate

Implement the AdDelegate protocol to receive ad-related callbacks. You don’t need to implement these in order to report back to the ad service; the module handles that for you. Assign your implementation to the player controller’s adController?.adDelegate property.

For all callbacks that take an adInfo: parameter, you can cast the value to either a MediaTailor.Avail.Ad (in the module) or a Google IMAAd to get more information, such as the ad ID. See the sample app’s DelegateEventsViewController.logAd(_,_) for an example.

CallbacksFunctioniOS ArcMediaPlayeriOS AVPlayertvOS ArcMediaPlayertvOS AVPlayer
Ad break started (livestream only)player(_:adBreakStarted:)βœ…βœ…βœ…βœ…
Ad completedplayer(_:adCompleted:)βœ…βœ…βœ…βœ…
Ad break ended (livestream only)player(_:adBreakEnded:)βœ…βœ…βœ…βœ…
Ad errorplayer(_:adInfo:adError:)βœ…βœ…βœ…βœ…
Ad startedplayer(_:adStarted:)βœ…βœ…βœ…βœ…
Ad pausedplayer(_:adPaused:)βœ…βœ…βœ…βœ…
Ad resumedplayer(_:adResumed:)βœ…βœ…βœ…βœ…
Ad skipped (pre-roll ads only)player(_:adSkipped:)βœ…βœ…βœ…βœ…
Ad played 25%player(_:adPlayed25Percent:)βœ…βœ…βœ…βœ…
Ad played 50%player(_:adPlayed50Percent:)βœ…βœ…βœ…βœ…
Ad played 75%player(_:adPlayed75Percent:)βœ…βœ…βœ…βœ…
Ad tapped (pre-roll ads only)player(_:adTapped:)βœ…βœ…βœ…βœ…
Ad impression (livestream only)player(_:adImpression:)βœ…βœ…βœ…βœ…
Ad clickedplayer(_ player: AVPlayer, adClicked: **Any**?)βœ…βœ…βœ…βœ…
Ad will open external applicationplayerAdWillOpenExternalApplication(player: AVPlayer)βœ…βœ…βœ…βœ…
Ad will open in-app linkplayerAdWillOpenInAppLink(player: AVPlayer)βœ…βœ…βœ…βœ…
Ad did open in-app linkplayerAdDidOpenInAppLink(player: AVPlayer)βœ…βœ…βœ…βœ…
Ad will close in-app linkplayerAdWillCloseInAppLink(player: AVPlayer)βœ…βœ…βœ…βœ…
Ad did close in-app linkplayerAdDidCloseInAppLink(player: AVPlayer)βœ…βœ…βœ…βœ…

AVPlayerDelegate

Implement the AVPlayerDelegate protocol to receive callbacks for the video player and video lifecycle events. Assign your implementation to the player controller’s delegate property.

Note that the AVPlayerDelegate protocol also extends the AdDelegate protocol.

CallbacksFunctioniOS ArcMediaPlayeriOS AVPlayertvOS ArcMediaPlayertvOS AVPlayer
Captions onplayer(_:captionsOn:)βœ…βœ…
Captions offplayerCaptionsOff(_)βœ…βœ…
Current item changedplayer(_:currentItemChangedFrom:)βœ…βœ…βœ…βœ…
Player errorplayer(_:error:)βœ…βœ…βœ…βœ…
Player appearedplayerAppeared(_)βœ…βœ…
Player readyplayerReady(_)βœ…βœ…βœ…βœ…
Player status unknownplayer(_:statusUnknown)βœ…βœ…βœ…βœ…
Player item errorplayer(_:item:error:)βœ…βœ…βœ…βœ…
Player item readyplayer(_:itemReady:)βœ…βœ…βœ…βœ…
Player item status unknownplayer(_:itemStatusUnknown:)βœ…βœ…βœ…βœ…
Player completed (only for VOD)player(_:completed:)βœ…βœ…βœ…βœ…
Played 25% (only for VOD)player(_:played25Percent:)βœ…βœ…βœ…βœ…
Played 50% (only for VOD)player(_:played50Percent:)βœ…βœ…βœ…βœ…
Played 75% (only for VOD)player(_:played75Percent:)βœ…βœ…βœ…βœ…
Played percent (only for VOD)player(_:item:playedPercent:)βœ…βœ…βœ…βœ…
Player mutedplayerMuted(_)βœ…βœ…βœ…βœ…
Player unmutedplayerUnmuted(_)βœ…βœ…βœ…βœ…
Player volume changedplayer(_:volumeChangedFrom:)βœ…βœ…βœ…βœ…
Player pausedplayer(_:paused:)βœ…βœ…βœ…βœ…
Player resumedplayer(_:resumed:)βœ…βœ…βœ…βœ…
Player skipped to timeplayer(_:item:skippedTo:)βœ…βœ…
Player startedplayer(_:started:byUser:)βœ…βœ…βœ…βœ…

ArcMediaPlayerViewDelegate

Implement this protocol and assign your implementation to ArcMediaPlayerViewController’s playerView.delegate to get callbacks that are specific to the ArcMediaPlayerView. Note that even though the ArcMediaPlayerView is supported on tvOS, the tvOS version does not have a control bar, so these callbacks will never get called.

CallbacksFunctioniOS ArcMediaPlayeriOS AVPlayertvOS ArcMediaPlayertvOS AVPlayer
Player view controller bar will appearplayerViewControlBarWillAppear(_)βœ…
Player view controller bar did appearplayerViewControlBarDidAppear(_)βœ…
Player view controller bar will disappearplayerViewControlBarWillDisappear(_)βœ…
Player view controller bar did disappearplayerViewControlBarDidDisappear(_)βœ