objc2_av_kit/generated/
AVPictureInPictureController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-av-foundation")]
10use objc2_av_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15extern_class!(
16    /// AVPictureInPictureController is a subclass of NSObject that can be used to present the contents of an AVPlayerLayer or AVPlayerView floating on top of applications.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontroller?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct AVPictureInPictureController;
22);
23
24extern_conformance!(
25    unsafe impl NSObjectProtocol for AVPictureInPictureController {}
26);
27
28impl AVPictureInPictureController {
29    extern_methods!(
30        /// Whether or not Picture in Picture is supported on the current device.
31        ///
32        /// When NO, all initializers will return nil.
33        #[unsafe(method(isPictureInPictureSupported))]
34        #[unsafe(method_family = none)]
35        pub unsafe fn isPictureInPictureSupported() -> bool;
36
37        #[cfg(feature = "objc2-app-kit")]
38        #[cfg(target_os = "macos")]
39        /// System default Picture in Picture start template image for use in client's Picture in Picture button.
40        #[unsafe(method(pictureInPictureButtonStartImage))]
41        #[unsafe(method_family = none)]
42        pub unsafe fn pictureInPictureButtonStartImage() -> Retained<NSImage>;
43
44        #[cfg(feature = "objc2-app-kit")]
45        #[cfg(target_os = "macos")]
46        /// System default Picture in Picture stop template image for use in client's Picture in Picture button.
47        #[unsafe(method(pictureInPictureButtonStopImage))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn pictureInPictureButtonStopImage() -> Retained<NSImage>;
50
51        /// Parameter `contentSource`: The content source to be shown in Picture in Picture.
52        ///
53        /// Use this initializer for content that may be a sample buffer display layer or a player layer.
54        #[unsafe(method(initWithContentSource:))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn initWithContentSource(
57            this: Allocated<Self>,
58            content_source: &AVPictureInPictureControllerContentSource,
59        ) -> Retained<Self>;
60
61        #[cfg(feature = "objc2-av-foundation")]
62        #[cfg(not(target_os = "watchos"))]
63        /// Parameter `playerLayer`: The player layer from which to source the media content for the Picture in Picture controller.
64        ///
65        /// Initialize the picture in picture controller with a player layer.
66        #[unsafe(method(initWithPlayerLayer:))]
67        #[unsafe(method_family = init)]
68        pub unsafe fn initWithPlayerLayer(
69            this: Allocated<Self>,
70            player_layer: &AVPlayerLayer,
71        ) -> Option<Retained<Self>>;
72
73        /// 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.
74        #[unsafe(method(contentSource))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn contentSource(
77            &self,
78        ) -> Option<Retained<AVPictureInPictureControllerContentSource>>;
79
80        /// Setter for [`contentSource`][Self::contentSource].
81        #[unsafe(method(setContentSource:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn setContentSource(
84            &self,
85            content_source: Option<&AVPictureInPictureControllerContentSource>,
86        );
87
88        #[cfg(feature = "objc2-av-foundation")]
89        #[cfg(not(target_os = "watchos"))]
90        /// The receiver's player layer.
91        #[unsafe(method(playerLayer))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn playerLayer(&self) -> Retained<AVPlayerLayer>;
94
95        /// The receiver's delegate.
96        #[unsafe(method(delegate))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn delegate(
99            &self,
100        ) -> Option<Retained<ProtocolObject<dyn AVPictureInPictureControllerDelegate>>>;
101
102        /// This is a [weak property][objc2::topics::weak_property].
103        /// Setter for [`delegate`][Self::delegate].
104        #[unsafe(method(setDelegate:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setDelegate(
107            &self,
108            delegate: Option<&ProtocolObject<dyn AVPictureInPictureControllerDelegate>>,
109        );
110
111        /// Start Picture in Picture for the provided AVPlayerLayer if possible.
112        ///
113        /// 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.
114        #[unsafe(method(startPictureInPicture))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn startPictureInPicture(&self);
117
118        /// Stop the local Picture in Picture if currently active. On tvOS, this can also stop Picture in Picture sessions for other applications.
119        ///
120        /// See startPictureInPicture for details.
121        #[unsafe(method(stopPictureInPicture))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn stopPictureInPicture(&self);
124
125        /// Whether or not Picture in Picture is currently possible.
126        #[unsafe(method(isPictureInPicturePossible))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn isPictureInPicturePossible(&self) -> bool;
129
130        /// Whether or not Picture in Picture is currently active.
131        #[unsafe(method(isPictureInPictureActive))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn isPictureInPictureActive(&self) -> bool;
134
135        /// Whether or not Picture in Picture is currently suspended.
136        #[unsafe(method(isPictureInPictureSuspended))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn isPictureInPictureSuspended(&self) -> bool;
139
140        /// Whether or not any Picture in Picture is active, and can be stopped.
141        ///
142        /// 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.
143        #[unsafe(method(canStopPictureInPicture))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn canStopPictureInPicture(&self) -> bool;
146
147        /// Disables certain user operations (fast forward, forward skip, and scrubbing).
148        ///
149        /// This can be used to temporarily enforce playback of mandatory content (such as legalese or advertisements).
150        #[unsafe(method(requiresLinearPlayback))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn requiresLinearPlayback(&self) -> bool;
153
154        /// Setter for [`requiresLinearPlayback`][Self::requiresLinearPlayback].
155        #[unsafe(method(setRequiresLinearPlayback:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setRequiresLinearPlayback(&self, requires_linear_playback: bool);
158
159        /// 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.
160        ///
161        /// This property must only be set to YES for content intended to be the user's primary focus.
162        #[unsafe(method(canStartPictureInPictureAutomaticallyFromInline))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn canStartPictureInPictureAutomaticallyFromInline(&self) -> bool;
165
166        /// Setter for [`canStartPictureInPictureAutomaticallyFromInline`][Self::canStartPictureInPictureAutomaticallyFromInline].
167        #[unsafe(method(setCanStartPictureInPictureAutomaticallyFromInline:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn setCanStartPictureInPictureAutomaticallyFromInline(
170            &self,
171            can_start_picture_in_picture_automatically_from_inline: bool,
172        );
173    );
174}
175
176/// Methods declared on superclass `NSObject`.
177impl AVPictureInPictureController {
178    extern_methods!(
179        #[unsafe(method(init))]
180        #[unsafe(method_family = init)]
181        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
182
183        #[unsafe(method(new))]
184        #[unsafe(method_family = new)]
185        pub unsafe fn new() -> Retained<Self>;
186    );
187}
188
189extern_class!(
190    /// A content source for AVPictureInPictureController.
191    ///
192    /// Create a content source with an appropriate layer, and use it to initialize the AVPictureInPictureController.
193    ///
194    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollercontentsource?language=objc)
195    #[unsafe(super(NSObject))]
196    #[derive(Debug, PartialEq, Eq, Hash)]
197    pub struct AVPictureInPictureControllerContentSource;
198);
199
200extern_conformance!(
201    unsafe impl NSObjectProtocol for AVPictureInPictureControllerContentSource {}
202);
203
204impl AVPictureInPictureControllerContentSource {
205    extern_methods!(
206        #[unsafe(method(init))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
209
210        #[unsafe(method(new))]
211        #[unsafe(method_family = new)]
212        pub unsafe fn new() -> Retained<Self>;
213
214        #[cfg(feature = "objc2-av-foundation")]
215        #[cfg(not(target_os = "watchos"))]
216        /// Parameter `playerLayer`: The player layer to be shown in Picture in Picture.
217        ///
218        /// Use this initializer for a content source with a player layer.
219        #[unsafe(method(initWithPlayerLayer:))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn initWithPlayerLayer(
222            this: Allocated<Self>,
223            player_layer: &AVPlayerLayer,
224        ) -> Retained<Self>;
225
226        #[cfg(feature = "objc2-av-foundation")]
227        #[cfg(not(target_os = "watchos"))]
228        /// The receiver's player layer.
229        #[unsafe(method(playerLayer))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn playerLayer(&self) -> Option<Retained<AVPlayerLayer>>;
232    );
233}
234
235extern_protocol!(
236    /// A protocol for delegates of AVPictureInPictureController.
237    ///
238    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollerdelegate?language=objc)
239    pub unsafe trait AVPictureInPictureControllerDelegate: NSObjectProtocol {
240        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
241        ///
242        /// Delegate can implement this method to be notified when Picture in Picture will start.
243        #[optional]
244        #[unsafe(method(pictureInPictureControllerWillStartPictureInPicture:))]
245        #[unsafe(method_family = none)]
246        unsafe fn pictureInPictureControllerWillStartPictureInPicture(
247            &self,
248            picture_in_picture_controller: &AVPictureInPictureController,
249        );
250
251        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
252        ///
253        /// Delegate can implement this method to be notified when Picture in Picture did start.
254        #[optional]
255        #[unsafe(method(pictureInPictureControllerDidStartPictureInPicture:))]
256        #[unsafe(method_family = none)]
257        unsafe fn pictureInPictureControllerDidStartPictureInPicture(
258            &self,
259            picture_in_picture_controller: &AVPictureInPictureController,
260        );
261
262        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
263        ///
264        /// Parameter `error`: An error describing why it failed.
265        ///
266        /// Delegate can implement this method to be notified when Picture in Picture failed to start.
267        #[optional]
268        #[unsafe(method(pictureInPictureController:failedToStartPictureInPictureWithError:))]
269        #[unsafe(method_family = none)]
270        unsafe fn pictureInPictureController_failedToStartPictureInPictureWithError(
271            &self,
272            picture_in_picture_controller: &AVPictureInPictureController,
273            error: &NSError,
274        );
275
276        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
277        ///
278        /// Delegate can implement this method to be notified when Picture in Picture will stop.
279        #[optional]
280        #[unsafe(method(pictureInPictureControllerWillStopPictureInPicture:))]
281        #[unsafe(method_family = none)]
282        unsafe fn pictureInPictureControllerWillStopPictureInPicture(
283            &self,
284            picture_in_picture_controller: &AVPictureInPictureController,
285        );
286
287        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
288        ///
289        /// Delegate can implement this method to be notified when Picture in Picture did stop.
290        #[optional]
291        #[unsafe(method(pictureInPictureControllerDidStopPictureInPicture:))]
292        #[unsafe(method_family = none)]
293        unsafe fn pictureInPictureControllerDidStopPictureInPicture(
294            &self,
295            picture_in_picture_controller: &AVPictureInPictureController,
296        );
297
298        #[cfg(feature = "block2")]
299        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
300        ///
301        /// Parameter `completionHandler`: The completion handler the delegate needs to call after restore.
302        ///
303        /// Delegate can implement this method to restore the user interface before Picture in Picture stops.
304        #[optional]
305        #[unsafe(method(pictureInPictureController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:))]
306        #[unsafe(method_family = none)]
307        unsafe fn pictureInPictureController_restoreUserInterfaceForPictureInPictureStopWithCompletionHandler(
308            &self,
309            picture_in_picture_controller: &AVPictureInPictureController,
310            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
311        );
312    }
313);