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        /// Setter for [`delegate`][Self::delegate].
103        ///
104        /// This is a [weak property][objc2::topics::weak_property].
105        #[unsafe(method(setDelegate:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn setDelegate(
108            &self,
109            delegate: Option<&ProtocolObject<dyn AVPictureInPictureControllerDelegate>>,
110        );
111
112        /// Start Picture in Picture for the provided AVPlayerLayer if possible.
113        ///
114        /// 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.
115        #[unsafe(method(startPictureInPicture))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn startPictureInPicture(&self);
118
119        /// Stop the local Picture in Picture if currently active. On tvOS, this can also stop Picture in Picture sessions for other applications.
120        ///
121        /// See startPictureInPicture for details.
122        #[unsafe(method(stopPictureInPicture))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn stopPictureInPicture(&self);
125
126        /// Whether or not Picture in Picture is currently possible.
127        #[unsafe(method(isPictureInPicturePossible))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn isPictureInPicturePossible(&self) -> bool;
130
131        /// Whether or not Picture in Picture is currently active.
132        #[unsafe(method(isPictureInPictureActive))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn isPictureInPictureActive(&self) -> bool;
135
136        /// Whether or not Picture in Picture is currently suspended.
137        #[unsafe(method(isPictureInPictureSuspended))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn isPictureInPictureSuspended(&self) -> bool;
140
141        /// Whether or not any Picture in Picture is active, and can be stopped.
142        ///
143        /// 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.
144        #[unsafe(method(canStopPictureInPicture))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn canStopPictureInPicture(&self) -> bool;
147
148        /// Disables certain user operations (fast forward, forward skip, and scrubbing).
149        ///
150        /// This can be used to temporarily enforce playback of mandatory content (such as legalese or advertisements).
151        #[unsafe(method(requiresLinearPlayback))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn requiresLinearPlayback(&self) -> bool;
154
155        /// Setter for [`requiresLinearPlayback`][Self::requiresLinearPlayback].
156        #[unsafe(method(setRequiresLinearPlayback:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setRequiresLinearPlayback(&self, requires_linear_playback: bool);
159
160        /// 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.
161        ///
162        /// This property must only be set to YES for content intended to be the user's primary focus.
163        #[unsafe(method(canStartPictureInPictureAutomaticallyFromInline))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn canStartPictureInPictureAutomaticallyFromInline(&self) -> bool;
166
167        /// Setter for [`canStartPictureInPictureAutomaticallyFromInline`][Self::canStartPictureInPictureAutomaticallyFromInline].
168        #[unsafe(method(setCanStartPictureInPictureAutomaticallyFromInline:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setCanStartPictureInPictureAutomaticallyFromInline(
171            &self,
172            can_start_picture_in_picture_automatically_from_inline: bool,
173        );
174    );
175}
176
177/// Methods declared on superclass `NSObject`.
178impl AVPictureInPictureController {
179    extern_methods!(
180        #[unsafe(method(init))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
183
184        #[unsafe(method(new))]
185        #[unsafe(method_family = new)]
186        pub unsafe fn new() -> Retained<Self>;
187    );
188}
189
190extern_class!(
191    /// A content source for AVPictureInPictureController.
192    ///
193    /// Create a content source with an appropriate layer, and use it to initialize the AVPictureInPictureController.
194    ///
195    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollercontentsource?language=objc)
196    #[unsafe(super(NSObject))]
197    #[derive(Debug, PartialEq, Eq, Hash)]
198    pub struct AVPictureInPictureControllerContentSource;
199);
200
201extern_conformance!(
202    unsafe impl NSObjectProtocol for AVPictureInPictureControllerContentSource {}
203);
204
205impl AVPictureInPictureControllerContentSource {
206    extern_methods!(
207        #[unsafe(method(init))]
208        #[unsafe(method_family = init)]
209        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
210
211        #[unsafe(method(new))]
212        #[unsafe(method_family = new)]
213        pub unsafe fn new() -> Retained<Self>;
214
215        #[cfg(feature = "objc2-av-foundation")]
216        #[cfg(not(target_os = "watchos"))]
217        /// Parameter `playerLayer`: The player layer to be shown in Picture in Picture.
218        ///
219        /// Use this initializer for a content source with a player layer.
220        #[unsafe(method(initWithPlayerLayer:))]
221        #[unsafe(method_family = init)]
222        pub unsafe fn initWithPlayerLayer(
223            this: Allocated<Self>,
224            player_layer: &AVPlayerLayer,
225        ) -> Retained<Self>;
226
227        #[cfg(feature = "objc2-av-foundation")]
228        #[cfg(not(target_os = "watchos"))]
229        /// The receiver's player layer.
230        #[unsafe(method(playerLayer))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn playerLayer(&self) -> Option<Retained<AVPlayerLayer>>;
233    );
234}
235
236extern_protocol!(
237    /// A protocol for delegates of AVPictureInPictureController.
238    ///
239    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avpictureinpicturecontrollerdelegate?language=objc)
240    pub unsafe trait AVPictureInPictureControllerDelegate: NSObjectProtocol {
241        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
242        ///
243        /// Delegate can implement this method to be notified when Picture in Picture will start.
244        #[optional]
245        #[unsafe(method(pictureInPictureControllerWillStartPictureInPicture:))]
246        #[unsafe(method_family = none)]
247        unsafe fn pictureInPictureControllerWillStartPictureInPicture(
248            &self,
249            picture_in_picture_controller: &AVPictureInPictureController,
250        );
251
252        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
253        ///
254        /// Delegate can implement this method to be notified when Picture in Picture did start.
255        #[optional]
256        #[unsafe(method(pictureInPictureControllerDidStartPictureInPicture:))]
257        #[unsafe(method_family = none)]
258        unsafe fn pictureInPictureControllerDidStartPictureInPicture(
259            &self,
260            picture_in_picture_controller: &AVPictureInPictureController,
261        );
262
263        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
264        ///
265        /// Parameter `error`: An error describing why it failed.
266        ///
267        /// Delegate can implement this method to be notified when Picture in Picture failed to start.
268        #[optional]
269        #[unsafe(method(pictureInPictureController:failedToStartPictureInPictureWithError:))]
270        #[unsafe(method_family = none)]
271        unsafe fn pictureInPictureController_failedToStartPictureInPictureWithError(
272            &self,
273            picture_in_picture_controller: &AVPictureInPictureController,
274            error: &NSError,
275        );
276
277        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
278        ///
279        /// Delegate can implement this method to be notified when Picture in Picture will stop.
280        #[optional]
281        #[unsafe(method(pictureInPictureControllerWillStopPictureInPicture:))]
282        #[unsafe(method_family = none)]
283        unsafe fn pictureInPictureControllerWillStopPictureInPicture(
284            &self,
285            picture_in_picture_controller: &AVPictureInPictureController,
286        );
287
288        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
289        ///
290        /// Delegate can implement this method to be notified when Picture in Picture did stop.
291        #[optional]
292        #[unsafe(method(pictureInPictureControllerDidStopPictureInPicture:))]
293        #[unsafe(method_family = none)]
294        unsafe fn pictureInPictureControllerDidStopPictureInPicture(
295            &self,
296            picture_in_picture_controller: &AVPictureInPictureController,
297        );
298
299        #[cfg(feature = "block2")]
300        /// Parameter `pictureInPictureController`: The Picture in Picture controller.
301        ///
302        /// Parameter `completionHandler`: The completion handler the delegate needs to call after restore.
303        ///
304        /// Delegate can implement this method to restore the user interface before Picture in Picture stops.
305        #[optional]
306        #[unsafe(method(pictureInPictureController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:))]
307        #[unsafe(method_family = none)]
308        unsafe fn pictureInPictureController_restoreUserInterfaceForPictureInPictureStopWithCompletionHandler(
309            &self,
310            picture_in_picture_controller: &AVPictureInPictureController,
311            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
312        );
313    }
314);