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