objc2_av_foundation/generated/
AVPlaybackCoordinator.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-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Describes why an AVCoordinatedPlaybackParticipant is not currently available to participate in coordinated playback.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreason?language=objc)
15// NS_TYPED_EXTENSIBLE_ENUM
16pub type AVCoordinatedPlaybackSuspensionReason = NSString;
17
18extern "C" {
19    /// The participant's audio session was interrupted.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasonaudiosessioninterrupted?language=objc)
22    pub static AVCoordinatedPlaybackSuspensionReasonAudioSessionInterrupted:
23        &'static AVCoordinatedPlaybackSuspensionReason;
24}
25
26extern "C" {
27    /// The player is buffering data after a stall.
28    ///
29    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasonstallrecovery?language=objc)
30    pub static AVCoordinatedPlaybackSuspensionReasonStallRecovery:
31        &'static AVCoordinatedPlaybackSuspensionReason;
32}
33
34extern "C" {
35    /// The participant is presented with interstitial content instead of the main player.
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasonplayinginterstitial?language=objc)
38    pub static AVCoordinatedPlaybackSuspensionReasonPlayingInterstitial:
39        &'static AVCoordinatedPlaybackSuspensionReason;
40}
41
42extern "C" {
43    /// The participant cannot participate in coordinated playback.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasoncoordinatedplaybacknotpossible?language=objc)
46    pub static AVCoordinatedPlaybackSuspensionReasonCoordinatedPlaybackNotPossible:
47        &'static AVCoordinatedPlaybackSuspensionReason;
48}
49
50extern "C" {
51    /// The participant's playback object is in a state that requires manual intervention by the user to resume playback.
52    ///
53    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasonuseractionrequired?language=objc)
54    pub static AVCoordinatedPlaybackSuspensionReasonUserActionRequired:
55        &'static AVCoordinatedPlaybackSuspensionReason;
56}
57
58extern "C" {
59    /// The participant is actively changing current time.
60    ///
61    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspensionreasonuserischangingcurrenttime?language=objc)
62    pub static AVCoordinatedPlaybackSuspensionReasonUserIsChangingCurrentTime:
63        &'static AVCoordinatedPlaybackSuspensionReason;
64}
65
66extern_class!(
67    /// A representation of a temporary break in participation.
68    ///
69    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
70    ///
71    /// - NOTE: See AVPlaybackCoordinator's beginSuspensionForReason: method for details on use.
72    ///
73    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybacksuspension?language=objc)
74    #[unsafe(super(NSObject))]
75    #[derive(Debug, PartialEq, Eq, Hash)]
76    pub struct AVCoordinatedPlaybackSuspension;
77);
78
79extern_conformance!(
80    unsafe impl NSObjectProtocol for AVCoordinatedPlaybackSuspension {}
81);
82
83impl AVCoordinatedPlaybackSuspension {
84    extern_methods!(
85        #[unsafe(method(init))]
86        #[unsafe(method_family = init)]
87        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
88
89        #[unsafe(method(new))]
90        #[unsafe(method_family = new)]
91        pub unsafe fn new() -> Retained<Self>;
92
93        /// The reason for the suspension. This will be communicated to other participants while coordination is suspended.
94        #[unsafe(method(reason))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn reason(&self) -> Retained<AVCoordinatedPlaybackSuspensionReason>;
97
98        /// The begin time of the suspension.
99        #[unsafe(method(beginDate))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn beginDate(&self) -> Retained<NSDate>;
102
103        /// Ends the suspension.
104        ///
105        /// If this is the last suspension, the coordinator will adjust timing of its playback object to match the group.
106        /// Also see endProposingNewTime: for a way to end a suspension and simultaneously proposing a new time to the group.
107        #[unsafe(method(end))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn end(&self);
110
111        #[cfg(feature = "objc2-core-media")]
112        /// Ends the suspension and proposes a new time that everyone should seek to.
113        ///
114        /// If this is the last suspension, the coordinator will propose the new time to the group without changing the groups playback rate.
115        /// If this is not the last suspension, the time will be ignored.
116        /// If the time is not numeric, this will behave like a call to [suspension end].
117        #[unsafe(method(endProposingNewTime:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn endProposingNewTime(&self, time: CMTime);
120    );
121}
122
123extern "C" {
124    /// Posted by the playback coordinator when its otherParticipants property changes.
125    ///
126    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplaybackcoordinatorotherparticipantsdidchangenotification?language=objc)
127    pub static AVPlaybackCoordinatorOtherParticipantsDidChangeNotification:
128        &'static NSNotificationName;
129}
130
131extern "C" {
132    /// Posted by the playback coordinator when its suspensionReasons property changes.
133    ///
134    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplaybackcoordinatorsuspensionreasonsdidchangenotification?language=objc)
135    pub static AVPlaybackCoordinatorSuspensionReasonsDidChangeNotification:
136        &'static NSNotificationName;
137}
138
139extern_class!(
140    /// The playback coordinator negotiates playback state between a player, such as AVPlayer or a custom playback object represented by an implementation of the AVPlaybackCoordinatorPlaybackControlDelegate protocol, and a group of other connected players.
141    ///
142    /// AVPlaybackCoordinator will match rate and time of all connected players. This means that a local rate change or seek will be reflected in all connected players. Equally, a rate change or seek in any of the connected players will be reflected locally.
143    /// AVPlaybackCoordinator does not manage the items in the play queue of the connected players, so it is up to player's owner to share and match the play queue across participants.
144    /// The coordinator does, however, keep track of the identity of items enqueued in each player. This means that for one player's current time and rate to be applied on another player, both players must be playing the same item. If two players are playing different items, they each have independent playback states. When one of the two players transitions to the other's item later, it will match the time and rate of that other player.
145    ///
146    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplaybackcoordinator?language=objc)
147    #[unsafe(super(NSObject))]
148    #[derive(Debug, PartialEq, Eq, Hash)]
149    pub struct AVPlaybackCoordinator;
150);
151
152extern_conformance!(
153    unsafe impl NSObjectProtocol for AVPlaybackCoordinator {}
154);
155
156impl AVPlaybackCoordinator {
157    extern_methods!(
158        #[unsafe(method(init))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
161
162        #[unsafe(method(new))]
163        #[unsafe(method_family = new)]
164        pub unsafe fn new() -> Retained<Self>;
165
166        /// The playback states of the other participants in the group.
167        ///
168        /// Use this property to create UI informing the local user about the state of other participants in the group.
169        ///
170        /// - NOTE: The coordinator posts AVPlaybackCoordinatorOtherParticipantsDidChangeNotification when the contents of the array changes.
171        #[unsafe(method(otherParticipants))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn otherParticipants(
174            &self,
175        ) -> Retained<NSArray<AVCoordinatedPlaybackParticipant>>;
176
177        /// Describes why the coordinator is currently not able to participate in group playback.
178        ///
179        /// If the list of reasons is non-empty, the coordinator will not react to any changes of group playback state.
180        #[unsafe(method(suspensionReasons))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn suspensionReasons(
183            &self,
184        ) -> Retained<NSArray<AVCoordinatedPlaybackSuspensionReason>>;
185
186        /// Informs the coordinator that its playback object is detached from the group for some reason and should not receive any playback commands from the coordinator.
187        ///
188        /// Use this to tell the coordinator that its player cannot, or should not, participate in coordinated playback temporarily.
189        /// The coordinator will not respond to playback commands coming from the group and it will also not send any commands to the group.
190        /// To resume in group playback, end a suspension by calling one of the suspension's end methods.
191        ///
192        /// - Parameter suspensionReason: Indicates the reason for the suspension that is shared with other participants. Can be a system-defined reason (see AVCoordinatedPlaybackSuspensionReason*) or a custom string.
193        ///
194        /// - NOTE: See the description of AVPlaybackCoordinator subclasses for suspensions automatically begun on behalf of their playback objects, if any.
195        #[unsafe(method(beginSuspensionForReason:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn beginSuspensionForReason(
198            &self,
199            suspension_reason: &AVCoordinatedPlaybackSuspensionReason,
200        ) -> Retained<AVCoordinatedPlaybackSuspension>;
201
202        #[cfg(feature = "objc2-core-media")]
203        /// Returns the item time (for the current item) that the coordinator expects to be playing at a given host clock time.
204        ///
205        /// This method is useful to decide if it is appropriate to end a suspension, e.g. a suspension with AVCoordinatedPlaybackSuspensionReasonStallRecovery, while other participants are continuing playback.
206        #[unsafe(method(expectedItemTimeAtHostTime:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn expectedItemTimeAtHostTime(&self, host_clock_time: CMTime) -> CMTime;
209    );
210}
211
212extern_class!(
213    /// A participant in a coordinated playback group connected through AVPlaybackCoordinator.
214    ///
215    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
216    ///
217    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcoordinatedplaybackparticipant?language=objc)
218    #[unsafe(super(NSObject))]
219    #[derive(Debug, PartialEq, Eq, Hash)]
220    pub struct AVCoordinatedPlaybackParticipant;
221);
222
223unsafe impl Send for AVCoordinatedPlaybackParticipant {}
224
225unsafe impl Sync for AVCoordinatedPlaybackParticipant {}
226
227extern_conformance!(
228    unsafe impl NSObjectProtocol for AVCoordinatedPlaybackParticipant {}
229);
230
231impl AVCoordinatedPlaybackParticipant {
232    extern_methods!(
233        /// The reason, if any, this participant is currently not participating in coordinated playback.
234        ///
235        /// This property is not atomic.
236        ///
237        /// # Safety
238        ///
239        /// This might not be thread-safe.
240        #[unsafe(method(suspensionReasons))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn suspensionReasons(
243            &self,
244        ) -> Retained<NSArray<AVCoordinatedPlaybackSuspensionReason>>;
245
246        /// YES if the participant is ready to play.
247        ///
248        /// This property is not atomic.
249        ///
250        /// # Safety
251        ///
252        /// This might not be thread-safe.
253        #[unsafe(method(isReadyToPlay))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn isReadyToPlay(&self) -> bool;
256
257        /// A unique id for the participant.
258        ///
259        /// Use this identifier to distinguish participants.
260        ///
261        /// This property is not atomic.
262        ///
263        /// # Safety
264        ///
265        /// This might not be thread-safe.
266        #[unsafe(method(identifier))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn identifier(&self) -> Retained<NSUUID>;
269    );
270}
271
272/// Methods declared on superclass `NSObject`.
273impl AVCoordinatedPlaybackParticipant {
274    extern_methods!(
275        #[unsafe(method(init))]
276        #[unsafe(method_family = init)]
277        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
278
279        #[unsafe(method(new))]
280        #[unsafe(method_family = new)]
281        pub unsafe fn new() -> Retained<Self>;
282    );
283}
284
285/// AVCoordinatedPlaybackPolicies.
286///
287/// Policies used by AVPlaybackCoordinator to determine how to interact with the group.
288impl AVPlaybackCoordinator {
289    extern_methods!(
290        /// Sets the amount of participants that can join a group before the coordinator stops waiting for this particular suspension reason.
291        ///
292        /// This allows additional configuration for suspension reasons in the suspensionReasonsThatTriggerWaiting array.
293        /// When the coordinator decides whether one participant's suspensions should cause others to wait, it will also consider this limit of participants currently in the group.
294        #[unsafe(method(setParticipantLimit:forWaitingOutSuspensionsWithReason:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn setParticipantLimit_forWaitingOutSuspensionsWithReason(
297            &self,
298            participant_limit: NSInteger,
299            reason: &AVCoordinatedPlaybackSuspensionReason,
300        );
301
302        /// Returns the maximum number of participants that can be in a group before the coordinator stops waiting out this particular suspensions reason. Default value is NSIntegerMax.
303        #[unsafe(method(participantLimitForWaitingOutSuspensionsWithReason:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn participantLimitForWaitingOutSuspensionsWithReason(
306            &self,
307            reason: &AVCoordinatedPlaybackSuspensionReason,
308        ) -> NSInteger;
309
310        /// If the coordinator decides to delay playback to wait for others, it will wait out these reasons, but not others.
311        #[unsafe(method(suspensionReasonsThatTriggerWaiting))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn suspensionReasonsThatTriggerWaiting(
314            &self,
315        ) -> Retained<NSArray<AVCoordinatedPlaybackSuspensionReason>>;
316
317        /// Setter for [`suspensionReasonsThatTriggerWaiting`][Self::suspensionReasonsThatTriggerWaiting].
318        ///
319        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
320        #[unsafe(method(setSuspensionReasonsThatTriggerWaiting:))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn setSuspensionReasonsThatTriggerWaiting(
323            &self,
324            suspension_reasons_that_trigger_waiting: &NSArray<
325                AVCoordinatedPlaybackSuspensionReason,
326            >,
327        );
328
329        /// Determines if participants should mirror the originator's stop time when pausing.
330        ///
331        /// If YES, all participants will seek to the originator's stop time after they pause. Use this if it is desirable to counteract any network delay incurred by communicating the originator's pause to the other participants.
332        /// If NO, it's acceptable for participants to stop at slightly different offsets and a pause will not cause other participants' time to jump back.
333        #[unsafe(method(pauseSnapsToMediaTimeOfOriginator))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn pauseSnapsToMediaTimeOfOriginator(&self) -> bool;
336
337        /// Setter for [`pauseSnapsToMediaTimeOfOriginator`][Self::pauseSnapsToMediaTimeOfOriginator].
338        #[unsafe(method(setPauseSnapsToMediaTimeOfOriginator:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn setPauseSnapsToMediaTimeOfOriginator(
341            &self,
342            pause_snaps_to_media_time_of_originator: bool,
343        );
344    );
345}
346
347extern_class!(
348    /// An AVPlaybackCoordinator subclass for controlling an AVPlayer
349    ///
350    /// While the coordinator is connected to other participants, it will intercept rate changes and seeks issued to the player to share these with other participants if appropriate.
351    /// Clients of AVPlayer can thus use the AVPlayer interfaces to modify the playback state of connected participants. When appropriate, the coordinator will also impose rate changes and seeks from other participants on the player. If this occurs, the corresponding notifications will carry an originating participant in their payload.
352    /// See AVPlayer's playbackCoordinator property for more details about player behavior changes.
353    /// AVPlayerPlaybackCoordinator may begin suspensions on behalf of the player when the player's timeControlStatus changes from AVPlayerTimeControlStatusPlaying to AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate or AVPlayerTimeControlStatusPaused. These suspensions will end when the player's timeControlStatus changes back to AVPlayerTimeControlStatusPlaying. This means that a suspension that begun because the player entered a waiting state, will end automatically when the player is done waiting. A suspension that begun because the player paused, will only end once the player's rate changes back to non-zero.
354    ///
355    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerplaybackcoordinator?language=objc)
356    #[unsafe(super(AVPlaybackCoordinator, NSObject))]
357    #[derive(Debug, PartialEq, Eq, Hash)]
358    pub struct AVPlayerPlaybackCoordinator;
359);
360
361extern_conformance!(
362    unsafe impl NSObjectProtocol for AVPlayerPlaybackCoordinator {}
363);
364
365impl AVPlayerPlaybackCoordinator {
366    extern_methods!(
367        #[unsafe(method(init))]
368        #[unsafe(method_family = init)]
369        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
370
371        #[unsafe(method(new))]
372        #[unsafe(method_family = new)]
373        pub unsafe fn new() -> Retained<Self>;
374
375        #[cfg(feature = "AVPlayer")]
376        /// The AVPlayer this coordinator is controlling.
377        #[unsafe(method(player))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn player(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayer>>;
380
381        /// An object implementing the AVPlaybackCoordinatorDelegate protocol.
382        #[unsafe(method(delegate))]
383        #[unsafe(method_family = none)]
384        pub unsafe fn delegate(
385            &self,
386        ) -> Option<Retained<ProtocolObject<dyn AVPlayerPlaybackCoordinatorDelegate>>>;
387
388        /// Setter for [`delegate`][Self::delegate].
389        ///
390        /// This is a [weak property][objc2::topics::weak_property].
391        #[unsafe(method(setDelegate:))]
392        #[unsafe(method_family = none)]
393        pub unsafe fn setDelegate(
394            &self,
395            delegate: Option<&ProtocolObject<dyn AVPlayerPlaybackCoordinatorDelegate>>,
396        );
397    );
398}
399
400/// AVPlaybackCoordinationMediumSupport.
401impl AVPlayerPlaybackCoordinator {
402    extern_methods!(
403        #[cfg(feature = "AVPlaybackCoordinationMedium")]
404        /// Connects the playback coordinator to the coordination medium
405        ///
406        /// This connects the playback coordinator to a coordination medium to enable sending and receiving messages from other connected playback coordinators.
407        /// If the coordination medium is non-NULL, this will connect the playback coordinator to the specified coordination medium.
408        /// If the coordination medium is set to NULL, this will disconnect the playback coordinator from the playback coordination medium. The player will no longer be coordinated with the other players connected to the coordination medium.
409        /// The playback coordinator can either only coordinate with local players through an AVPlaybackCoordinationMedium or coordinate with a remote group session through the `coordinateWithSession` API. If the client attempts to connect to an AVPlaybackCoordinationMedium while already connected to a group session, this method will populate the outError parameter
410        /// If the playback coordinator successfully connects to the coordination medium or disconnects from a coordination medium, the `outError` parameter will be nil. If the playback coordinator fails to connect to the specified coordination medium, the `outError` parameter will describe what went wrong.
411        ///
412        /// - Parameter coordinationMedium: The coordination medium the playback coordinator connects to. If NULL, the playback coordinator disconnects from any existing coordination medium.
413        /// - Parameter outError: A pointer to an NSError object that will be populated with failure information if connecting to or disconnecting from the coordination medium fails.
414        #[unsafe(method(coordinateUsingCoordinationMedium:error:_))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn coordinateUsingCoordinationMedium_error(
417            &self,
418            coordination_medium: Option<&AVPlaybackCoordinationMedium>,
419        ) -> Result<(), Retained<NSError>>;
420
421        #[cfg(feature = "AVPlaybackCoordinationMedium")]
422        /// The AVPlaybackCoordinationMedium this playback coordinator is connected to.
423        ///
424        /// This is the AVPlaybackCoordinationMedium the playback coordinator is connected to.
425        /// If not NULL, the playback coordinator is connected to the specified coordination medium. The playback coordinator is not available to coordinate with a group session.
426        /// If NULL, the playback coordinator is not connected to any playback coordination medium. The playback coordinator is available to coordinate with a group session through the `coordinateWithSession` API.
427        #[unsafe(method(playbackCoordinationMedium))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn playbackCoordinationMedium(
430            &self,
431        ) -> Option<Retained<AVPlaybackCoordinationMedium>>;
432    );
433}
434
435extern_protocol!(
436    /// Delegate protocol for AVPlayerPlaybackCoordinator.
437    ///
438    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerplaybackcoordinatordelegate?language=objc)
439    pub unsafe trait AVPlayerPlaybackCoordinatorDelegate:
440        NSObjectProtocol + Send + Sync
441    {
442        #[cfg(feature = "AVPlayerItem")]
443        /// Called by the coordinator to identify AVPlayerItems played by the coordinator's AVPlayer.
444        ///
445        /// Implementing this method allows the coordinator to establish identity of two items created from different URLs, e.g., because one participant is using a local cache and the other a remote URL.
446        /// If the method is not implemented, the coordinator will derive the identifier from the item's asset.
447        #[optional]
448        #[unsafe(method(playbackCoordinator:identifierForPlayerItem:))]
449        #[unsafe(method_family = none)]
450        unsafe fn playbackCoordinator_identifierForPlayerItem(
451            &self,
452            coordinator: &AVPlayerPlaybackCoordinator,
453            player_item: &AVPlayerItem,
454        ) -> Retained<NSString>;
455
456        #[cfg(feature = "AVPlayerItem")]
457        /// Called by the coordinator to obtain time ranges in the AVPlayerItem that do not correspond to the primary content.
458        ///
459        /// Implement this method to provide the coordinator a list of sample accurate time ranges that represent interstitials in the player item.
460        /// The coordinator would use this along with the waiting policy for the playingInterstitial suspension to coordinate playback across the group.
461        /// If the playingInterstitial suspension is part of AVPlaybackCoordinator.suspensionReasonsThatTriggerWaiting, then the coordinator would wait for other participants to complete the interstitial before proceeding with playback.
462        /// And if the playingInterstitial suspension is not a part of AVPlaybackCoordinator.suspensionReasonsThatTriggerWaiting then the coordinator will not wait for the participant playing the interstitial.
463        /// Instead, that participant would jump to catch up with the rest of the group when they finish playing the interstitial.
464        /// This delegate method is expected to return an array of NSValues with each value containing a CMTimeRange that represents the interstitial.
465        /// If the method is not implemented, the coordinator would assume that the entire item corresponds to the primary content.
466        #[optional]
467        #[unsafe(method(playbackCoordinator:interstitialTimeRangesForPlayerItem:))]
468        #[unsafe(method_family = none)]
469        unsafe fn playbackCoordinator_interstitialTimeRangesForPlayerItem(
470            &self,
471            coordinator: &AVPlayerPlaybackCoordinator,
472            player_item: &AVPlayerItem,
473        ) -> Retained<NSArray<NSValue>>;
474    }
475);
476
477/// Configuration for a call to [AVDelegatingPlaybackCoordinator coordinateRateChangeToRate:options:].
478///
479/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorratechangeoptions?language=objc)
480// NS_OPTIONS
481#[repr(transparent)]
482#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
483pub struct AVDelegatingPlaybackCoordinatorRateChangeOptions(pub NSUInteger);
484bitflags::bitflags! {
485    impl AVDelegatingPlaybackCoordinatorRateChangeOptions: NSUInteger {
486/// Requests that the coordinator begin playback as soon as possible and ignore other participant's readiness and suspensions.
487        #[doc(alias = "AVDelegatingPlaybackCoordinatorRateChangeOptionPlayImmediately")]
488        const PlayImmediately = 1<<0;
489    }
490}
491
492unsafe impl Encode for AVDelegatingPlaybackCoordinatorRateChangeOptions {
493    const ENCODING: Encoding = NSUInteger::ENCODING;
494}
495
496unsafe impl RefEncode for AVDelegatingPlaybackCoordinatorRateChangeOptions {
497    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
498}
499
500/// Configuration for a call to [AVDelegatingPlaybackCoordinator coordinateSeekToTime:options:].
501///
502/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorseekoptions?language=objc)
503// NS_OPTIONS
504#[repr(transparent)]
505#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
506pub struct AVDelegatingPlaybackCoordinatorSeekOptions(pub NSUInteger);
507bitflags::bitflags! {
508    impl AVDelegatingPlaybackCoordinatorSeekOptions: NSUInteger {
509/// Requests that the coordinator resume playback as soon as possible after the seek is complete and ignore other participant's readiness and suspensions.
510        #[doc(alias = "AVDelegatingPlaybackCoordinatorSeekOptionResumeImmediately")]
511        const ResumeImmediately = 1<<0;
512    }
513}
514
515unsafe impl Encode for AVDelegatingPlaybackCoordinatorSeekOptions {
516    const ENCODING: Encoding = NSUInteger::ENCODING;
517}
518
519unsafe impl RefEncode for AVDelegatingPlaybackCoordinatorSeekOptions {
520    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
521}
522
523extern_class!(
524    /// An AVPlaybackCoordinator subclass for controlling a custom playback object.
525    ///
526    /// - NOTE: Use AVPlayer's playbackCoordinator property to get an AVPlaybackCoordinator for an AVPlayer.
527    ///
528    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinator?language=objc)
529    #[unsafe(super(AVPlaybackCoordinator, NSObject))]
530    #[derive(Debug, PartialEq, Eq, Hash)]
531    pub struct AVDelegatingPlaybackCoordinator;
532);
533
534extern_conformance!(
535    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinator {}
536);
537
538impl AVDelegatingPlaybackCoordinator {
539    extern_methods!(
540        /// Creates an AVPlaybackCoordinator for a custom playback object.
541        ///
542        /// Use this to create an AVPlaybackCoordinator when playback is not driven by an AVPlayer.
543        ///
544        /// - Parameter playbackControlDelegate: An object conforming to the AVPlaybackCoordinatorPlaybackControlDelegate protocol representing a custom playback object. The coordinator will only hold a weak reference to its delegate.
545        ///
546        /// - NOTE: See AVPlayer's playbackCoordinator property to get an AVPlaybackCoordinator for an AVPlayer.
547        #[unsafe(method(initWithPlaybackControlDelegate:))]
548        #[unsafe(method_family = init)]
549        pub unsafe fn initWithPlaybackControlDelegate(
550            this: Allocated<Self>,
551            playback_control_delegate: &ProtocolObject<
552                dyn AVPlaybackCoordinatorPlaybackControlDelegate,
553            >,
554        ) -> Retained<Self>;
555
556        /// The custom player implementation controlled by the coordinator.
557        #[unsafe(method(playbackControlDelegate))]
558        #[unsafe(method_family = none)]
559        pub unsafe fn playbackControlDelegate(
560            &self,
561        ) -> Option<Retained<ProtocolObject<dyn AVPlaybackCoordinatorPlaybackControlDelegate>>>;
562
563        /// Coordinaties a rate change across the group of connected participants, waiting for other participants to become ready if necessary.
564        ///
565        /// The coordinator will request a coordinated rate change from all other connected participants.
566        /// When changing the rate from zero to non-zero, it may also wait out other participant's suspensions as configured by the suspensionReasonsThatTriggerWaiting property.
567        ///
568        /// This method should not be called when the rate change should not affect the group, or the group should not have control over local playback temporarily, e.g. a pause because of an audio session interruption.
569        /// In those cases, the coordinator should be informed by beginning a suspension with the appropriate reason instead. If other participants pause is dependent on the coordinator's configuration.
570        /// The suspension will stop the coordinator from issuing further commands to its playbackControlDelegate. After beginning the suspension, the playback object can be reconfigured as necessary.
571        ///
572        /// - Parameter rate: The playback rate the group should be using.
573        /// - Parameter options: Additional configuration of the rate change. For details see AVDelegatingPlaybackCoordinatorRateChangeOptions.
574        ///
575        /// - NOTE: Calling this method while the coordinator is suspended affects only the local playback object. The group state will not be affected, even after the suspension ends.
576        #[unsafe(method(coordinateRateChangeToRate:options:))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn coordinateRateChangeToRate_options(
579            &self,
580            rate: c_float,
581            options: AVDelegatingPlaybackCoordinatorRateChangeOptions,
582        );
583
584        #[cfg(feature = "objc2-core-media")]
585        /// Triggers a seek to the requested time for all connected participants.
586        ///
587        /// For behavior around resuming playback after the seek is complete and suspensions, see the discussion of coordinateRateChangeToRate:options.
588        ///
589        /// - Parameter time: The time the group should seek to when the command ends.
590        /// - Parameter options: Additional configuration of the seek. For details see AVDelegatingPlaybackCoordinatorSeekOptions.
591        ///
592        /// - NOTE: Calling this method while the coordinator is suspended affects only the local playback object. The group state will not be affected, even after the suspension ends.
593        /// To end a suspension and also affect the group timing see -[AVCoordinatedPlaybackSuspension endProposingNewTime:]
594        #[unsafe(method(coordinateSeekToTime:options:))]
595        #[unsafe(method_family = none)]
596        pub unsafe fn coordinateSeekToTime_options(
597            &self,
598            time: CMTime,
599            options: AVDelegatingPlaybackCoordinatorSeekOptions,
600        );
601
602        #[cfg(feature = "objc2-core-media")]
603        /// Informs the coordinator to transition to a new current item.
604        ///
605        /// The coordinator will stop sending commands for any previous item identifier and begin sending commands for the new identifier.
606        /// The proposed timing will either be used as the new referece timing for the group, or it will be compared to an already existing reference timing.
607        /// If the proposed timing doesn't match such an existing reference timing, the coordinator will use the playbackControlDelegate to issue appropriate commands to match up the timing.
608        ///
609        /// - Parameter itemIdentifier: The identifier for the new current item. May be nil if nothing is playing.
610        /// - Parameter snapshotTimebase: A timebase used to communicate the initial playback state of the new item. If NULL, the coordinator will assume that playback is paused at kCMTimeZero. An appropriate timebase to pass to the completion handler may be retreived from AVFoundation playback objects such as AVSampleBufferRenderSynchronizer. It can also be created manually using CMTimebaseCreateWithSourceClock. The timebase will only be used to take a snapshot of its immediate timing. It will not be observed further.
611        ///
612        /// - NOTE: This is not a way to affect the play queue of other participants. All other participants must do this independently, e.g. as a side-effect of an automatic item transition or an out-of-band communication requesting a similar item change.
613        #[unsafe(method(transitionToItemWithIdentifier:proposingInitialTimingBasedOnTimebase:))]
614        #[unsafe(method_family = none)]
615        pub unsafe fn transitionToItemWithIdentifier_proposingInitialTimingBasedOnTimebase(
616            &self,
617            item_identifier: Option<&NSString>,
618            snapshot_timebase: Option<&CMTimebase>,
619        );
620
621        /// The item identifier of the current item. Previously set by a call to transitionToItemWithIdentifier:proposingInitialTimingBasedOnTimebase:
622        #[unsafe(method(currentItemIdentifier))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn currentItemIdentifier(&self) -> Option<Retained<NSString>>;
625
626        /// Instructs the coordinator to re-issue commands to synchronize the current item back to the state of the other participants.
627        ///
628        /// Use this method when the playback object is in a state that doesn't match the group for some reason and should be re-synchronized.
629        #[unsafe(method(reapplyCurrentItemStateToPlaybackControlDelegate))]
630        #[unsafe(method_family = none)]
631        pub unsafe fn reapplyCurrentItemStateToPlaybackControlDelegate(&self);
632    );
633}
634
635/// Methods declared on superclass `AVPlaybackCoordinator`.
636impl AVDelegatingPlaybackCoordinator {
637    extern_methods!(
638        #[unsafe(method(init))]
639        #[unsafe(method_family = init)]
640        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
641
642        #[unsafe(method(new))]
643        #[unsafe(method_family = new)]
644        pub unsafe fn new() -> Retained<Self>;
645    );
646}
647
648extern_protocol!(
649    /// A custom player implementation
650    ///
651    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplaybackcoordinatorplaybackcontroldelegate?language=objc)
652    pub unsafe trait AVPlaybackCoordinatorPlaybackControlDelegate:
653        NSObjectProtocol + Send + Sync
654    {
655        #[cfg(feature = "block2")]
656        /// Called by the coordinator to match the playback rate of the control delegate to the group, when the target rate is non-zero.
657        ///
658        /// The coordinator issues this command when the desired playback timeline has changed. This may mean that the rate has changed, but it can also mean that the anchor time has changed.
659        /// Play commands are only issued when the desired playback rate is non-zero.
660        ///
661        /// - Parameter coordinator: The coordinator requesting a change in playback rate.
662        /// - Parameter playCommand: A play command object. See AVDelegatingPlaybackCoordinatorPlayCommand. The receiver should verify that the command is still valid by inspecting the expectedCurrentItemIdentifier property before applying the command.
663        /// - Parameter completionHandler: The receiver must call the completion handler when done, either when the command has been handled succesfully or when the receiver has indicated its inability to handle the command by beginning a suspension with an appropriate reason.
664        ///
665        /// # Safety
666        ///
667        /// `completion_handler` block must be sendable.
668        #[unsafe(method(playbackCoordinator:didIssuePlayCommand:completionHandler:))]
669        #[unsafe(method_family = none)]
670        unsafe fn playbackCoordinator_didIssuePlayCommand_completionHandler(
671            &self,
672            coordinator: &AVDelegatingPlaybackCoordinator,
673            play_command: &AVDelegatingPlaybackCoordinatorPlayCommand,
674            completion_handler: &block2::DynBlock<dyn Fn()>,
675        );
676
677        #[cfg(feature = "block2")]
678        /// Called by the coordinator to pause playback.
679        ///
680        /// - Parameter coordinator: The coordinator requesting playback to pause.
681        /// - Parameter pauseCommand: A pause command object. See AVDelegatingPlaybackCoordinatorPauseCommand. The receiver should verify that the command is still valid by inspecting the expectedCurrentItemIdentifier property before applying the command.
682        /// - Parameter completionHandler: The receiver must call the completion handler when done, either when the command has been handled succesfully or when the receiver has indicated its inability to handle the command by beginning a suspension with an appropriate reason. If the command's shouldBufferInAnticipationOfPlayback is YES, the completion handler should also only be called once the playback object is ready to receive a subsequent play command.
683        ///
684        /// # Safety
685        ///
686        /// `completion_handler` block must be sendable.
687        #[unsafe(method(playbackCoordinator:didIssuePauseCommand:completionHandler:))]
688        #[unsafe(method_family = none)]
689        unsafe fn playbackCoordinator_didIssuePauseCommand_completionHandler(
690            &self,
691            coordinator: &AVDelegatingPlaybackCoordinator,
692            pause_command: &AVDelegatingPlaybackCoordinatorPauseCommand,
693            completion_handler: &block2::DynBlock<dyn Fn()>,
694        );
695
696        #[cfg(feature = "block2")]
697        /// Called by the coordinator to seek to a new time.
698        ///
699        /// The coordinator issues this command when the playback object current time changes, potentially also pausing playback.
700        ///
701        /// - Parameter coordinator: The coordinator requesting the seek.
702        /// - Parameter seekCommand: A seek command object. See AVDelegatingPlaybackCoordinatorSeekCommand. The receiver should verify that the command is still valid by inspecting the expectedCurrentItemIdentifier property before applying the command.
703        /// - Parameter completionHandler: The receiver must call the completion handler when done, either when the command has been handled succesfully or when the receiver has indicated its inability to handle the command by beginning a suspension with an appropriate reason. If the command's shouldBufferInAnticipationOfPlayback is YES, the completion handler should also only be called once the playback object is ready to receive a subsequent play command.
704        ///
705        /// # Safety
706        ///
707        /// `completion_handler` block must be sendable.
708        #[unsafe(method(playbackCoordinator:didIssueSeekCommand:completionHandler:))]
709        #[unsafe(method_family = none)]
710        unsafe fn playbackCoordinator_didIssueSeekCommand_completionHandler(
711            &self,
712            coordinator: &AVDelegatingPlaybackCoordinator,
713            seek_command: &AVDelegatingPlaybackCoordinatorSeekCommand,
714            completion_handler: &block2::DynBlock<dyn Fn()>,
715        );
716
717        #[cfg(feature = "block2")]
718        /// Called by the coordinator to indicate that playback is expected to begin soon and the playback object should begin buffering.
719        ///
720        /// The coordinator issues this command when playback is currently paused and the coordinator is expecting playback to start soon.
721        /// In response to this command, it is appropriate to update playback UI to indicate playback in a waiting state.
722        /// The expected start can be cancelled by calling -[AVDelegatingPlaybackCoordinator coordinateRateChangeTo:0].
723        ///
724        /// - Parameter coordinator: The coordinator requesting buffering to begin.
725        /// - Parameter bufferingCommand: A buffering command object. See AVDelegatingPlaybackCoordinatorBufferingCommand. The receiver should verify that the command is still valid by inspecting the expectedCurrentItemIdentifier property before applying the command.
726        /// - Parameter completionHandler: The receiver must call the completion handler when done, either when the command has been handled succesfully or when the receiver has indicated its inability to handle the command by beginning a suspension with an appropriate reason. For buffering commands, the command should only be considered complete once the playback object is ready to receive a subsequent play command.
727        ///
728        /// # Safety
729        ///
730        /// `completion_handler` block must be sendable.
731        #[unsafe(method(playbackCoordinator:didIssueBufferingCommand:completionHandler:))]
732        #[unsafe(method_family = none)]
733        unsafe fn playbackCoordinator_didIssueBufferingCommand_completionHandler(
734            &self,
735            coordinator: &AVDelegatingPlaybackCoordinator,
736            buffering_command: &AVDelegatingPlaybackCoordinatorBufferingCommand,
737            completion_handler: &block2::DynBlock<dyn Fn()>,
738        );
739    }
740);
741
742extern_class!(
743    /// Abstract superclass for playback commands
744    ///
745    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
746    ///
747    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorplaybackcontrolcommand?language=objc)
748    #[unsafe(super(NSObject))]
749    #[derive(Debug, PartialEq, Eq, Hash)]
750    pub struct AVDelegatingPlaybackCoordinatorPlaybackControlCommand;
751);
752
753unsafe impl Send for AVDelegatingPlaybackCoordinatorPlaybackControlCommand {}
754
755unsafe impl Sync for AVDelegatingPlaybackCoordinatorPlaybackControlCommand {}
756
757extern_conformance!(
758    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinatorPlaybackControlCommand {}
759);
760
761impl AVDelegatingPlaybackCoordinatorPlaybackControlCommand {
762    extern_methods!(
763        #[unsafe(method(init))]
764        #[unsafe(method_family = init)]
765        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
766
767        #[unsafe(method(new))]
768        #[unsafe(method_family = new)]
769        pub unsafe fn new() -> Retained<Self>;
770
771        /// The participant causing this command to be issued.
772        ///
773        /// Only commands issued on behalf of another participant will contain an originator.
774        /// Commands caused by local requests, e.g., requests to coordinate a rate change, will not contain an originator.
775        /// Similarly, re-application of older commands, e.g., in response to a call to [AVDelegatingPlaybackCoordinator reapplyCurrentItemStateToPlaybackControlDelegate], will not contain an originator.
776        /// If the originator is non-nil, it may be appropriate to show UI indicating someone else's action.
777        ///
778        /// This property is not atomic.
779        ///
780        /// # Safety
781        ///
782        /// This might not be thread-safe.
783        #[unsafe(method(originator))]
784        #[unsafe(method_family = none)]
785        pub unsafe fn originator(&self) -> Option<Retained<AVCoordinatedPlaybackParticipant>>;
786
787        /// Indicates the item this command was issued for.
788        ///
789        /// Commands are always meant for the current item. A command handler should verify that the identifier of its current item matches this identifier.
790        /// If it doesn't this command is obsolete and should be ignored. Note that any completion handler of the delegate method issuing the command must still be invoked.
791        ///
792        /// This property is not atomic.
793        ///
794        /// # Safety
795        ///
796        /// This might not be thread-safe.
797        #[unsafe(method(expectedCurrentItemIdentifier))]
798        #[unsafe(method_family = none)]
799        pub unsafe fn expectedCurrentItemIdentifier(&self) -> Retained<NSString>;
800    );
801}
802
803extern_class!(
804    /// A playback command requesting playback with specific timing.
805    ///
806    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
807    ///
808    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorplaycommand?language=objc)
809    #[unsafe(super(AVDelegatingPlaybackCoordinatorPlaybackControlCommand, NSObject))]
810    #[derive(Debug, PartialEq, Eq, Hash)]
811    pub struct AVDelegatingPlaybackCoordinatorPlayCommand;
812);
813
814unsafe impl Send for AVDelegatingPlaybackCoordinatorPlayCommand {}
815
816unsafe impl Sync for AVDelegatingPlaybackCoordinatorPlayCommand {}
817
818extern_conformance!(
819    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinatorPlayCommand {}
820);
821
822impl AVDelegatingPlaybackCoordinatorPlayCommand {
823    extern_methods!(
824        #[unsafe(method(init))]
825        #[unsafe(method_family = init)]
826        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
827
828        #[unsafe(method(new))]
829        #[unsafe(method_family = new)]
830        pub unsafe fn new() -> Retained<Self>;
831
832        /// Playback rate. Will always be non-zero.
833        ///
834        /// This property is not atomic.
835        ///
836        /// # Safety
837        ///
838        /// This might not be thread-safe.
839        #[unsafe(method(rate))]
840        #[unsafe(method_family = none)]
841        pub unsafe fn rate(&self) -> c_float;
842
843        #[cfg(feature = "objc2-core-media")]
844        /// The itemTime that playback should begin at.
845        ///
846        /// The receiver of this command should verify that data is loaded for the requested time and potentially begin loading it before beginning playback.
847        /// It is not important to load data for time exactly. If data "similar" to time is already loaded, it is acceptable to start playback with the loaded data. Playback should still start with the requested timing.
848        /// Should the receiver be unable to start with the exact requested timing, playback will be out of sync with the group.
849        /// If data for the requested time cannot be loaded, or playback stalls later, the command handler may want to indicate this to the coordinator by beginning a suspension with AVCoordinatedPlaybackSuspensionReasonStallRecovery.
850        ///
851        /// This property is not atomic.
852        ///
853        /// # Safety
854        ///
855        /// This might not be thread-safe.
856        #[unsafe(method(itemTime))]
857        #[unsafe(method_family = none)]
858        pub unsafe fn itemTime(&self) -> CMTime;
859
860        #[cfg(feature = "objc2-core-media")]
861        /// This is the host clock time (see CMClockGetHostTimeClock()) defining when playback should start (or should have started) at the given itemTime.
862        ///
863        /// This property is not atomic.
864        ///
865        /// # Safety
866        ///
867        /// This might not be thread-safe.
868        #[unsafe(method(hostClockTime))]
869        #[unsafe(method_family = none)]
870        pub unsafe fn hostClockTime(&self) -> CMTime;
871    );
872}
873
874extern_class!(
875    /// A playback command requesting buffering in anticipation of playback.
876    ///
877    /// Receiving this command should be reflected to the user as playback in a buffering state.
878    /// To cancel the group intent to begin playback and move back into a paused state, call [AVDelegatingPlaybackCoordinator coordinateRateChangeToRate:0 options: 0]
879    ///
880    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
881    ///
882    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorbufferingcommand?language=objc)
883    #[unsafe(super(AVDelegatingPlaybackCoordinatorPlaybackControlCommand, NSObject))]
884    #[derive(Debug, PartialEq, Eq, Hash)]
885    pub struct AVDelegatingPlaybackCoordinatorBufferingCommand;
886);
887
888unsafe impl Send for AVDelegatingPlaybackCoordinatorBufferingCommand {}
889
890unsafe impl Sync for AVDelegatingPlaybackCoordinatorBufferingCommand {}
891
892extern_conformance!(
893    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinatorBufferingCommand {}
894);
895
896impl AVDelegatingPlaybackCoordinatorBufferingCommand {
897    extern_methods!(
898        #[unsafe(method(init))]
899        #[unsafe(method_family = init)]
900        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
901
902        #[unsafe(method(new))]
903        #[unsafe(method_family = new)]
904        pub unsafe fn new() -> Retained<Self>;
905
906        /// The rate to prepare playback for.
907        ///
908        /// The command should only be considered complete once the player is ready to receive an AVDelegatingPlaybackCoordinatorPlayCommand with the indicated rate.
909        ///
910        /// This property is not atomic.
911        ///
912        /// # Safety
913        ///
914        /// This might not be thread-safe.
915        #[unsafe(method(anticipatedPlaybackRate))]
916        #[unsafe(method_family = none)]
917        pub unsafe fn anticipatedPlaybackRate(&self) -> c_float;
918
919        /// Communicates when the coordinator expects the command's completion handler at the latest.
920        ///
921        /// A receiver of a buffering command should fire the completion handler by this date at the latest. This is useful in buffering situations where the receiver
922        /// has not yet buffered enough data to be considered ready to play by the due date. The receiver should then decide to either complete the command as is
923        /// to try and keep up with the group, or alternatively begin a stall recovery suspension to communicate the situation to the other participants.
924        /// Completing the command after this date means that the coordinator will likely send a play command for a later time than the receiver buffered for.
925        ///
926        /// This property is not atomic.
927        ///
928        /// # Safety
929        ///
930        /// This might not be thread-safe.
931        #[unsafe(method(completionDueDate))]
932        #[unsafe(method_family = none)]
933        pub unsafe fn completionDueDate(&self) -> Option<Retained<NSDate>>;
934    );
935}
936
937extern_class!(
938    /// A playback command requesting a pause
939    ///
940    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
941    ///
942    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorpausecommand?language=objc)
943    #[unsafe(super(AVDelegatingPlaybackCoordinatorPlaybackControlCommand, NSObject))]
944    #[derive(Debug, PartialEq, Eq, Hash)]
945    pub struct AVDelegatingPlaybackCoordinatorPauseCommand;
946);
947
948unsafe impl Send for AVDelegatingPlaybackCoordinatorPauseCommand {}
949
950unsafe impl Sync for AVDelegatingPlaybackCoordinatorPauseCommand {}
951
952extern_conformance!(
953    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinatorPauseCommand {}
954);
955
956impl AVDelegatingPlaybackCoordinatorPauseCommand {
957    extern_methods!(
958        #[unsafe(method(init))]
959        #[unsafe(method_family = init)]
960        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
961
962        #[unsafe(method(new))]
963        #[unsafe(method_family = new)]
964        pub unsafe fn new() -> Retained<Self>;
965
966        /// Indicates that playback is anticipated and the player should begin buffering if necessary.
967        ///
968        /// When shouldBufferInAnticipationOfPlayback is YES, some participant wants to resume playback at the rate indicated by the anticipatedPlaybackRate property.
969        /// This should be treated similar to receiving a separate AVDelegatingPlaybackCoordinatorBufferingCommand.
970        /// If YES, the command should only be considered complete once the player is ready to receive an AVDelegatingPlaybackCoordinatorPlayCommand with the indicated rate.
971        ///
972        /// This property is not atomic.
973        ///
974        /// # Safety
975        ///
976        /// This might not be thread-safe.
977        #[unsafe(method(shouldBufferInAnticipationOfPlayback))]
978        #[unsafe(method_family = none)]
979        pub unsafe fn shouldBufferInAnticipationOfPlayback(&self) -> bool;
980
981        /// The rate to prepare for if shouldBufferInAnticipationOfPlayback is YES.
982        ///
983        /// This property is not atomic.
984        ///
985        /// # Safety
986        ///
987        /// This might not be thread-safe.
988        #[unsafe(method(anticipatedPlaybackRate))]
989        #[unsafe(method_family = none)]
990        pub unsafe fn anticipatedPlaybackRate(&self) -> c_float;
991    );
992}
993
994extern_class!(
995    /// A playback command requesting a seek.
996    ///
997    /// If the current playback rate is non-zero, playback should not automatically resume after the seek. Instead the delegate should pause and wait for the coordinator to issue another PlayCommand. Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
998    ///
999    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avdelegatingplaybackcoordinatorseekcommand?language=objc)
1000    #[unsafe(super(AVDelegatingPlaybackCoordinatorPlaybackControlCommand, NSObject))]
1001    #[derive(Debug, PartialEq, Eq, Hash)]
1002    pub struct AVDelegatingPlaybackCoordinatorSeekCommand;
1003);
1004
1005unsafe impl Send for AVDelegatingPlaybackCoordinatorSeekCommand {}
1006
1007unsafe impl Sync for AVDelegatingPlaybackCoordinatorSeekCommand {}
1008
1009extern_conformance!(
1010    unsafe impl NSObjectProtocol for AVDelegatingPlaybackCoordinatorSeekCommand {}
1011);
1012
1013impl AVDelegatingPlaybackCoordinatorSeekCommand {
1014    extern_methods!(
1015        #[unsafe(method(init))]
1016        #[unsafe(method_family = init)]
1017        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1018
1019        #[unsafe(method(new))]
1020        #[unsafe(method_family = new)]
1021        pub unsafe fn new() -> Retained<Self>;
1022
1023        #[cfg(feature = "objc2-core-media")]
1024        /// The time to seek the currentItem to.
1025        ///
1026        /// Playback should never automatically resume after seeking to this time. The coordinator will issue a new PlayCommand when everyone else is ready to resume.
1027        ///
1028        /// This property is not atomic.
1029        ///
1030        /// # Safety
1031        ///
1032        /// This might not be thread-safe.
1033        #[unsafe(method(itemTime))]
1034        #[unsafe(method_family = none)]
1035        pub unsafe fn itemTime(&self) -> CMTime;
1036
1037        /// Indicates that playback is anticipated and the player should begin buffering if necessary.
1038        ///
1039        /// When shouldBufferInAnticipationOfPlayback, playback is expected to eventually resume at the rate indicated by the anticipatedPlaybackRate property.
1040        /// This should be treated similar to receiving a separate AVDelegatingPlaybackCoordinatorBufferingCommand.
1041        /// If YES, the command should only be considered complete once the player is ready to receive an AVDelegatingPlaybackCoordinatorPlayCommand with the indicated rate.
1042        ///
1043        /// This property is not atomic.
1044        ///
1045        /// # Safety
1046        ///
1047        /// This might not be thread-safe.
1048        #[unsafe(method(shouldBufferInAnticipationOfPlayback))]
1049        #[unsafe(method_family = none)]
1050        pub unsafe fn shouldBufferInAnticipationOfPlayback(&self) -> bool;
1051
1052        /// The rate to prepare for if shouldBufferInAnticipationOfPlayback is YES.
1053        ///
1054        /// This property is not atomic.
1055        ///
1056        /// # Safety
1057        ///
1058        /// This might not be thread-safe.
1059        #[unsafe(method(anticipatedPlaybackRate))]
1060        #[unsafe(method_family = none)]
1061        pub unsafe fn anticipatedPlaybackRate(&self) -> c_float;
1062
1063        /// Communicates when the coordinator expects the command's completion handler at the latest.
1064        ///
1065        /// A seek command expecting buffering in anticipation of playback does expect the receiver to fire the completion handler by this date at the latest.
1066        /// This is useful in buffering situations where the receiver has not yet buffered enough data to be considered ready to play by the due date.
1067        /// The receiver should then decide to either complete the command as is to try and keep up with the group, or alternatively begin a stall recovery
1068        /// suspension to communicate the situation to the other participants.
1069        /// Completing the command after this date means that the coordinator will likely send a play command for a later time than the receiver buffered for.
1070        ///
1071        /// This property is not atomic.
1072        ///
1073        /// # Safety
1074        ///
1075        /// This might not be thread-safe.
1076        #[unsafe(method(completionDueDate))]
1077        #[unsafe(method_family = none)]
1078        pub unsafe fn completionDueDate(&self) -> Option<Retained<NSDate>>;
1079    );
1080}