objc2_av_foundation/generated/
AVPlayer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// These constants are returned by the AVPlayer status property to indicate whether it can successfully play items.
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerstatus?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct AVPlayerStatus(pub NSInteger);
21impl AVPlayerStatus {
22    /// Indicates that the status of the player is not yet known because it has not tried to load new media resources for playback.
23    #[doc(alias = "AVPlayerStatusUnknown")]
24    pub const Unknown: Self = Self(0);
25    /// Indicates that the player is ready to play AVPlayerItem instances.
26    #[doc(alias = "AVPlayerStatusReadyToPlay")]
27    pub const ReadyToPlay: Self = Self(1);
28    /// Indicates that the player can no longer play AVPlayerItem instances because of an error. The error is described by the value of the player's error property.
29    #[doc(alias = "AVPlayerStatusFailed")]
30    pub const Failed: Self = Self(2);
31}
32
33unsafe impl Encode for AVPlayerStatus {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for AVPlayerStatus {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// AVPlayer offers a playback interface for single-item playback that's sufficient for the implementation of playback controllers and playback user interfaces.
43    ///
44    /// AVPlayer works equally well with local and remote media files, providing clients with appropriate
45    /// information about readiness to play or about the need to await additional data before continuing.
46    ///
47    /// Visual content of items played by an instance of AVPlayer can be displayed in a CoreAnimation layer
48    /// of class AVPlayerLayer.
49    ///
50    /// To allow clients to add and remove their objects as key-value observers safely, AVPlayer serializes notifications of
51    /// changes that occur dynamically during playback on a dispatch queue. By default, this queue is the main queue. See dispatch_get_main_queue().
52    ///
53    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayer?language=objc)
54    #[unsafe(super(NSObject))]
55    #[thread_kind = MainThreadOnly]
56    #[derive(Debug, PartialEq, Eq, Hash)]
57    pub struct AVPlayer;
58);
59
60extern_conformance!(
61    unsafe impl NSObjectProtocol for AVPlayer {}
62);
63
64impl AVPlayer {
65    extern_methods!(
66        /// Initializes an AVPlayer with no player items.
67        #[unsafe(method(init))]
68        #[unsafe(method_family = init)]
69        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
70
71        /// Returns an instance of AVPlayer that plays a single audiovisual resource referenced by URL.
72        ///
73        /// Implicitly creates an AVPlayerItem. Clients can obtain the AVPlayerItem as it becomes the player's currentItem.
74        ///
75        /// - Parameter URL:
76        ///
77        /// - Returns: An instance of AVPlayer
78        #[unsafe(method(playerWithURL:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn playerWithURL(url: &NSURL, mtm: MainThreadMarker) -> Retained<Self>;
81
82        #[cfg(feature = "AVPlayerItem")]
83        /// Create an AVPlayer that plays a single audiovisual item.
84        ///
85        /// Useful in order to play items for which an AVAsset has previously been created. See -[AVPlayerItem initWithAsset:].
86        ///
87        /// - Parameter item:
88        ///
89        /// - Returns: An instance of AVPlayer
90        #[unsafe(method(playerWithPlayerItem:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn playerWithPlayerItem(
93            item: Option<&AVPlayerItem>,
94            mtm: MainThreadMarker,
95        ) -> Retained<Self>;
96
97        /// Initializes an AVPlayer that plays a single audiovisual resource referenced by URL.
98        ///
99        /// Implicitly creates an AVPlayerItem. Clients can obtain the AVPlayerItem as it becomes the player's currentItem.
100        ///
101        /// - Parameter URL:
102        ///
103        /// - Returns: An instance of AVPlayer
104        #[unsafe(method(initWithURL:))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
107
108        #[cfg(feature = "AVPlayerItem")]
109        /// Create an AVPlayer that plays a single audiovisual item.
110        ///
111        /// Useful in order to play items for which an AVAsset has previously been created. See -[AVPlayerItem initWithAsset:].
112        /// This method throws an exception if the item is not an AVPlayerItem, or if the item is
113        /// associated with another AVPlayer.
114        ///
115        /// - Parameter item:
116        ///
117        /// - Returns: An instance of AVPlayer
118        #[unsafe(method(initWithPlayerItem:))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn initWithPlayerItem(
121            this: Allocated<Self>,
122            item: Option<&AVPlayerItem>,
123        ) -> Retained<Self>;
124
125        /// The ability of the receiver to be used for playback.
126        ///
127        /// The value of this property is an AVPlayerStatus that indicates whether the receiver can be used for playback. When
128        /// the value of this property is AVPlayerStatusFailed, the receiver can no longer be used for playback and a new
129        /// instance needs to be created in its place. When this happens, clients can check the value of the error property to
130        /// determine the nature of the failure. This property is key value observable.
131        #[unsafe(method(status))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn status(&self) -> AVPlayerStatus;
134
135        /// If the receiver's status is AVPlayerStatusFailed, this describes the error that caused the failure.
136        ///
137        /// The value of this property is an NSError that describes what caused the receiver to no longer be able to play items.
138        /// If the receiver's status is not AVPlayerStatusFailed, the value of this property is nil.
139        #[unsafe(method(error))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
142    );
143}
144
145/// Methods declared on superclass `NSObject`.
146impl AVPlayer {
147    extern_methods!(
148        #[unsafe(method(new))]
149        #[unsafe(method_family = new)]
150        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
151    );
152}
153
154extern "C" {
155    /// Indicates a player rate change.
156    ///
157    /// Posted by the player when its rate changes. Similar to KVO of AVPlayer.rate, but providing additional information about the rate change in the userInfo. See keys below.
158    ///
159    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangenotification?language=objc)
160    pub static AVPlayerRateDidChangeNotification: &'static NSNotificationName;
161}
162
163extern "C" {
164    /// Indicates a reason for the rate change notification.
165    ///
166    /// The value corresponding to this key is of type AVPlayerRateDidChangeReason.
167    ///
168    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereasonkey?language=objc)
169    pub static AVPlayerRateDidChangeReasonKey: &'static NSString;
170}
171
172extern "C" {
173    /// Indicates a rate change was caused by another participant connected through AVPlayerPlaybackCoordinator.
174    ///
175    /// Informs the receiver of an AVPlayerRateDidChangeNotification about a rate change originated from another AVCoordinatedPlaybackParticipant connected through AVPlayerPlaybackCoordinator. This can be used to inform UI showing why the playback rate changed. The type of the value for this key is an AVCoordinatedPlaybackParticipant, which is part of the AVPlayerPlaybackCoordinator.otherParticipants array.
176    ///
177    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangeoriginatingparticipantkey?language=objc)
178    pub static AVPlayerRateDidChangeOriginatingParticipantKey: &'static NSString;
179}
180
181/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereason?language=objc)
182// NS_TYPED_ENUM
183pub type AVPlayerRateDidChangeReason = NSString;
184
185extern "C" {
186    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereasonsetratecalled?language=objc)
187    pub static AVPlayerRateDidChangeReasonSetRateCalled: &'static AVPlayerRateDidChangeReason;
188}
189
190extern "C" {
191    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereasonsetratefailed?language=objc)
192    pub static AVPlayerRateDidChangeReasonSetRateFailed: &'static AVPlayerRateDidChangeReason;
193}
194
195extern "C" {
196    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereasonaudiosessioninterrupted?language=objc)
197    pub static AVPlayerRateDidChangeReasonAudioSessionInterrupted:
198        &'static AVPlayerRateDidChangeReason;
199}
200
201extern "C" {
202    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerratedidchangereasonappbackgrounded?language=objc)
203    pub static AVPlayerRateDidChangeReasonAppBackgrounded: &'static AVPlayerRateDidChangeReason;
204}
205
206/// These constants are the allowable values of AVPlayer's timeControlStatus property. This discussion pertains when automaticallyWaitsToMinimizeStalling is YES, the default setting, and exceptions are discussed in connection with automaticallyWaitsToMinimizeStalling.
207///
208/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayertimecontrolstatus?language=objc)
209// NS_ENUM
210#[repr(transparent)]
211#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
212pub struct AVPlayerTimeControlStatus(pub NSInteger);
213impl AVPlayerTimeControlStatus {
214    /// This state is entered upon receipt of a -pause message, an invocation of -setRate: with a value of 0.0, when a change in overall state requires playback to be halted, such as when an interruption occurs on iOS, as announced by AVAudioSession. In this state, playback is paused indefinitely and will not resume until 1) a subsequent -play message is received or 2) a -setRate: or -playImmediatelyAtRate: message with a non-zero value for rate is received and sufficient media data has been buffered for playback to proceed.
215    #[doc(alias = "AVPlayerTimeControlStatusPaused")]
216    pub const Paused: Self = Self(0);
217    /// This state is entered when 1) the playback buffer becomes empty and playback stalls in AVPlayerTimeControlStatusPlaying, 2) when rate is set from zero to non-zero in AVPlayerTimeControlStatusPaused and insufficient media data has been buffered for playback to occur, or 3) when the player has no item to play, i.e. when the receiver's currentItem is nil. In this state, the value of the rate property is not currently effective but instead indicates the rate at which playback will start or resume. Refer to the value of reasonForWaitingToPlay for details about why the receiver is waiting and the conditions that allow waitStatus to change to AVPlayerWaitStatusPlaying. While waiting for buffering, you can attempt to start playback of any available media data via -playImmediatelyAtRate:.
218    #[doc(alias = "AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate")]
219    pub const WaitingToPlayAtSpecifiedRate: Self = Self(1);
220    /// In this state, playback is currently progressing and rate changes will take effect immediately. Should playback stall because of insufficient media data, timeControlStatus will change to AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate.
221    #[doc(alias = "AVPlayerTimeControlStatusPlaying")]
222    pub const Playing: Self = Self(2);
223}
224
225unsafe impl Encode for AVPlayerTimeControlStatus {
226    const ENCODING: Encoding = NSInteger::ENCODING;
227}
228
229unsafe impl RefEncode for AVPlayerTimeControlStatus {
230    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
231}
232
233/// The type of reason that a player is waiting for playback.
234///
235/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingreason?language=objc)
236// NS_TYPED_ENUM
237pub type AVPlayerWaitingReason = NSString;
238
239extern "C" {
240    /// Indicates that the player is waiting for appropriate playback buffer conditions before starting playback
241    ///
242    /// The player is waiting for playback because automaticallyWaitToMinimizeStalling is YES and playback at the specified rate would likely cause the playback buffer to become empty before playback completes. Playback will resume when 1) playback at the specified rate will likely complete without a stall or 2) the playback buffer becomes full, meaning no forther buffering of media data is possible.
243    /// When the value of automaticallyWaitsToMinimizeStalling is NO, timeControlStatus cannot become AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate for this reason.
244    ///
245    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingtominimizestallsreason?language=objc)
246    pub static AVPlayerWaitingToMinimizeStallsReason: &'static AVPlayerWaitingReason;
247}
248
249extern "C" {
250    /// Indicates that the player is monitoring the playback buffer fill rate to determine if playback is likely to complete without interruptions.
251    ///
252    /// The player is waiting for playback because automaticallyWaitToMinimizeStalling is YES and it has not yet determined if starting playback at the specified rate would likely cause the buffer to become empty. When the brief initial monitoring period is over, either playback will begin or the value of reasonForWaitingToPlayAtSpecifiedRate will switch to AVPlayerWaitingToMinimizeStallsReason.
253    /// Recommended practice is not to show UI indicating the waiting state to the user while the value of reasonForWaitingToPlayAtSpecifiedRate is AVPlayerWaitingWhileEvaluatingBufferingRateReason.
254    ///
255    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingwhileevaluatingbufferingratereason?language=objc)
256    pub static AVPlayerWaitingWhileEvaluatingBufferingRateReason: &'static AVPlayerWaitingReason;
257}
258
259extern "C" {
260    /// Indicates that the AVPlayer is waiting because its currentItem is nil
261    ///
262    /// The player is waiting for playback because automaticallyWaitToMinimizeStalling is YES and the value of currentItem is nil. When an item becomes available, either because of a call to -replaceCurrentItemWithPlayerItem: or -insertItem: afterItem:, playback will begin or the value of reasonForWaitingToPlay will change.
263    ///
264    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingwithnoitemtoplayreason?language=objc)
265    pub static AVPlayerWaitingWithNoItemToPlayReason: &'static AVPlayerWaitingReason;
266}
267
268extern "C" {
269    /// Indicates that the player is waiting for another participant connected through its AVPlayerPlaybackCoordinator.
270    ///
271    /// The player is waiting for playback because its connected AVPlayerPlaybackCoordinator requires information from one of the other participants before playback can start.
272    ///
273    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingforcoordinatedplaybackreason?language=objc)
274    pub static AVPlayerWaitingForCoordinatedPlaybackReason: &'static AVPlayerWaitingReason;
275}
276
277/// AVPlayerPlaybackControl.
278impl AVPlayer {
279    extern_methods!(
280        /// Indicates the desired rate of playback; 0.0 means "paused", 1.0 indicates a desire to play at the natural rate of the current item.
281        ///
282        /// Setting the value of rate to 0.0 pauses playback, causing the value of timeControlStatus to change to AVPlayerTimeControlStatusPaused.
283        /// Setting the rate to a non-zero value causes the value of timeControlStatus to become either AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate or AVPlayerTimeControlStatusPlaying, depending on whether sufficient media data has been buffered for playback to occur and whether the player's default behavior of waiting in order to minimize stalling is permitted. See discussion of AVPlayerTimeControlStatus for more details.
284        ///
285        /// AVPlayer can reset the desired rate to 0.0 when a change in overall state requires playback to be halted, such as when an interruption occurs on iOS, as announced by AVAudioSession, or when the playback buffer becomes empty and playback stalls while automaticallyWaitsToMinimizeStalling is NO.
286        ///
287        /// The effective rate of playback may differ from the desired rate even while timeControlStatus is AVPlayerTimeControlStatusPlaying, if the processing algorithm in use for managing audio pitch requires quantization of playback rate. For information about quantization of rates for audio processing, see AVAudioProcessingSettings.h. You can always obtain the effective rate of playback from the currentItem's timebase; see the timebase property of AVPlayerItem.
288        ///
289        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
290        #[unsafe(method(rate))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn rate(&self) -> c_float;
293
294        /// Setter for [`rate`][Self::rate].
295        #[unsafe(method(setRate:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn setRate(&self, rate: c_float);
298
299        /// Indicates the rate at which to start playback when play is called; defaults to 1.0.
300        ///
301        /// Setting this property does not imply playback starts automatically at this rate. Clients still have to kick off playback using `play`. Note that using setRate to start playback will skip using the value in this property nor would it update this property. Therefore, `setRate:1.0` is no longer recommended as a means to start playback. Use `play` instead. Use `setRate` for operations like scanning where the rate is to be updated instantaneously. Invoking `play` again would restore playback at the rate set in this property.
302        ///
303        /// The effective rate of playback may still differ from the default rate subject to restrictions imposed by the system. See documentation for the rate property for a discussion on when the desired rate does not translate to effective rate.
304        #[unsafe(method(defaultRate))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn defaultRate(&self) -> c_float;
307
308        /// Setter for [`defaultRate`][Self::defaultRate].
309        #[unsafe(method(setDefaultRate:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn setDefaultRate(&self, default_rate: c_float);
312
313        /// Signals the desire to begin playback at the rate set in the defaultRate.
314        ///
315        /// For releases up to iOS version 16.0, macOS versions 13.0, tvOS 16.0 and watchOS 9.0, this is equivalent to setting the value of rate to `1.0`. Starting from iOS version 16.0, macOS versions 13.0, tvOS 16.0 and watchOS 9.0, this will attempt to use the rate set in the `defaultRate` property. The effective rate of playback may differ from the `defaultRate` due to the reasons mentioned in the documentation of the `rate` property. Clients interested in knowing the effective rate can listen for `AVPlayerRateDidChangeNotification` notification.
316        ///
317        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
318        #[unsafe(method(play))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn play(&self);
321
322        /// Pauses playback.
323        ///
324        /// Equivalent to setting the value of rate to 0.0.
325        ///
326        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
327        #[unsafe(method(pause))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn pause(&self);
330
331        /// Indicates whether playback is currently paused indefinitely, suspended while waiting for appropriate conditions, or in progress.
332        ///
333        /// For possible values and discussion, see AVPlayerTimeControlStatus.
334        ///
335        /// When automaticallyWaitsToMinimizeStalling is YES, absent intervention in the form of invocations of -setRate: or -pause or, on iOS, an interruption that requires user intervention before playback can resume, the value of the property timeControlStatus automatically changes between AVPlayerTimeControlStatusPlaying and AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate depending on whether sufficient media data is available to continue playback. This property is key value observable.
336        #[unsafe(method(timeControlStatus))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn timeControlStatus(&self) -> AVPlayerTimeControlStatus;
339
340        /// Indicates the reason for waiting when the value of timeControlStatus is AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate
341        ///
342        /// When the value of timeControlStatus is AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate, this property describes why the player is currently waiting. It is nil otherwise.
343        /// You can use the value of reasonForWaitingToPlay to show UI indicating the player's waiting state conditionally.
344        /// This property is key value observable.
345        /// Possible values are AVPlayerWaitingWithNoItemToPlayReason, AVPlayerWaitingWhileEvaluatingBufferingRateReason, and AVPlayerWaitingToMinimizeStallsReason.
346        #[unsafe(method(reasonForWaitingToPlay))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn reasonForWaitingToPlay(&self) -> Option<Retained<AVPlayerWaitingReason>>;
349
350        /// Immediately plays the available media data at the specified rate.
351        ///
352        /// When the player's currentItem has a value of NO for playbackBufferEmpty, this method causes the value of rate to change to the specified rate, the value of timeControlStatus to change to AVPlayerTimeControlStatusPlaying, and the receiver to play the available media immediately, whether or not prior buffering of media data is sufficient to ensure smooth playback.
353        /// If insufficient media data is buffered for playback to start (e.g. if the current item has a value of YES for playbackBufferEmpty), the receiver will act as if the buffer became empty during playback, except that no AVPlayerItemPlaybackStalledNotification will be posted.
354        ///
355        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
356        #[unsafe(method(playImmediatelyAtRate:))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn playImmediatelyAtRate(&self, rate: c_float);
359    );
360}
361
362/// These constants are the allowable values of AVPlayer's actionAtItemEnd property.
363///
364/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeractionatitemend?language=objc)
365// NS_ENUM
366#[repr(transparent)]
367#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
368pub struct AVPlayerActionAtItemEnd(pub NSInteger);
369impl AVPlayerActionAtItemEnd {
370    /// Indicates that when an AVPlayerItem reaches its end time the player will automatically advance to the next item in its queue. This value is supported only for players of class AVQueuePlayer. An AVPlayer that's not an AVQueuePlayer will raise an NSInvalidArgumentException if an attempt is made to set its actionAtItemEnd to AVPlayerActionAtItemEndAdvance.
371    #[doc(alias = "AVPlayerActionAtItemEndAdvance")]
372    pub const Advance: Self = Self(0);
373    /// Indicates that when an AVPlayerItem reaches its end time the player will automatically pause (which is to say, the player's rate will automatically be set to 0).
374    #[doc(alias = "AVPlayerActionAtItemEndPause")]
375    pub const Pause: Self = Self(1);
376    /// Indicates that when an AVPlayerItem reaches its end time the player will take no action (which is to say, the player's rate will not change, its currentItem will not change, and its currentTime will continue to be incremented or decremented as time elapses, according to its rate). After this, if the player's actionAtItemEnd is set to a value other than AVPlayerActionAtItemEndNone, the player will immediately take the action appropriate to that value.
377    #[doc(alias = "AVPlayerActionAtItemEndNone")]
378    pub const None: Self = Self(2);
379}
380
381unsafe impl Encode for AVPlayerActionAtItemEnd {
382    const ENCODING: Encoding = NSInteger::ENCODING;
383}
384
385unsafe impl RefEncode for AVPlayerActionAtItemEnd {
386    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
387}
388
389/// AVPlayerItemControl.
390impl AVPlayer {
391    extern_methods!(
392        #[cfg(feature = "AVPlayerItem")]
393        /// Indicates the current item of the player
394        #[unsafe(method(currentItem))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn currentItem(&self) -> Option<Retained<AVPlayerItem>>;
397
398        #[cfg(feature = "AVPlayerItem")]
399        /// Replaces the player's current item with the specified player item.
400        ///
401        /// In all releases of iOS 4, invoking replaceCurrentItemWithPlayerItem: with an AVPlayerItem that's already the receiver's currentItem results in an exception being raised. Starting with iOS 5, it's a no-op.
402        /// This method throws an exception if the item already exists in the play queue.
403        ///
404        /// - Parameter item: The AVPlayerItem that will become the player's current item.
405        #[unsafe(method(replaceCurrentItemWithPlayerItem:))]
406        #[unsafe(method_family = none)]
407        pub unsafe fn replaceCurrentItemWithPlayerItem(&self, item: Option<&AVPlayerItem>);
408
409        /// Indicates the action that the player should perform when playback of an item reaches its end time.
410        ///
411        /// This property throws an exception if set to AVPlayerActionAtItemEndAdvance on an AVPlayer which is not an AVQueuePlayer.
412        #[unsafe(method(actionAtItemEnd))]
413        #[unsafe(method_family = none)]
414        pub unsafe fn actionAtItemEnd(&self) -> AVPlayerActionAtItemEnd;
415
416        /// Setter for [`actionAtItemEnd`][Self::actionAtItemEnd].
417        #[unsafe(method(setActionAtItemEnd:))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn setActionAtItemEnd(&self, action_at_item_end: AVPlayerActionAtItemEnd);
420    );
421}
422
423/// AVPlayerTimeControl.
424impl AVPlayer {
425    extern_methods!(
426        #[cfg(feature = "objc2-core-media")]
427        /// Returns the current time of the current item.
428        ///
429        /// Returns the current time of the current item. Not key-value observable; use -addPeriodicTimeObserverForInterval:queue:usingBlock: instead.
430        ///
431        /// - Returns: A CMTime
432        #[unsafe(method(currentTime))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn currentTime(&self) -> CMTime;
435
436        /// Moves the playback cursor.
437        ///
438        /// Use this method to seek to a specified time for the current player item.
439        /// The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:.
440        ///
441        /// - Parameter date:
442        #[unsafe(method(seekToDate:))]
443        #[unsafe(method_family = none)]
444        pub unsafe fn seekToDate(&self, date: &NSDate);
445
446        #[cfg(feature = "block2")]
447        /// Moves the playback cursor and invokes the specified block when the seek operation has either been completed or been interrupted.
448        ///
449        /// Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete.
450        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter
451        /// set to NO. If the new request completes without being interrupted by another seek request or by any other operation the specified
452        /// completion handler will be invoked with the finished parameter set to YES. If no item is attached, the completion handler will be
453        /// invoked immediately with the finished parameter set to NO.
454        ///
455        /// - Parameter date:
456        /// - Parameter completionHandler:
457        ///
458        /// # Safety
459        ///
460        /// `completion_handler` block must be sendable.
461        #[unsafe(method(seekToDate:completionHandler:))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn seekToDate_completionHandler(
464            &self,
465            date: &NSDate,
466            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
467        );
468
469        #[cfg(feature = "objc2-core-media")]
470        /// Moves the playback cursor.
471        ///
472        /// Use this method to seek to a specified time for the current player item.
473        /// The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:.
474        ///
475        /// - Parameter time:
476        #[unsafe(method(seekToTime:))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn seekToTime(&self, time: CMTime);
479
480        #[cfg(feature = "objc2-core-media")]
481        /// Moves the playback cursor within a specified time bound.
482        ///
483        /// Use this method to seek to a specified time for the current player item.
484        /// The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency.
485        /// Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay.
486        /// Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly.
487        ///
488        /// - Parameter time:
489        /// - Parameter toleranceBefore:
490        /// - Parameter toleranceAfter:
491        #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn seekToTime_toleranceBefore_toleranceAfter(
494            &self,
495            time: CMTime,
496            tolerance_before: CMTime,
497            tolerance_after: CMTime,
498        );
499
500        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
501        /// Moves the playback cursor and invokes the specified block when the seek operation has either been completed or been interrupted.
502        ///
503        /// Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete.
504        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter
505        /// set to NO. If the new request completes without being interrupted by another seek request or by any other operation the specified
506        /// completion handler will be invoked with the finished parameter set to YES. If no item is attached, the completion handler will be
507        /// invoked immediately with the finished parameter set to NO.
508        ///
509        /// - Parameter time:
510        /// - Parameter completionHandler:
511        ///
512        /// # Safety
513        ///
514        /// `completion_handler` block must be sendable.
515        #[unsafe(method(seekToTime:completionHandler:))]
516        #[unsafe(method_family = none)]
517        pub unsafe fn seekToTime_completionHandler(
518            &self,
519            time: CMTime,
520            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
521        );
522
523        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
524        /// Moves the playback cursor within a specified time bound and invokes the specified block when the seek operation has either been completed or been interrupted.
525        ///
526        /// Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete.
527        /// The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency.
528        /// Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay.
529        /// Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly.
530        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter set to NO. If the new
531        /// request completes without being interrupted by another seek request or by any other operation the specified completion handler will be invoked with the
532        /// finished parameter set to YES. If no item is attached, the completion handler will be invoked immediately with the finished parameter set to NO.
533        ///
534        /// - Parameter time:
535        /// - Parameter toleranceBefore:
536        /// - Parameter toleranceAfter:
537        ///
538        /// # Safety
539        ///
540        /// `completion_handler` block must be sendable.
541        #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:completionHandler:))]
542        #[unsafe(method_family = none)]
543        pub unsafe fn seekToTime_toleranceBefore_toleranceAfter_completionHandler(
544            &self,
545            time: CMTime,
546            tolerance_before: CMTime,
547            tolerance_after: CMTime,
548            completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
549        );
550    );
551}
552
553/// AVPlayerAdvancedRateControl.
554impl AVPlayer {
555    extern_methods!(
556        /// Indicates that the player is allowed to delay playback at the specified rate in order to minimize stalling
557        ///
558        /// When this property is YES, whenever 1) the rate is set from zero to non-zero or 2) the playback buffer becomes empty and playback stalls, the player will attempt to determine if, at the specified rate, its currentItem will play to the end without interruptions. Should it determine that such interruptions would occur and these interruptions can be avoided by delaying the start or resumption of playback, the value of timeControlStatus will become AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate and playback will start automatically when the likelihood of stalling has been minimized.
559        ///
560        /// You may want to set this property to NO when you need precise control over playback start times, e.g., when synchronizing multiple instances of AVPlayer, and you should set it to NO if you use an AVAssetResourceLoader delegate to load media data (more on this below). If the value of this property is NO, reasonForWaitingToPlay cannot assume a value of AVPlayerWaitingToMinimizeStallsReason.
561        /// This implies that setting rate to a non-zero value in AVPlayerTimeControlStatusPaused will cause playback to start immediately as long as the playback buffer is not empty. When the playback buffer becomes empty during AVPlayerTimeControlStatusPlaying and playback stalls, playback state will switch to AVPlayerTimeControlStatusPaused and the rate will become 0.0.
562        ///
563        /// Changing the value of this property to NO while the value of timeControlStatus is AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate with a reasonForWaitingToPlay of AVPlayerWaitingToMinimizeStallsReason will cause the player to attempt playback at the specified rate immediately.
564        ///
565        /// For clients linked against iOS 10.0 and running on that version or later or linked against macOS 10.12 and running on that version or later, the default value of this property is YES.
566        /// In versions of iOS prior to iOS 10.0 and versions of macOS prior to 10.12, this property is unavailable, and the behavior of the AVPlayer corresponds to the type of content being played. For streaming content, including HTTP Live Streaming, the AVPlayer acts as if automaticallyWaitsToMinimizeStalling is YES. For file-based content, including file-based content accessed via progressive http download, the AVPlayer acts as if automaticallyWaitsToMinimizeStalling is NO.
567        ///
568        /// If you employ an AVAssetResourceLoader delegate that loads media data for playback, you should set the value of your AVPlayer’s automaticallyWaitsToMinimizeStalling property to NO. Allowing the value of automaticallyWaitsToMinimizeStalling to remain YES when an AVAssetResourceLoader delegate is used for the loading of media data can result in poor start-up times for playback and poor recovery from stalls, because the behaviors provided by AVPlayer when automaticallyWaitsToMinimizeStalling has a value of YES depend on predictions of the future availability of media data that that do not function as expected when data is loaded via a client-controlled means, using the AVAssetResourceLoader delegate interface.
569        ///
570        /// You can allow the value of automaticallyWaitsToMinimizeStalling to remain YES if you use an AVAssetResourceLoader delegate to manage content keys for FairPlay Streaming, to provide dynamically-generated master playlists for HTTP Live Streaming, or to respond to authentication challenges, but not to load media data for playback.
571        ///
572        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
573        #[unsafe(method(automaticallyWaitsToMinimizeStalling))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn automaticallyWaitsToMinimizeStalling(&self) -> bool;
576
577        /// Setter for [`automaticallyWaitsToMinimizeStalling`][Self::automaticallyWaitsToMinimizeStalling].
578        #[unsafe(method(setAutomaticallyWaitsToMinimizeStalling:))]
579        #[unsafe(method_family = none)]
580        pub unsafe fn setAutomaticallyWaitsToMinimizeStalling(
581            &self,
582            automatically_waits_to_minimize_stalling: bool,
583        );
584
585        #[cfg(feature = "objc2-core-media")]
586        /// Simultaneously sets the playback rate and the relationship between the current item's current time and host time.
587        ///
588        /// You can use this function to synchronize playback with an external activity.
589        ///
590        /// The current item's timebase is adjusted so that its time will be (or was) itemTime when host time is (or was) hostClockTime.
591        /// In other words: if hostClockTime is in the past, the timebase's time will be interpolated as though the timebase has been running at the requested rate since that time. If hostClockTime is in the future, the timebase will immediately start running at the requested rate from an earlier time so that it will reach the requested itemTime at the requested hostClockTime. (Note that the item's time will not jump backwards, but instead will sit at itemTime until the timebase reaches that time.)
592        ///
593        /// Note that setRate:time:atHostTime: is not supported when automaticallyWaitsToMinimizeStalling is YES. For clients linked against iOS 10.0 and later or macOS 12.0 and later, invoking setRate:time:atHostTime: when automaticallyWaitsToMinimizeStalling is YES will raise an NSInvalidArgument exception. Support for HTTP Live Streaming content requires iOS 11, tvOS 11, macOS 10.13 or later.
594        ///
595        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
596        ///
597        /// - Parameter itemTime: The time to start playback from, specified precisely (i.e., with zero tolerance). Pass kCMTimeInvalid to use the current item's current time.
598        /// - Parameter hostClockTime: The host time at which to start playback. If hostClockTime is specified, the player will not ensure that media data is loaded before the timebase starts moving. If hostClockTime is kCMTimeInvalid, the rate and time will be set together, but without external synchronization; a host time in the near future will be used, allowing some time for media data loading.
599        #[unsafe(method(setRate:time:atHostTime:))]
600        #[unsafe(method_family = none)]
601        pub unsafe fn setRate_time_atHostTime(
602            &self,
603            rate: c_float,
604            item_time: CMTime,
605            host_clock_time: CMTime,
606        );
607
608        #[cfg(feature = "block2")]
609        /// Begins loading media data to prime the render pipelines for playback from the current time with the given rate.
610        ///
611        /// Once the completion handler is called with YES, the player's rate can be set with minimal latency.
612        /// The completion handler will be called with NO if the preroll is interrupted by a time change or incompatible rate change, or if preroll is not possible for some other reason.
613        /// Call this method only when the rate is currently zero and only after the AVPlayer's status has become AVPlayerStatusReadyToPlay.
614        /// This method throws an exception if the status is not AVPlayerStatusReadyToPlay.
615        ///
616        /// - Parameter rate: The intended rate for subsequent playback.
617        /// - Parameter completionHandler: The block that will be called when the preroll is either completed or is interrupted.
618        ///
619        /// # Safety
620        ///
621        /// `completion_handler` block must be sendable.
622        #[unsafe(method(prerollAtRate:completionHandler:))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn prerollAtRate_completionHandler(
625            &self,
626            rate: c_float,
627            completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
628        );
629
630        /// Cancel any pending preroll requests and invoke the corresponding completion handlers if present.
631        ///
632        /// Use this method to cancel and release the completion handlers for pending prerolls. The finished parameter of the completion handlers will be set to NO.
633        #[unsafe(method(cancelPendingPrerolls))]
634        #[unsafe(method_family = none)]
635        pub unsafe fn cancelPendingPrerolls(&self);
636
637        #[cfg(feature = "objc2-core-media")]
638        /// Set to override the automatic choice of source clock for item timebases.
639        ///
640        /// NULL by default. This is most useful for synchronizing video-only movies with audio played via other means. IMPORTANT NOTE: If you specify a source clock other than the appropriate audio device clock, audio may drift out of sync.
641        #[unsafe(method(sourceClock))]
642        #[unsafe(method_family = none)]
643        pub unsafe fn sourceClock(&self) -> Option<Retained<CMClock>>;
644
645        #[cfg(feature = "objc2-core-media")]
646        /// Setter for [`sourceClock`][Self::sourceClock].
647        #[unsafe(method(setSourceClock:))]
648        #[unsafe(method_family = none)]
649        pub unsafe fn setSourceClock(&self, source_clock: Option<&CMClock>);
650    );
651}
652
653/// AVPlayerTimeObservation.
654impl AVPlayer {
655    extern_methods!(
656        #[cfg(all(
657            feature = "block2",
658            feature = "dispatch2",
659            feature = "objc2-core-media"
660        ))]
661        /// Requests invocation of a block during playback to report changing time.
662        ///
663        /// The block is invoked periodically at the interval specified, interpreted according to the timeline of the current item.
664        /// The block is also invoked whenever time jumps and whenever playback starts or stops.
665        /// If the interval corresponds to a very short interval in real time, the player may invoke the block less frequently
666        /// than requested. Even so, the player will invoke the block sufficiently often for the client to update indications
667        /// of the current time appropriately in its end-user interface.
668        /// Each call to -addPeriodicTimeObserverForInterval:queue:usingBlock: should be paired with a corresponding call to -removeTimeObserver:.
669        /// Releasing the observer object without a call to -removeTimeObserver: will result in undefined behavior.
670        ///
671        /// - Parameter interval: The interval of invocation of the block during normal playback, according to progress of the current time of the player.
672        /// - Parameter queue: The serial queue onto which block should be enqueued. If you pass NULL, the main queue (obtained using dispatch_get_main_queue()) will be used. Passing a concurrent queue to this method will result in undefined behavior.
673        /// - Parameter block: The block to be invoked periodically.
674        ///
675        /// - Returns: An object conforming to the NSObject protocol.  You must retain this returned value as long as you want the time observer to be invoked by the player.
676        /// Pass this object to -removeTimeObserver: to cancel time observation.
677        ///
678        /// # Safety
679        ///
680        /// - `queue` possibly has additional threading requirements.
681        /// - `block` block must be sendable.
682        #[unsafe(method(addPeriodicTimeObserverForInterval:queue:usingBlock:))]
683        #[unsafe(method_family = none)]
684        pub unsafe fn addPeriodicTimeObserverForInterval_queue_usingBlock(
685            &self,
686            interval: CMTime,
687            queue: Option<&DispatchQueue>,
688            block: &block2::DynBlock<dyn Fn(CMTime)>,
689        ) -> Retained<AnyObject>;
690
691        #[cfg(all(feature = "block2", feature = "dispatch2"))]
692        /// Requests invocation of a block when specified times are traversed during normal playback.
693        ///
694        /// Each call to -addPeriodicTimeObserverForInterval:queue:usingBlock: should be paired with a corresponding call to -removeTimeObserver:.
695        /// Releasing the observer object without a call to -removeTimeObserver: will result in undefined behavior.
696        ///
697        /// - Parameter times: The times for which the observer requests notification, supplied as an array of NSValues carrying CMTimes.
698        /// - Parameter queue: The serial queue onto which block should be enqueued. If you pass NULL, the main queue (obtained using dispatch_get_main_queue()) will be used. Passing a concurrent queue to this method will result in undefined behavior.
699        /// - Parameter block: The block to be invoked when any of the specified times is crossed during normal playback.
700        ///
701        /// - Returns: An object conforming to the NSObject protocol.  You must retain this returned value as long as you want the time observer to be invoked by the player.
702        /// Pass this object to -removeTimeObserver: to cancel time observation.
703        ///
704        /// # Safety
705        ///
706        /// - `queue` possibly has additional threading requirements.
707        /// - `block` block must be sendable.
708        #[unsafe(method(addBoundaryTimeObserverForTimes:queue:usingBlock:))]
709        #[unsafe(method_family = none)]
710        pub unsafe fn addBoundaryTimeObserverForTimes_queue_usingBlock(
711            &self,
712            times: &NSArray<NSValue>,
713            queue: Option<&DispatchQueue>,
714            block: &block2::DynBlock<dyn Fn()>,
715        ) -> Retained<AnyObject>;
716
717        /// Cancels a previously registered time observer.
718        ///
719        /// Upon return, the caller is guaranteed that no new time observer blocks will begin executing. Depending on the calling thread and the queue
720        /// used to add the time observer, an in-flight block may continue to execute after this method returns. You can guarantee synchronous time
721        /// observer removal by enqueuing the call to -removeTimeObserver: on that queue. Alternatively, call dispatch_sync(queue, ^{}) after
722        /// -removeTimeObserver: to wait for any in-flight blocks to finish executing.
723        /// -removeTimeObserver: should be used to explicitly cancel each time observer added using -addPeriodicTimeObserverForInterval:queue:usingBlock:
724        /// and -addBoundaryTimeObserverForTimes:queue:usingBlock:.
725        ///
726        /// This method throws an exception for any of the following reasons:
727        /// - observer was added by a different instance of AVPlayer
728        /// - observer was not returned by -addPeriodicTimeObserverForInterval:queue:usingBlock:
729        /// - observer was not returned by -addBoundaryTimeObserverForTimes:queue:usingBlock:
730        ///
731        /// - Parameter observer: An object returned by a previous call to -addPeriodicTimeObserverForInterval:queue:usingBlock: or -addBoundaryTimeObserverForTimes:queue:usingBlock:.
732        ///
733        /// # Safety
734        ///
735        /// `observer` should be of the correct type.
736        #[unsafe(method(removeTimeObserver:))]
737        #[unsafe(method_family = none)]
738        pub unsafe fn removeTimeObserver(&self, observer: &AnyObject);
739    );
740}
741
742/// AVPlayerMediaControl.
743impl AVPlayer {
744    extern_methods!(
745        /// Indicates the current audio volume of the player; 0.0 means "silence all audio", 1.0 means "play at the full volume of the current item".
746        ///
747        /// iOS note: Do not use this property to implement a volume slider for media playback. For that purpose, use MPVolumeView, which is customizable in appearance and provides standard media playback behaviors that users expect.
748        /// This property is most useful on iOS to control the volume of the AVPlayer relative to other audio output, not for volume control by end users.
749        #[unsafe(method(volume))]
750        #[unsafe(method_family = none)]
751        pub unsafe fn volume(&self) -> c_float;
752
753        /// Setter for [`volume`][Self::volume].
754        #[unsafe(method(setVolume:))]
755        #[unsafe(method_family = none)]
756        pub unsafe fn setVolume(&self, volume: c_float);
757
758        /// Indicates whether or not audio output of the player is muted. Only affects audio muting for the player instance and not for the device.
759        #[unsafe(method(isMuted))]
760        #[unsafe(method_family = none)]
761        pub unsafe fn isMuted(&self) -> bool;
762
763        /// Setter for [`isMuted`][Self::isMuted].
764        #[unsafe(method(setMuted:))]
765        #[unsafe(method_family = none)]
766        pub unsafe fn setMuted(&self, muted: bool);
767    );
768}
769
770/// AVPlayerAutomaticMediaSelection.
771impl AVPlayer {
772    extern_methods!(
773        /// Indicates whether the receiver should apply the current selection criteria automatically to AVPlayerItems.
774        ///
775        /// For clients linked against the iOS 7 SDK or later or against the macOS 10.9 SDK or later, the default is YES. For all others, the default is NO.
776        ///
777        /// By default, AVPlayer applies selection criteria based on system preferences. To override the default criteria for any media selection group, use -[AVPlayer setMediaSelectionCriteria:forMediaCharacteristic:].
778        #[unsafe(method(appliesMediaSelectionCriteriaAutomatically))]
779        #[unsafe(method_family = none)]
780        pub unsafe fn appliesMediaSelectionCriteriaAutomatically(&self) -> bool;
781
782        /// Setter for [`appliesMediaSelectionCriteriaAutomatically`][Self::appliesMediaSelectionCriteriaAutomatically].
783        #[unsafe(method(setAppliesMediaSelectionCriteriaAutomatically:))]
784        #[unsafe(method_family = none)]
785        pub unsafe fn setAppliesMediaSelectionCriteriaAutomatically(
786            &self,
787            applies_media_selection_criteria_automatically: bool,
788        );
789
790        #[cfg(all(feature = "AVMediaFormat", feature = "AVPlayerMediaSelectionCriteria"))]
791        /// Applies automatic selection criteria for media that has the specified media characteristic.
792        ///
793        /// Criteria will be applied to an AVPlayerItem when:
794        /// a) It is made ready to play
795        /// b) Specific media selections are made by -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:] in a different group. The automatic choice in one group may be influenced by a specific selection in another group.
796        /// c) Underlying system preferences change, e.g. system language, accessibility captions.
797        ///
798        /// Specific selections made by -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:] within any group will override automatic selection in that group until -[AVPlayerItem selectMediaOptionAutomaticallyInMediaSelectionGroup:] is received.
799        ///
800        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
801        ///
802        /// - Parameter criteria: An instance of AVPlayerMediaSelectionCriteria.
803        /// - Parameter mediaCharacteristic: The media characteristic for which the selection criteria are to be applied. Supported values include AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual.
804        #[unsafe(method(setMediaSelectionCriteria:forMediaCharacteristic:))]
805        #[unsafe(method_family = none)]
806        pub unsafe fn setMediaSelectionCriteria_forMediaCharacteristic(
807            &self,
808            criteria: Option<&AVPlayerMediaSelectionCriteria>,
809            media_characteristic: &AVMediaCharacteristic,
810        );
811
812        #[cfg(all(feature = "AVMediaFormat", feature = "AVPlayerMediaSelectionCriteria"))]
813        /// Returns the automatic selection criteria for media that has the specified media characteristic.
814        ///
815        /// - Parameter mediaCharacteristic: The media characteristic for which the selection criteria is to be returned. Supported values include AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual. Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
816        #[unsafe(method(mediaSelectionCriteriaForMediaCharacteristic:))]
817        #[unsafe(method_family = none)]
818        pub unsafe fn mediaSelectionCriteriaForMediaCharacteristic(
819            &self,
820            media_characteristic: &AVMediaCharacteristic,
821        ) -> Option<Retained<AVPlayerMediaSelectionCriteria>>;
822    );
823}
824
825/// AVPlayerAudioDeviceSupport.
826impl AVPlayer {
827    extern_methods!(
828        /// Specifies the unique ID of the Core Audio output device used to play audio.
829        ///
830        /// By default, the value of this property is nil, indicating that the default audio output device is used. Otherwise the value of this property is an NSString containing the unique ID of the Core Audio output device to be used for audio output.
831        ///
832        /// Core Audio's kAudioDevicePropertyDeviceUID is a suitable source of audio output device unique IDs.
833        #[unsafe(method(audioOutputDeviceUniqueID))]
834        #[unsafe(method_family = none)]
835        pub unsafe fn audioOutputDeviceUniqueID(&self) -> Option<Retained<NSString>>;
836
837        /// Setter for [`audioOutputDeviceUniqueID`][Self::audioOutputDeviceUniqueID].
838        ///
839        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
840        #[unsafe(method(setAudioOutputDeviceUniqueID:))]
841        #[unsafe(method_family = none)]
842        pub unsafe fn setAudioOutputDeviceUniqueID(
843            &self,
844            audio_output_device_unique_id: Option<&NSString>,
845        );
846    );
847}
848
849/// AVPlayerExternalPlaybackSupport.
850///
851/// Methods for supporting "external playback" of video
852///
853/// "External playback" is a mode where video data is sent to an external device for full screen playback at its original fidelity.
854/// AirPlay Video playback is considered as an "external playback" mode.
855///
856/// In "external screen" mode (also known as mirroring and second display), video data is rendered on the host
857/// device (e.g. Mac and iPhone), rendered video is recompressed and transferred to the external device, and the
858/// external device decompresses and displays the video.
859///
860/// AVPlayerExternalPlaybackSupport properties affect AirPlay Video playback and are the replacement for the
861/// deprecated AVPlayerAirPlaySupport properties.
862///
863/// Additional note for iOS: AVPlayerExternalPlaybackSupport properties apply to the Lightning-based
864/// video adapters but do not apply to 30-pin-connector-based video output cables and adapters.
865impl AVPlayer {
866    extern_methods!(
867        /// Indicates whether the player allows switching to "external playback" mode. The default value is YES.
868        #[unsafe(method(allowsExternalPlayback))]
869        #[unsafe(method_family = none)]
870        pub unsafe fn allowsExternalPlayback(&self) -> bool;
871
872        /// Setter for [`allowsExternalPlayback`][Self::allowsExternalPlayback].
873        #[unsafe(method(setAllowsExternalPlayback:))]
874        #[unsafe(method_family = none)]
875        pub unsafe fn setAllowsExternalPlayback(&self, allows_external_playback: bool);
876
877        /// Indicates whether the player is currently playing video in "external playback" mode.
878        #[unsafe(method(isExternalPlaybackActive))]
879        #[unsafe(method_family = none)]
880        pub unsafe fn isExternalPlaybackActive(&self) -> bool;
881
882        /// Indicates whether the player should automatically switch to "external playback" mode while the "external screen" mode is active in order to play video content and switching back to "external screen" mode as soon as playback is done. Brief transition may be visible on the external display when automatically switching between the two modes. The default value is NO. Has no effect if allowsExternalPlayback is NO.
883        #[unsafe(method(usesExternalPlaybackWhileExternalScreenIsActive))]
884        #[unsafe(method_family = none)]
885        pub unsafe fn usesExternalPlaybackWhileExternalScreenIsActive(&self) -> bool;
886
887        /// Setter for [`usesExternalPlaybackWhileExternalScreenIsActive`][Self::usesExternalPlaybackWhileExternalScreenIsActive].
888        #[unsafe(method(setUsesExternalPlaybackWhileExternalScreenIsActive:))]
889        #[unsafe(method_family = none)]
890        pub unsafe fn setUsesExternalPlaybackWhileExternalScreenIsActive(
891            &self,
892            uses_external_playback_while_external_screen_is_active: bool,
893        );
894
895        #[cfg(feature = "AVAnimation")]
896        /// Video gravity strictly for "external playback" mode, one of AVLayerVideoGravity* defined in AVAnimation.h
897        #[unsafe(method(externalPlaybackVideoGravity))]
898        #[unsafe(method_family = none)]
899        pub unsafe fn externalPlaybackVideoGravity(&self) -> Retained<AVLayerVideoGravity>;
900
901        #[cfg(feature = "AVAnimation")]
902        /// Setter for [`externalPlaybackVideoGravity`][Self::externalPlaybackVideoGravity].
903        ///
904        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
905        #[unsafe(method(setExternalPlaybackVideoGravity:))]
906        #[unsafe(method_family = none)]
907        pub unsafe fn setExternalPlaybackVideoGravity(
908            &self,
909            external_playback_video_gravity: &AVLayerVideoGravity,
910        );
911    );
912}
913
914/// AVPlayerProtectedContent.
915///
916/// Methods supporting protected content.
917impl AVPlayer {
918    extern_methods!(
919        /// Whether or not decoded output is being obscured due to insufficient external protection.
920        ///
921        /// The value of this property indicates whether the player is purposefully obscuring the visual output
922        /// of the current item because the requirement for an external protection mechanism is not met by the
923        /// current device configuration. It is highly recommended that clients whose content requires external
924        /// protection observe this property and set the playback rate to zero and display an appropriate user
925        /// interface when the value changes to YES. This property is key value observable.
926        ///
927        /// Note that the value of this property is dependent on the external protection requirements of the
928        /// current item. These requirements are inherent to the content itself and cannot be externally specified.
929        /// If the current item does not require external protection, the value of this property will be NO.
930        #[unsafe(method(outputObscuredDueToInsufficientExternalProtection))]
931        #[unsafe(method_family = none)]
932        pub unsafe fn outputObscuredDueToInsufficientExternalProtection(&self) -> bool;
933    );
934}
935
936/// A bitfield type that specifies an HDR mode.
937///
938/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerhdrmode?language=objc)
939// NS_OPTIONS
940#[deprecated = "The deprecated availableHDRModes uses this enum. Use eligibleForHDRPlayback instead"]
941#[repr(transparent)]
942#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
943pub struct AVPlayerHDRMode(pub NSInteger);
944bitflags::bitflags! {
945    impl AVPlayerHDRMode: NSInteger {
946/// Indicates that HLG (Hybrid Log-Gamma) HDR mode is available.
947        #[doc(alias = "AVPlayerHDRModeHLG")]
948#[deprecated = "The deprecated availableHDRModes uses this enum. Use eligibleForHDRPlayback instead"]
949        const HLG = 0x1;
950/// Indicates that HDR10 HDR mode is available.
951        #[doc(alias = "AVPlayerHDRModeHDR10")]
952#[deprecated = "The deprecated availableHDRModes uses this enum. Use eligibleForHDRPlayback instead"]
953        const HDR10 = 0x2;
954/// Indicates that Dolby Vision HDR mode is available.
955        #[doc(alias = "AVPlayerHDRModeDolbyVision")]
956#[deprecated = "The deprecated availableHDRModes uses this enum. Use eligibleForHDRPlayback instead"]
957        const DolbyVision = 0x4;
958    }
959}
960
961unsafe impl Encode for AVPlayerHDRMode {
962    const ENCODING: Encoding = NSInteger::ENCODING;
963}
964
965unsafe impl RefEncode for AVPlayerHDRMode {
966    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
967}
968
969extern "C" {
970    /// A notification that fires whenever availableHDRModes changes.
971    ///
972    /// This notification fires when a value is added or removed from the list of availableHDRModes. This can be caused by display connection/disconnection or resource changes.
973    ///
974    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeravailablehdrmodesdidchangenotification?language=objc)
975    #[deprecated]
976    pub static AVPlayerAvailableHDRModesDidChangeNotification: &'static NSNotificationName;
977}
978
979extern "C" {
980    /// A notification that fires whenever eligibleForHDRPlayback changes.
981    ///
982    /// This notification fires when eligibleForHDRPlayback changes. This can be caused by display connection/disconnection or resource changes.
983    ///
984    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayereligibleforhdrplaybackdidchangenotification?language=objc)
985    pub static AVPlayerEligibleForHDRPlaybackDidChangeNotification: &'static NSNotificationName;
986}
987
988/// AVPlayerPlaybackCapabilities.
989impl AVPlayer {
990    extern_methods!(
991        /// An AVPlayerHDRMode value that indicates the HDR modes the device can play to an appropriate display. A value of 0 indicates that no HDR modes are supported.
992        ///
993        /// This property indicates all of the HDR modes that the device can play. Each value indicates that an appropriate HDR display is available for the specified HDR mode. Additionally, the device must be capable of playing the specified HDR type. This property does not indicate whether video contains HDR content, whether HDR video is currently playing, or whether video is playing on an HDR display.
994        #[deprecated = "Use eligibleForHDRPlayback instead"]
995        #[unsafe(method(availableHDRModes))]
996        #[unsafe(method_family = none)]
997        pub unsafe fn availableHDRModes(mtm: MainThreadMarker) -> AVPlayerHDRMode;
998
999        /// Indicates whether HDR content can be played to an appropriate display.
1000        ///
1001        /// This property is YES if an HDR display is available and the device is capable of playing HDR content from an appropriate AVAsset, NO otherwise. This property does not indicate whether video contains HDR content, whether HDR video is currently playing, or whether video is playing on an HDR display. This property is not KVO observable.
1002        #[unsafe(method(eligibleForHDRPlayback))]
1003        #[unsafe(method_family = none)]
1004        pub unsafe fn eligibleForHDRPlayback(mtm: MainThreadMarker) -> bool;
1005    );
1006}
1007
1008/// AVPlayerVideoDecoderGPUSupport.
1009impl AVPlayer {
1010    extern_methods!(
1011        /// Specifies a registryID associated with a GPU that should be used for video decode.
1012        ///
1013        /// By default, whenever possible, video decode will be performed on the GPU associated with the display on which the presenting CALayer is located. Decode will be transitioned to a new GPU if appropriate when the CALayer moves to a new display. This property overrides this default behavior, forcing decode to prefer an affinity to the GPU specified regardless of which GPU is being used to display the associated CALayer.
1014        ///
1015        /// The GPU registryID can be obtained from the GPU MTLDevice using [MTLDevice registryID] or can be obtained from OpenGL or OpenCL.
1016        #[unsafe(method(preferredVideoDecoderGPURegistryID))]
1017        #[unsafe(method_family = none)]
1018        pub unsafe fn preferredVideoDecoderGPURegistryID(&self) -> u64;
1019
1020        /// Setter for [`preferredVideoDecoderGPURegistryID`][Self::preferredVideoDecoderGPURegistryID].
1021        #[unsafe(method(setPreferredVideoDecoderGPURegistryID:))]
1022        #[unsafe(method_family = none)]
1023        pub unsafe fn setPreferredVideoDecoderGPURegistryID(
1024            &self,
1025            preferred_video_decoder_gpu_registry_id: u64,
1026        );
1027    );
1028}
1029
1030/// AVPlayerVideoDisplaySleepPrevention.
1031impl AVPlayer {
1032    extern_methods!(
1033        /// Indicates whether video playback prevents display and device sleep.
1034        ///
1035        /// Default is YES on iOS, tvOS and in Mac Catalyst apps. Default is NO on macOS.
1036        /// Setting this property to NO does not force the display to sleep, it simply stops preventing display sleep. Other apps or frameworks within your app may still be preventing display sleep for various reasons.
1037        ///
1038        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
1039        #[unsafe(method(preventsDisplaySleepDuringVideoPlayback))]
1040        #[unsafe(method_family = none)]
1041        pub unsafe fn preventsDisplaySleepDuringVideoPlayback(&self) -> bool;
1042
1043        /// Setter for [`preventsDisplaySleepDuringVideoPlayback`][Self::preventsDisplaySleepDuringVideoPlayback].
1044        #[unsafe(method(setPreventsDisplaySleepDuringVideoPlayback:))]
1045        #[unsafe(method_family = none)]
1046        pub unsafe fn setPreventsDisplaySleepDuringVideoPlayback(
1047            &self,
1048            prevents_display_sleep_during_video_playback: bool,
1049        );
1050    );
1051}
1052
1053/// AVPlayerAutomaticBackgroundPrevention.
1054impl AVPlayer {
1055    extern_methods!(
1056        /// Indicates whether video playback prevents the app from automatically getting backgrounded.
1057        ///
1058        /// Default value is YES.
1059        /// Setting this property to YES prevents an application that is playing video from automatically getting backgrounded. This property does not prevent the user from backgrounding the application.
1060        #[unsafe(method(preventsAutomaticBackgroundingDuringVideoPlayback))]
1061        #[unsafe(method_family = none)]
1062        pub unsafe fn preventsAutomaticBackgroundingDuringVideoPlayback(&self) -> bool;
1063
1064        /// Setter for [`preventsAutomaticBackgroundingDuringVideoPlayback`][Self::preventsAutomaticBackgroundingDuringVideoPlayback].
1065        #[unsafe(method(setPreventsAutomaticBackgroundingDuringVideoPlayback:))]
1066        #[unsafe(method_family = none)]
1067        pub unsafe fn setPreventsAutomaticBackgroundingDuringVideoPlayback(
1068            &self,
1069            prevents_automatic_backgrounding_during_video_playback: bool,
1070        );
1071    );
1072}
1073
1074/// This policy describes how AVPlayer behaves when the application transitions to UIApplicationStateBackground while playing video.
1075///
1076/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeraudiovisualbackgroundplaybackpolicy?language=objc)
1077// NS_ENUM
1078#[repr(transparent)]
1079#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1080pub struct AVPlayerAudiovisualBackgroundPlaybackPolicy(pub NSInteger);
1081impl AVPlayerAudiovisualBackgroundPlaybackPolicy {
1082    /// Indicates that the system is free to decide. This is the default policy.
1083    #[doc(alias = "AVPlayerAudiovisualBackgroundPlaybackPolicyAutomatic")]
1084    pub const Automatic: Self = Self(1);
1085    /// Indicates that the player must be paused on going to background.
1086    #[doc(alias = "AVPlayerAudiovisualBackgroundPlaybackPolicyPauses")]
1087    pub const Pauses: Self = Self(2);
1088    /// Indicates that the player continues to play if possible in background.
1089    #[doc(alias = "AVPlayerAudiovisualBackgroundPlaybackPolicyContinuesIfPossible")]
1090    pub const ContinuesIfPossible: Self = Self(3);
1091}
1092
1093unsafe impl Encode for AVPlayerAudiovisualBackgroundPlaybackPolicy {
1094    const ENCODING: Encoding = NSInteger::ENCODING;
1095}
1096
1097unsafe impl RefEncode for AVPlayerAudiovisualBackgroundPlaybackPolicy {
1098    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1099}
1100
1101/// AVPlayerBackgroundSupport.
1102impl AVPlayer {
1103    extern_methods!(
1104        /// Controls the policy to be used in deciding how playback of audiovisual content should continue while the application transitions to background.
1105        ///
1106        /// By default, the system is free to decide the background playback policy (AVPlayerAudiovisualBackgroundPlaybackPolicyAutomatic).
1107        /// If set to AVPlayerAudiovisualBackgroundPlaybackPolicyPauses, player will be paused on entering background.
1108        /// If set to AVPlayerAudiovisualBackgroundPlaybackPolicyContinuesIfPossible, the system makes the best effort to continue playback but the app also needs appropriate UIBackgroundModes for the system to let it continue running in the background. Note that this policy only applies to items with enabled video.
1109        #[unsafe(method(audiovisualBackgroundPlaybackPolicy))]
1110        #[unsafe(method_family = none)]
1111        pub unsafe fn audiovisualBackgroundPlaybackPolicy(
1112            &self,
1113        ) -> AVPlayerAudiovisualBackgroundPlaybackPolicy;
1114
1115        /// Setter for [`audiovisualBackgroundPlaybackPolicy`][Self::audiovisualBackgroundPlaybackPolicy].
1116        #[unsafe(method(setAudiovisualBackgroundPlaybackPolicy:))]
1117        #[unsafe(method_family = none)]
1118        pub unsafe fn setAudiovisualBackgroundPlaybackPolicy(
1119            &self,
1120            audiovisual_background_playback_policy: AVPlayerAudiovisualBackgroundPlaybackPolicy,
1121        );
1122    );
1123}
1124
1125/// PlaybackCoordination.
1126impl AVPlayer {
1127    extern_methods!(
1128        #[cfg(feature = "AVPlaybackCoordinator")]
1129        /// The playback coordinator for this player.
1130        ///
1131        /// If the playback coordinator is connected to other participants, rate changes and seeks on the current item will be automatically mirrored to all connected participants.
1132        /// Depending on policies, the coordinator may also intercept rate changes to non-zero to coordinate playback start with the rest of the group.
1133        /// Use [AVPlayer playImmediatelyAtRate:] to override the coordinated startup behavior and start playback immediately. This is useful to give users an opportunity to override waiting caused by other participants' suspensions.
1134        /// Player configuration other than rate and seeks are not communicated to other participants and can be configured independently by each participant.
1135        /// A player with a connected playbackCoordinator will change behavior in situations that require the player to pause for internal reasons, such as a route change or a stall.
1136        /// When resuming after these events, the player will not resume at the stop time. Instead, it will attempt to rejoin the group, potentially seeking to match the other participant's progress.
1137        /// It is left to the owner of the AVPlayer to ensure that all participants are playing the same item. See the discussion of AVPlaybackCoordinator for considerations about item transitions.
1138        #[unsafe(method(playbackCoordinator))]
1139        #[unsafe(method_family = none)]
1140        pub unsafe fn playbackCoordinator(&self) -> Retained<AVPlayerPlaybackCoordinator>;
1141    );
1142}
1143
1144/// AVPlayerOutputSupport.
1145impl AVPlayer {
1146    extern_methods!(
1147        #[cfg(feature = "AVPlayerOutput")]
1148        /// The video output for this player, if one was set.
1149        ///
1150        /// When an AVPlayerVideoOutput is associated with an AVPlayer, the AVPlayerVideoOutput can then be used to receive video-related samples during playback.
1151        ///
1152        /// - NOTE: If an output is set while AVPlayer has a current item it may cause different data channels to be selected for that item, which can have a performance impact.
1153        /// As a result, when possible, it is best to set an output before setting items on an AVPlayer.
1154        #[unsafe(method(videoOutput))]
1155        #[unsafe(method_family = none)]
1156        pub unsafe fn videoOutput(&self) -> Option<Retained<AVPlayerVideoOutput>>;
1157
1158        #[cfg(feature = "AVPlayerOutput")]
1159        /// Setter for [`videoOutput`][Self::videoOutput].
1160        #[unsafe(method(setVideoOutput:))]
1161        #[unsafe(method_family = none)]
1162        pub unsafe fn setVideoOutput(&self, video_output: Option<&AVPlayerVideoOutput>);
1163    );
1164}
1165
1166/// This defines the network resource priority for a player.
1167///
1168/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayernetworkresourcepriority?language=objc)
1169// NS_ENUM
1170#[repr(transparent)]
1171#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1172pub struct AVPlayerNetworkResourcePriority(pub NSInteger);
1173impl AVPlayerNetworkResourcePriority {
1174    /// The default priority level given to a player for loading network resources. Use this when the player requires an optimal level of network resources and streaming in high-quality resolution is ideal. Players with AVPlayerNetworkResourcePriorityHigh will take precedence over this player. This player will take precedence over players with AVPlayerNetworkResourcePriorityLow.
1175    #[doc(alias = "AVPlayerNetworkResourcePriorityDefault")]
1176    pub const Default: Self = Self(0);
1177    /// Indicates a low priority level for loading network resources. Use this when the player requires minimal network bandwidth and streaming in high-quality resolution is not crucial. Other players with higher priority will take precedence over this player.
1178    #[doc(alias = "AVPlayerNetworkResourcePriorityLow")]
1179    pub const Low: Self = Self(1);
1180    /// Indicates a high priority level for loading network resources. Use this when the player requires a high level of network resources and streaming in high-quality resolution is crucial. This player will take precedence over other lower priority players.
1181    #[doc(alias = "AVPlayerNetworkResourcePriorityHigh")]
1182    pub const High: Self = Self(2);
1183}
1184
1185unsafe impl Encode for AVPlayerNetworkResourcePriority {
1186    const ENCODING: Encoding = NSInteger::ENCODING;
1187}
1188
1189unsafe impl RefEncode for AVPlayerNetworkResourcePriority {
1190    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1191}
1192
1193/// AVPlayerResourceArbitrationSupport.
1194impl AVPlayer {
1195    extern_methods!(
1196        /// Indicates the priority of this player for network bandwidth resource distribution.
1197        ///
1198        /// This value determines the priority of the player during network resource allocation among all other players within the same application process. The default value for this is AVPlayerNetworkResourcePriorityDefault.
1199        #[unsafe(method(networkResourcePriority))]
1200        #[unsafe(method_family = none)]
1201        pub unsafe fn networkResourcePriority(&self) -> AVPlayerNetworkResourcePriority;
1202
1203        /// Setter for [`networkResourcePriority`][Self::networkResourcePriority].
1204        #[unsafe(method(setNetworkResourcePriority:))]
1205        #[unsafe(method_family = none)]
1206        pub unsafe fn setNetworkResourcePriority(
1207            &self,
1208            network_resource_priority: AVPlayerNetworkResourcePriority,
1209        );
1210    );
1211}
1212
1213/// AVPlayerSpatialAudioExperience.
1214impl AVPlayer {
1215    extern_methods!();
1216}
1217
1218/// AVPlayerRoutingPlaybackArbitrationSupport.
1219impl AVPlayer {
1220    extern_methods!(
1221        /// Whether the player's audio output is suppressed due to being on a non-mixable audio route.
1222        ///
1223        /// If YES, the player's audio output is suppressed. The player is muted while on a non-mixable audio route and cannot play audio. The player's mute property does not reflect the true mute status.
1224        /// If NO, the player's audio output is not suppressed. The player may be muted or unmuted while on a non-mixable audio route and can play audio. The player's mute property reflects the true mute status.
1225        /// In a non-mixable audio route, only one player can play audio. To play audio in non-mixable states, the player must be specified as the priority participant in AVRoutingPlaybackArbiter.preferredParticipantForNonMixableAudioRoutes. If this player becomes the preferred player, it will gain audio priority and suppress the audio of all other players. If another participant becomes the preferred participant, this player will lose audio priority and have their audio suppressed. This property is key-value observed.
1226        #[unsafe(method(audioOutputSuppressedDueToNonMixableAudioRoute))]
1227        #[unsafe(method_family = none)]
1228        pub unsafe fn audioOutputSuppressedDueToNonMixableAudioRoute(&self) -> bool;
1229    );
1230}
1231
1232/// AVPlayerObservation.
1233impl AVPlayer {
1234    extern_methods!(
1235        /// AVPlayer and other AVFoundation types can optionally be observed using Swift Observation.
1236        ///
1237        /// When set to YES, new instances of AVPlayer, AVQueuePlayer, AVPlayerItem, and AVPlayerItemTrack are observable with Swift Observation. The default value is NO (not observable).  An exception is thrown if this property is set YES after initializing any objects of these types, or if it is set to NO after any observable objects are initialized.  In other words, all objects of these types must either be observable or not observable in an application instance.
1238        ///
1239        /// For more information regarding management of class objects in SwiftUI, please refer to https://developer.apple.com/documentation/swiftui/state.
1240        #[unsafe(method(isObservationEnabled))]
1241        #[unsafe(method_family = none)]
1242        pub unsafe fn isObservationEnabled(mtm: MainThreadMarker) -> bool;
1243
1244        /// Setter for [`isObservationEnabled`][Self::isObservationEnabled].
1245        #[unsafe(method(setObservationEnabled:))]
1246        #[unsafe(method_family = none)]
1247        pub unsafe fn setObservationEnabled(observation_enabled: bool, mtm: MainThreadMarker);
1248    );
1249}
1250
1251/// AVPlayerDeprecated.
1252impl AVPlayer {
1253    extern_methods!(
1254        /// Indicates whether display of closed captions is enabled.
1255        ///
1256        /// This property is deprecated.
1257        ///
1258        /// When the value of appliesMediaSelectionCriteriaAutomatically is YES, the receiver will enable closed captions automatically either according to user preferences or, if you provide them, according to AVPlayerMediaSelectionCriteria for the media characteristic AVMediaCharacteristicLegible.
1259        ///
1260        /// If you want to determine whether closed captions may be available for a given AVPlayerItem, you can examine the AVMediaSelectionOptions in the AVMediaSelectionGroup for the characteristic AVMediaCharacteristicLegible, as vended by -[AVAsset mediaSelectionGroupForMediaCharacteristic:]. See AVMediaCharacteristicTranscribesSpokenDialogForAccessibility and AVMediaCharacteristicDescribesMusicAndSoundForAccessibility as documented in AVMediaFormat.h for information about how to identify legible media selection options that offer the features of closed captions for accessibility purposes.
1261        ///
1262        /// You can select or deselect a specific AVMediaSelectionOption via -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:].
1263        ///
1264        /// For further information about Media Accessibility preferences, see MediaAccessibility framework documentation.
1265        #[deprecated = "Allow AVPlayer to enable closed captions automatically according to user preferences by ensuring that the value of appliesMediaSelectionCriteriaAutomatically is YES."]
1266        #[unsafe(method(isClosedCaptionDisplayEnabled))]
1267        #[unsafe(method_family = none)]
1268        pub unsafe fn isClosedCaptionDisplayEnabled(&self) -> bool;
1269
1270        /// Setter for [`isClosedCaptionDisplayEnabled`][Self::isClosedCaptionDisplayEnabled].
1271        #[deprecated = "Allow AVPlayer to enable closed captions automatically according to user preferences by ensuring that the value of appliesMediaSelectionCriteriaAutomatically is YES."]
1272        #[unsafe(method(setClosedCaptionDisplayEnabled:))]
1273        #[unsafe(method_family = none)]
1274        pub unsafe fn setClosedCaptionDisplayEnabled(&self, closed_caption_display_enabled: bool);
1275
1276        #[cfg(feature = "objc2-core-media")]
1277        /// Use sourceClock instead.
1278        #[deprecated]
1279        #[unsafe(method(masterClock))]
1280        #[unsafe(method_family = none)]
1281        pub unsafe fn masterClock(&self) -> Option<Retained<CMClock>>;
1282
1283        #[cfg(feature = "objc2-core-media")]
1284        /// Setter for [`masterClock`][Self::masterClock].
1285        #[deprecated]
1286        #[unsafe(method(setMasterClock:))]
1287        #[unsafe(method_family = none)]
1288        pub unsafe fn setMasterClock(&self, master_clock: Option<&CMClock>);
1289    );
1290}
1291
1292extern_class!(
1293    /// AVQueuePlayer is a subclass of AVPlayer that offers an interface for multiple-item playback.
1294    ///
1295    /// AVQueuePlayer extends AVPlayer with methods for managing a queue of items to be played in sequence.
1296    /// It plays these items as gaplessly as possible in the current runtime environment, depending on
1297    /// the timely availability of media data for the enqueued items.
1298    ///
1299    /// For best performance clients should typically enqueue only as many AVPlayerItems as are necessary
1300    /// to ensure smooth playback. Note that once an item is enqueued it becomes eligible to be loaded and
1301    /// made ready for playback, with whatever I/O and processing overhead that entails.
1302    ///
1303    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avqueueplayer?language=objc)
1304    #[unsafe(super(AVPlayer, NSObject))]
1305    #[derive(Debug, PartialEq, Eq, Hash)]
1306    pub struct AVQueuePlayer;
1307);
1308
1309extern_conformance!(
1310    unsafe impl NSObjectProtocol for AVQueuePlayer {}
1311);
1312
1313impl AVQueuePlayer {
1314    extern_methods!(
1315        #[cfg(feature = "AVPlayerItem")]
1316        /// Creates an instance of AVQueuePlayer and enqueues the AVPlayerItems from the specified array.
1317        ///
1318        /// - Parameter items: An NSArray of AVPlayerItems with which to populate the player's queue initially.
1319        ///
1320        /// - Returns: An instance of AVQueuePlayer.
1321        #[unsafe(method(queuePlayerWithItems:))]
1322        #[unsafe(method_family = none)]
1323        pub unsafe fn queuePlayerWithItems(
1324            items: &NSArray<AVPlayerItem>,
1325            mtm: MainThreadMarker,
1326        ) -> Retained<Self>;
1327
1328        #[cfg(feature = "AVPlayerItem")]
1329        /// Initializes an instance of AVQueuePlayer by enqueueing the AVPlayerItems from the specified array.
1330        ///
1331        /// This method throws an exception if items contains duplicated values or values associated with another AVPlayer.
1332        ///
1333        /// - Parameter items: An NSArray of AVPlayerItems with which to populate the player's queue initially.
1334        ///
1335        /// - Returns: An instance of AVQueuePlayer.
1336        #[unsafe(method(initWithItems:))]
1337        #[unsafe(method_family = init)]
1338        pub unsafe fn initWithItems(
1339            this: Allocated<Self>,
1340            items: &NSArray<AVPlayerItem>,
1341        ) -> Retained<Self>;
1342
1343        #[cfg(feature = "AVPlayerItem")]
1344        /// Provides an array of the currently enqueued items.
1345        ///
1346        /// - Returns: An NSArray containing the enqueued AVPlayerItems.
1347        #[unsafe(method(items))]
1348        #[unsafe(method_family = none)]
1349        pub unsafe fn items(&self) -> Retained<NSArray<AVPlayerItem>>;
1350
1351        /// Ends playback of the current item and initiates playback of the next item in the player's queue.
1352        ///
1353        /// Removes the current item from the play queue.
1354        #[unsafe(method(advanceToNextItem))]
1355        #[unsafe(method_family = none)]
1356        pub unsafe fn advanceToNextItem(&self);
1357
1358        #[cfg(feature = "AVPlayerItem")]
1359        /// Tests whether an AVPlayerItem can be inserted into the player's queue.
1360        ///
1361        /// Note that adding the same AVPlayerItem to an AVQueuePlayer at more than one position in the queue is not supported.
1362        ///
1363        /// - Parameter item: The AVPlayerItem to be tested.
1364        /// - Parameter afterItem: The item that the item to be tested is to follow in the queue. Pass nil to test whether the item can be appended to the queue.
1365        ///
1366        /// - Returns: An indication of whether the item can be inserted into the queue after the specified item.
1367        #[unsafe(method(canInsertItem:afterItem:))]
1368        #[unsafe(method_family = none)]
1369        pub unsafe fn canInsertItem_afterItem(
1370            &self,
1371            item: &AVPlayerItem,
1372            after_item: Option<&AVPlayerItem>,
1373        ) -> bool;
1374
1375        #[cfg(feature = "AVPlayerItem")]
1376        /// Places an AVPlayerItem after the specified item in the queue.
1377        ///
1378        /// This method throws an exception if item already exists in the queue.
1379        ///
1380        /// - Parameter item: The item to be inserted.
1381        /// - Parameter afterItem: The item that the newly inserted item should follow in the queue. Pass nil to append the item to the queue.
1382        #[unsafe(method(insertItem:afterItem:))]
1383        #[unsafe(method_family = none)]
1384        pub unsafe fn insertItem_afterItem(
1385            &self,
1386            item: &AVPlayerItem,
1387            after_item: Option<&AVPlayerItem>,
1388        );
1389
1390        #[cfg(feature = "AVPlayerItem")]
1391        /// Removes an AVPlayerItem from the queue.
1392        ///
1393        /// If the item to be removed is currently playing, has the same effect as -advanceToNextItem.
1394        ///
1395        /// - Parameter item: The item to be removed.
1396        #[unsafe(method(removeItem:))]
1397        #[unsafe(method_family = none)]
1398        pub unsafe fn removeItem(&self, item: &AVPlayerItem);
1399
1400        /// Removes all items from the queue.
1401        ///
1402        /// Stops playback by the target.
1403        #[unsafe(method(removeAllItems))]
1404        #[unsafe(method_family = none)]
1405        pub unsafe fn removeAllItems(&self);
1406    );
1407}
1408
1409/// Methods declared on superclass `AVPlayer`.
1410impl AVQueuePlayer {
1411    extern_methods!(
1412        /// Initializes an AVPlayer with no player items.
1413        #[unsafe(method(init))]
1414        #[unsafe(method_family = init)]
1415        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1416
1417        /// Returns an instance of AVPlayer that plays a single audiovisual resource referenced by URL.
1418        ///
1419        /// Implicitly creates an AVPlayerItem. Clients can obtain the AVPlayerItem as it becomes the player's currentItem.
1420        ///
1421        /// - Parameter URL:
1422        ///
1423        /// - Returns: An instance of AVPlayer
1424        #[unsafe(method(playerWithURL:))]
1425        #[unsafe(method_family = none)]
1426        pub unsafe fn playerWithURL(url: &NSURL, mtm: MainThreadMarker) -> Retained<Self>;
1427
1428        #[cfg(feature = "AVPlayerItem")]
1429        /// Create an AVPlayer that plays a single audiovisual item.
1430        ///
1431        /// Useful in order to play items for which an AVAsset has previously been created. See -[AVPlayerItem initWithAsset:].
1432        ///
1433        /// - Parameter item:
1434        ///
1435        /// - Returns: An instance of AVPlayer
1436        #[unsafe(method(playerWithPlayerItem:))]
1437        #[unsafe(method_family = none)]
1438        pub unsafe fn playerWithPlayerItem(
1439            item: Option<&AVPlayerItem>,
1440            mtm: MainThreadMarker,
1441        ) -> Retained<Self>;
1442
1443        /// Initializes an AVPlayer that plays a single audiovisual resource referenced by URL.
1444        ///
1445        /// Implicitly creates an AVPlayerItem. Clients can obtain the AVPlayerItem as it becomes the player's currentItem.
1446        ///
1447        /// - Parameter URL:
1448        ///
1449        /// - Returns: An instance of AVPlayer
1450        #[unsafe(method(initWithURL:))]
1451        #[unsafe(method_family = init)]
1452        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
1453
1454        #[cfg(feature = "AVPlayerItem")]
1455        /// Create an AVPlayer that plays a single audiovisual item.
1456        ///
1457        /// Useful in order to play items for which an AVAsset has previously been created. See -[AVPlayerItem initWithAsset:].
1458        /// This method throws an exception if the item is not an AVPlayerItem, or if the item is
1459        /// associated with another AVPlayer.
1460        ///
1461        /// - Parameter item:
1462        ///
1463        /// - Returns: An instance of AVPlayer
1464        #[unsafe(method(initWithPlayerItem:))]
1465        #[unsafe(method_family = init)]
1466        pub unsafe fn initWithPlayerItem(
1467            this: Allocated<Self>,
1468            item: Option<&AVPlayerItem>,
1469        ) -> Retained<Self>;
1470    );
1471}
1472
1473/// Methods declared on superclass `NSObject`.
1474impl AVQueuePlayer {
1475    extern_methods!(
1476        #[unsafe(method(new))]
1477        #[unsafe(method_family = new)]
1478        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
1479    );
1480}