APSMediaPlayerOverlayControllerProtocol
Objective-C
@protocol APSMediaPlayerOverlayControllerProtocol <KRAdapter>
Swift
protocol APSMediaPlayerOverlayControllerProtocol
The APSMediaPlayerOverlayController
defines all the methods that a UIViewController
subclass must or can implement to be able to register as an overlay controller with the player. This protocol extends the KRAdapter
protocol, so objects should also implement a type
method, returning a unique string to register under.
To use:
- Create a new class that implements this protocol
Register it with the player shared instance:
[[APSMediaPlayer sharedInstance] registerClass:[<YOURCLASS> class] inGroup:kAPSMediaPlayerOverlayControllersGroup];
Set up with the
APSMediaOverlay
:overlay.type = @"<YOURSTRINGCONSTANT>"
-
This method is invoked by the player when first diplaying the overlay controller object.
Declaration
Objective-C
- (void)load;
Swift
func load()
-
This method is invoked by the player on a background thread, before the overlay start point, as set by the [APSMediaEvent preTriggerInterval] property.
Declaration
Objective-C
- (void)preload;
Swift
optional func preload()
-
This method is called whenever the playback state of the player is changed (e.g. current playback time changes, playback state changes etc.). If the overlay controller needs to update its interface as a result of these changes, the updates should be performed in this method.
The method is invoked on the main application thread.
Declaration
Objective-C
- (void)update;
Swift
optional func update()
-
This method is invoked by the player, before the overlay controller’s view is removed from the player surface. Any overlay cleanup code should be performed in this method.
The method is invoked on the main application thread.
Declaration
Objective-C
- (void)overlayWillBeRemoved;
Swift
optional func overlayWillBeRemoved()
-
This method is invoked by the player, when fullscreen mode is enabled.
Declaration
Objective-C
- (void)didEnterFullscreen;
Swift
optional func didEnterFullscreen()
-
This method is invoked by the player, when fullscreen mode is disabled.
Declaration
Objective-C
- (void)didExitFullscreen;
Swift
optional func didExitFullscreen()
-
This method is invoked by the player, when picture in picture mode is enabled.
Declaration
Objective-C
- (void)didStartPictureInPicture;
Swift
optional func didStartPictureInPicture()
-
This method is invoked by the player, when picture in picture mode is disabled.
Declaration
Objective-C
- (void)didStopPictureInPicture;
Swift
optional func didStopPictureInPicture()
-
Allows an overlay controller to return a current playback time in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - returns: The current overlay-managed playback time, in seconds.
Declaration
Objective-C
- (NSTimeInterval)currentPlaybackTime;
Swift
optional func currentPlaybackTime() -> TimeInterval
-
Allows an overlay controller to return a total playable (buffered) time in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - returns: The current overlay-managed total playable (buffered) time, in seconds.
Declaration
Objective-C
- (NSTimeInterval)playableDuration;
Swift
optional func playableDuration() -> TimeInterval
-
Allows an overlay that handles media playback in place of the parent unit to internally set the current playback time.
Declaration
Objective-C
- (void)setCurrentPlaybackTime:(NSTimeInterval)playbackTime;
Swift
optional func setCurrentPlaybackTime(_ playbackTime: TimeInterval)
Parameters
playbackTime
The required playback time to seek to, in seconds.
-
Allows an overlay controller to return a total playback duration in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - parameter: playbackTime The total overlay-managed playback duration, in seconds.
Declaration
Objective-C
- (NSTimeInterval)duration;
Swift
optional func duration() -> TimeInterval
-
Allows an overlay controller to return a playback state in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - returns: The current overlay-managed playback state.
Declaration
Objective-C
- (APSMoviePlaybackState)playbackState;
Swift
optional func playbackState() -> APSMoviePlaybackState
-
Allows an overlay controller to return a load state in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - returns: The current overlay-managed load state.
Declaration
Objective-C
- (APSMovieLoadState)loadState;
Swift
optional func loadState() -> APSMovieLoadState
-
Allows an overlay controller to return a media source type in place of the parent
APSMediaUnit
object, if theurl
property of that object is nil.This occurs for overlays that handle media playback in place of the parent unit, for e.g. the Youtube player overlay controller. *
- - returns: The current overlay-managed media source type.
Declaration
Objective-C
- (APSMovieSourceType)movieSourceType;
Swift
optional func movieSourceType() -> APSMovieSourceType
-
Allows an overlay that handles media playback in place of the parent unit to start playback.
Declaration
Objective-C
- (void)play;
Swift
optional func play()
-
Allows an overlay that handles media playback in place of the parent unit to stop playback.
Declaration
Objective-C
- (void)stop;
Swift
optional func stop()
-
Allows an overlay that handles media playback in place of the parent unit to pause playback.
Declaration
Objective-C
- (void)pause;
Swift
optional func pause()
-
Allows an overlay that handles media playback in place of the parent unit to return a thumbnail image at a specific time interval from the managed video.
Warning
This method should execute blocking operations on a background thread, and should invoke the callback block on the main thread.
Declaration
Objective-C
- (void)thumbnailAt:(NSTimeInterval)playbackTime withCompletionBlock:(APSThumbnailGeneratedBlock _Nonnull)block;
Swift
optional func thumbnail(at playbackTime: TimeInterval, withCompletionBlock block: @escaping APSThumbnailGeneratedBlock)
Parameters
playbackTime
The time when the thumbnail should be taken from the video.
block
The block to be invoked on thumbnail generation completion.
-
Allows an overlay controller to specify what action the player should take when it comes back into focus, after a modal in-app web browser was triggered and dismissed by user interaction.
Declaration
Objective-C
- (APSWebviewDismissedAction)onWebviewDismiss;
Swift
optional func onWebviewDismiss() -> APSWebviewDismissedAction
Return Value
The desired action. See
APSWebviewDismissedAction
for more details.