//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-av-foundation")]
use objc2_av_foundation::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// AVPictureInPictureController is a subclass of NSObject that can be used to present the contents of an AVPlayerLayer or AVPlayerView floating on top of applications.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontroller?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPictureInPictureController;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVPictureInPictureController {}
);
impl AVPictureInPictureController {
extern_methods!(
/// Whether or not Picture in Picture is supported on the current device.
///
/// When NO, all initializers will return nil.
#[unsafe(method(isPictureInPictureSupported))]
#[unsafe(method_family = none)]
pub unsafe fn isPictureInPictureSupported() -> bool;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
/// System default Picture in Picture start template image for use in client's Picture in Picture button.
#[unsafe(method(pictureInPictureButtonStartImage))]
#[unsafe(method_family = none)]
pub unsafe fn pictureInPictureButtonStartImage() -> Retained<NSImage>;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
/// System default Picture in Picture stop template image for use in client's Picture in Picture button.
#[unsafe(method(pictureInPictureButtonStopImage))]
#[unsafe(method_family = none)]
pub unsafe fn pictureInPictureButtonStopImage() -> Retained<NSImage>;
/// Parameter `contentSource`: The content source to be shown in Picture in Picture.
///
/// Use this initializer for content that may be a sample buffer display layer or a player layer.
#[unsafe(method(initWithContentSource:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithContentSource(
this: Allocated<Self>,
content_source: &AVPictureInPictureControllerContentSource,
) -> Retained<Self>;
#[cfg(feature = "objc2-av-foundation")]
#[cfg(not(target_os = "watchos"))]
/// Parameter `playerLayer`: The player layer from which to source the media content for the Picture in Picture controller.
///
/// Initialize the picture in picture controller with a player layer.
#[unsafe(method(initWithPlayerLayer:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithPlayerLayer(
this: Allocated<Self>,
player_layer: &AVPlayerLayer,
) -> Option<Retained<Self>>;
/// The receiver's content source. Can be changed while Picture in Picture is active, but the new content source must be ready for display (in the case of AVPlayerLayer, that means AVPlayerLayer.isReadyForDisplay must return YES), otherwise Picture in Picture will stop.
#[unsafe(method(contentSource))]
#[unsafe(method_family = none)]
pub unsafe fn contentSource(
&self,
) -> Option<Retained<AVPictureInPictureControllerContentSource>>;
/// Setter for [`contentSource`][Self::contentSource].
#[unsafe(method(setContentSource:))]
#[unsafe(method_family = none)]
pub unsafe fn setContentSource(
&self,
content_source: Option<&AVPictureInPictureControllerContentSource>,
);
#[cfg(feature = "objc2-av-foundation")]
#[cfg(not(target_os = "watchos"))]
/// The receiver's player layer.
#[unsafe(method(playerLayer))]
#[unsafe(method_family = none)]
pub unsafe fn playerLayer(&self) -> Retained<AVPlayerLayer>;
/// The receiver's delegate.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn AVPictureInPictureControllerDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn AVPictureInPictureControllerDelegate>>,
);
/// Start Picture in Picture for the provided AVPlayerLayer if possible.
///
/// Receiver will call -pictureInPictureControllerWillStartPictureInPicture: if Picture in Picture is currently possible and -pictureInPictureControllerDidStartPictureInPicture: after a successful start. If starting Picture in Picture fails, -pictureInPictureControllerFailedToStartPictureInPicture:withError: is called on the delegate instead. Client can stop Picture in Picture by calling -stopPictureInPicture. In addition the user can stop Picture in Picture through user interaction. It is also possible that Picture in Picture is stopped by the Picture in Picture controller at any time. In all these cases receiver calls -pictureInPictureControllerWillStopPictureInPicture: on the delegate and -pictureInPictureControllerDidStopPictureInPicture:after the stop animation completed.
#[unsafe(method(startPictureInPicture))]
#[unsafe(method_family = none)]
pub unsafe fn startPictureInPicture(&self);
/// Stop the local Picture in Picture if currently active. On tvOS, this can also stop Picture in Picture sessions for other applications.
///
/// See startPictureInPicture for details.
#[unsafe(method(stopPictureInPicture))]
#[unsafe(method_family = none)]
pub unsafe fn stopPictureInPicture(&self);
/// Whether or not Picture in Picture is currently possible.
#[unsafe(method(isPictureInPicturePossible))]
#[unsafe(method_family = none)]
pub unsafe fn isPictureInPicturePossible(&self) -> bool;
/// Whether or not Picture in Picture is currently active.
#[unsafe(method(isPictureInPictureActive))]
#[unsafe(method_family = none)]
pub unsafe fn isPictureInPictureActive(&self) -> bool;
/// Whether or not Picture in Picture is currently suspended.
#[unsafe(method(isPictureInPictureSuspended))]
#[unsafe(method_family = none)]
pub unsafe fn isPictureInPictureSuspended(&self) -> bool;
/// Whether or not any Picture in Picture is active, and can be stopped.
///
/// When true, stopPictureInPicture will stop the active Picture in Picture session. Apps should re-inspect the system-provided picture in picture start button image when this property changes. Observable.
#[unsafe(method(canStopPictureInPicture))]
#[unsafe(method_family = none)]
pub unsafe fn canStopPictureInPicture(&self) -> bool;
/// Disables certain user operations (fast forward, forward skip, and scrubbing).
///
/// This can be used to temporarily enforce playback of mandatory content (such as legalese or advertisements).
#[unsafe(method(requiresLinearPlayback))]
#[unsafe(method_family = none)]
pub unsafe fn requiresLinearPlayback(&self) -> bool;
/// Setter for [`requiresLinearPlayback`][Self::requiresLinearPlayback].
#[unsafe(method(setRequiresLinearPlayback:))]
#[unsafe(method_family = none)]
pub unsafe fn setRequiresLinearPlayback(&self, requires_linear_playback: bool);
/// Indicates whether Picture in Picture should be allowed to start automatically when transitioning to background when the receiver’s content is embedded inline. Default is NO.
///
/// This property must only be set to YES for content intended to be the user's primary focus.
#[unsafe(method(canStartPictureInPictureAutomaticallyFromInline))]
#[unsafe(method_family = none)]
pub unsafe fn canStartPictureInPictureAutomaticallyFromInline(&self) -> bool;
/// Setter for [`canStartPictureInPictureAutomaticallyFromInline`][Self::canStartPictureInPictureAutomaticallyFromInline].
#[unsafe(method(setCanStartPictureInPictureAutomaticallyFromInline:))]
#[unsafe(method_family = none)]
pub unsafe fn setCanStartPictureInPictureAutomaticallyFromInline(
&self,
can_start_picture_in_picture_automatically_from_inline: bool,
);
);
}
/// Methods declared on superclass `NSObject`.
impl AVPictureInPictureController {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// A content source for AVPictureInPictureController.
///
/// Create a content source with an appropriate layer, and use it to initialize the AVPictureInPictureController.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollercontentsource?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPictureInPictureControllerContentSource;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVPictureInPictureControllerContentSource {}
);
impl AVPictureInPictureControllerContentSource {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[cfg(feature = "objc2-av-foundation")]
#[cfg(not(target_os = "watchos"))]
/// Parameter `playerLayer`: The player layer to be shown in Picture in Picture.
///
/// Use this initializer for a content source with a player layer.
#[unsafe(method(initWithPlayerLayer:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithPlayerLayer(
this: Allocated<Self>,
player_layer: &AVPlayerLayer,
) -> Retained<Self>;
#[cfg(feature = "objc2-av-foundation")]
#[cfg(not(target_os = "watchos"))]
/// The receiver's player layer.
#[unsafe(method(playerLayer))]
#[unsafe(method_family = none)]
pub unsafe fn playerLayer(&self) -> Option<Retained<AVPlayerLayer>>;
);
}
extern_protocol!(
/// A protocol for delegates of AVPictureInPictureController.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollerdelegate?language=objc)
pub unsafe trait AVPictureInPictureControllerDelegate: NSObjectProtocol {
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Delegate can implement this method to be notified when Picture in Picture will start.
#[optional]
#[unsafe(method(pictureInPictureControllerWillStartPictureInPicture:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureControllerWillStartPictureInPicture(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
);
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Delegate can implement this method to be notified when Picture in Picture did start.
#[optional]
#[unsafe(method(pictureInPictureControllerDidStartPictureInPicture:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureControllerDidStartPictureInPicture(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
);
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Parameter `error`: An error describing why it failed.
///
/// Delegate can implement this method to be notified when Picture in Picture failed to start.
#[optional]
#[unsafe(method(pictureInPictureController:failedToStartPictureInPictureWithError:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureController_failedToStartPictureInPictureWithError(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
error: &NSError,
);
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Delegate can implement this method to be notified when Picture in Picture will stop.
#[optional]
#[unsafe(method(pictureInPictureControllerWillStopPictureInPicture:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureControllerWillStopPictureInPicture(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
);
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Delegate can implement this method to be notified when Picture in Picture did stop.
#[optional]
#[unsafe(method(pictureInPictureControllerDidStopPictureInPicture:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureControllerDidStopPictureInPicture(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
);
#[cfg(feature = "block2")]
/// Parameter `pictureInPictureController`: The Picture in Picture controller.
///
/// Parameter `completionHandler`: The completion handler the delegate needs to call after restore.
///
/// Delegate can implement this method to restore the user interface before Picture in Picture stops.
#[optional]
#[unsafe(method(pictureInPictureController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:))]
#[unsafe(method_family = none)]
unsafe fn pictureInPictureController_restoreUserInterfaceForPictureInPictureStopWithCompletionHandler(
&self,
picture_in_picture_controller: &AVPictureInPictureController,
completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
);
}
);