objc2_av_foundation/generated/
AVPlayerLooper.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// These constants are returned by the AVPlayerLooper status property to indicate whether it can successfully accomplish looping playback.
13///
14/// Indicates that the status of the looper is not yet known.
15///
16/// Indicates that the looper is ready for looping playback.
17///
18/// Indicates that the looper is not able to perform looping playback because of an error. The error is described by the value of the error property.
19///
20/// Indicates that the looper is no longer looping because -disableLooping was invoked.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerlooperstatus?language=objc)
23// NS_ENUM
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct AVPlayerLooperStatus(pub NSInteger);
27impl AVPlayerLooperStatus {
28    #[doc(alias = "AVPlayerLooperStatusUnknown")]
29    pub const Unknown: Self = Self(0);
30    #[doc(alias = "AVPlayerLooperStatusReady")]
31    pub const Ready: Self = Self(1);
32    #[doc(alias = "AVPlayerLooperStatusFailed")]
33    pub const Failed: Self = Self(2);
34    #[doc(alias = "AVPlayerLooperStatusCancelled")]
35    pub const Cancelled: Self = Self(3);
36}
37
38unsafe impl Encode for AVPlayerLooperStatus {
39    const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for AVPlayerLooperStatus {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46/// These constants are the allowable values of Looper's existingItemsOrder initization parameter.
47///
48/// Indicates that the looper will insert the replica items before any existing items in the specified AVQueuePlayer's play queue. This is default behavior.
49///
50/// Indicates that the looper will insert the replica items after any existing items in the specified AVQueuePlayer's play queue.
51///
52/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerlooperitemordering?language=objc)
53// NS_ENUM
54#[repr(transparent)]
55#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct AVPlayerLooperItemOrdering(pub NSInteger);
57impl AVPlayerLooperItemOrdering {
58    #[doc(alias = "AVPlayerLooperItemOrderingLoopingItemsPrecedeExistingItems")]
59    pub const LoopingItemsPrecedeExistingItems: Self = Self(0);
60    #[doc(alias = "AVPlayerLooperItemOrderingLoopingItemsFollowExistingItems")]
61    pub const LoopingItemsFollowExistingItems: Self = Self(1);
62}
63
64unsafe impl Encode for AVPlayerLooperItemOrdering {
65    const ENCODING: Encoding = NSInteger::ENCODING;
66}
67
68unsafe impl RefEncode for AVPlayerLooperItemOrdering {
69    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
70}
71
72extern_class!(
73    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerlooper?language=objc)
74    #[unsafe(super(NSObject))]
75    #[derive(Debug, PartialEq, Eq, Hash)]
76    pub struct AVPlayerLooper;
77);
78
79unsafe impl Send for AVPlayerLooper {}
80
81unsafe impl Sync for AVPlayerLooper {}
82
83extern_conformance!(
84    unsafe impl NSObjectProtocol for AVPlayerLooper {}
85);
86
87impl AVPlayerLooper {
88    extern_methods!(
89        #[unsafe(method(init))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
92
93        #[unsafe(method(new))]
94        #[unsafe(method_family = new)]
95        pub unsafe fn new() -> Retained<Self>;
96
97        #[cfg(all(
98            feature = "AVPlayer",
99            feature = "AVPlayerItem",
100            feature = "objc2-core-media"
101        ))]
102        /// Returns an instance of AVPlayerLooper to loop specified AVPlayerItem within the specified time range with specified AVQueuePlayer.
103        ///
104        /// Parameter `player`: Must not be nil
105        ///
106        /// Parameter `itemToLoop`: Must not be nil
107        ///
108        /// Parameter `loopRange`: Playback time range in [0, itemToLoop's duration]. kCMTimeRangeInvalid means [0, itemToLoop's duration].
109        ///
110        /// Returns: An instance of AVPlayerLooper.
111        ///
112        /// The specified AVPlayerItem will be used as a template to generate at least 3 AVPlayerItem replicas and the replicas will be inserted into specified AVQueuePlayer's play queue to accomplish the looping playback. The specified AVPlayerItem should have its asset's duration property loaded beforehand so looping setup work would not be blocked until the duration value is known. Otherwise, AVPlayerLooper's status property is  AVPlayerLooperStatusUnknown until the duration property is loaded. The specified AVPlayerItem will not be used in the actual looping playback. Furthermore, AVPlayerItem replicas will be generated at initialization time so any changes made to the specified AVPlayerItem's property afterwards will not be reflected in the replicas used for looping playback. Specified CMTimeRange will limit each item loop iteration to playing within the specified time range. To play from beginning and the whole duration of the item, specify kCMTimeRangeInvalid for the range parameter. Time range will be accomplished by seeking to range start time and setting AVPlayerItem's forwardPlaybackEndTime property on the looping item replicas. Client should not modify AVQueuePlayer's play queue while AVPlayerLooper is performing the looping. AVPlayerLooper will insert the replica items before any existing items in the specified AVQueuePlayer's play queue and change the actionAtItemEnd to AVPlayerActionAtItemEndAdvance if required. AVQueuePlayer's play queue and actionAtItemEnd will be restored when -disableLooping method is called and then current looping item replicas completes playback or when AVPlayerLooper is destroyed. While AVPlayerLooper is being initialized, the specified AVQueuePlayer will be paused (rate of 0.0) if necessary and the original player rate will be restored after initialization completes. The client shall set the specified AVQueuePlayer's rate to 0 beforehand if additional set-up work needs to be performed after AVPlayerLooper initialization and before starting looping playback. An NSInvalidArgumentException will be raised if the player and template item are not specified or the template item has a 0 duration. An NSInvalidArgumentException will be raised if a valid time range has a duration of 0 or is not contained within time 0 and duration of the templateItem.
113        #[unsafe(method(playerLooperWithPlayer:templateItem:timeRange:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn playerLooperWithPlayer_templateItem_timeRange(
116            player: &AVQueuePlayer,
117            item_to_loop: &AVPlayerItem,
118            loop_range: CMTimeRange,
119        ) -> Retained<Self>;
120
121        #[cfg(all(feature = "AVPlayer", feature = "AVPlayerItem"))]
122        /// Returns an instance of AVPlayerLooper to loop specified AVPlayerItem with specified AVQueuePlayer.
123        ///
124        /// Parameter `player`: Must not be nil
125        ///
126        /// Parameter `itemToLoop`: Must not be nil
127        ///
128        /// Returns: An instance of AVPlayerLooper.
129        ///
130        /// Equivalent to +playerLooperWithPlayer:templateItem:timeRange: and passing in kCMTimeRangeInvalid for timeRange parameter.
131        #[unsafe(method(playerLooperWithPlayer:templateItem:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn playerLooperWithPlayer_templateItem(
134            player: &AVQueuePlayer,
135            item_to_loop: &AVPlayerItem,
136        ) -> Retained<Self>;
137
138        #[cfg(all(
139            feature = "AVPlayer",
140            feature = "AVPlayerItem",
141            feature = "objc2-core-media"
142        ))]
143        /// Initializes an instance of AVPlayerLooper to loop specified AVPlayerItem within specified time range with specified AVQueuePlayer.
144        ///
145        /// Parameter `player`: Must not be nil
146        ///
147        /// Parameter `itemToLoop`: Must not be nil
148        ///
149        /// Parameter `loopRange`: Playback time range in [0, itemToLoop's duration]. kCMTimeRangeInvalid means [0, itemToLoop's duration].
150        ///
151        /// Returns: An initialized AVPlayerLooper.
152        ///
153        /// Equivalent to -initWithPlayer:templateItem:timeRange:existingItemsOrdering: and passing AVPlayerLooperItemOrderingLoopingItemsPrecedeExistingItems as the beforeOrAfter parameter.
154        #[unsafe(method(initWithPlayer:templateItem:timeRange:))]
155        #[unsafe(method_family = init)]
156        pub unsafe fn initWithPlayer_templateItem_timeRange(
157            this: Allocated<Self>,
158            player: &AVQueuePlayer,
159            item_to_loop: &AVPlayerItem,
160            loop_range: CMTimeRange,
161        ) -> Retained<Self>;
162
163        #[cfg(all(
164            feature = "AVPlayer",
165            feature = "AVPlayerItem",
166            feature = "objc2-core-media"
167        ))]
168        /// Initializes an instance of AVPlayerLooper to loop specified AVPlayerItem within specified time range with specified AVQueuePlayer and adhering to specified ordering of existing items in the play queue.
169        ///
170        /// Parameter `player`: Must not be nil
171        ///
172        /// Parameter `itemToLoop`: Must not be nil
173        ///
174        /// Parameter `loopRange`: Playback time range in [0, itemToLoop's duration]. kCMTimeRangeInvalid means [0, itemToLoop's duration].
175        ///
176        /// Parameter `itemOrdering`: Specifes if replica items are to be inserted before or after existing items in the specified AVQueuePlayer.
177        ///
178        /// Returns: An initialized AVPlayerLooper.
179        ///
180        /// The specified AVPlayerItem will be used as a template to generate at least 3 AVPlayerItem replicas and the replicas will be inserted into specified AVQueuePlayer's play queue to accomplish the looping playback. The specified AVPlayerItem should have its asset's duration property loaded beforehand so looping setup work would not be blocked until the duration value is known. Otherwise, AVPlayerLooper's status property is  AVPlayerLooperStatusUnknown until the duration property is loaded. The specified AVPlayerItem will not be used in the actual looping playback. Furthermore, AVPlayerItem replicas will be generated at initialization time so any changes made to the specified AVPlayerItem's property afterwards will not be reflected in the replicas used for looping playback. Specified CMTimeRange will limit each item loop iteration to playing within the specified time range. To play from beginning and the whole duration of the item, specify kCMTimeRangeInvalid for the range parameter. Time range will be accomplished by seeking to range start time and setting AVPlayerItem's forwardPlaybackEndTime property on the looping item replicas. Client should not modify AVQueuePlayer's play queue while AVPlayerLooper is performing the looping. AVPlayerLooper will insert the replica items in the specified AVQueuePlayer's play queue before or after existing equeued items according to the specified AVPlayerLooperItemOrdering. The looper will change the actionAtItemEnd to AVPlayerActionAtItemEndAdvance if required. AVQueuePlayer's play queue and actionAtItemEnd will be restored when -disableLooping method is called and then current looping item replicas completes playback or when AVPlayerLooper is destroyed. While AVPlayerLooper is being initialized, the specified AVQueuePlayer will be paused (rate of 0.0) if necessary and the original player rate will be restored after initialization completes. The client shall set the specified AVQueuePlayer's rate to 0 beforehand if additional set-up work needs to be performed after AVPlayerLooper initialization and before starting looping playback. An NSInvalidArgumentException will be raised if the player and template item are not specified or the template item has a 0 duration. An NSInvalidArgumentException will be raised if a valid time range has a duration of 0 or is not contained within time 0 and duration of the templateItem.
181        #[unsafe(method(initWithPlayer:templateItem:timeRange:existingItemsOrdering:))]
182        #[unsafe(method_family = init)]
183        pub unsafe fn initWithPlayer_templateItem_timeRange_existingItemsOrdering(
184            this: Allocated<Self>,
185            player: &AVQueuePlayer,
186            item_to_loop: &AVPlayerItem,
187            loop_range: CMTimeRange,
188            item_ordering: AVPlayerLooperItemOrdering,
189        ) -> Retained<Self>;
190
191        /// The ability of the receiver to be used for looping playback.
192        ///
193        /// The value of this property is an AVPlayerLooperStatus that indicates whether the receiver is ready for looping playback. When the value of this property is AVPlayerStatusFailed, the receiver can no longer be used for playback and a new instance needs to be created in its place. When this happens, clients can check the value of the error property to determine the nature of the failure. This property is key value observable.
194        #[unsafe(method(status))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn status(&self) -> AVPlayerLooperStatus;
197
198        /// If the receiver's status is AVPlayerLooperStatusFailed, this describes the error that caused the failure.
199        ///
200        /// The value of this property is a NSError that describes what caused the receiver to not be able to perform looping playback. If the receiver's status is not AVPlayerLooperStatusFailed, the value of this property is nil.
201        #[unsafe(method(error))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
204
205        /// Disables the item looping
206        ///
207        /// AVPlayerLooper will stop performing player queue operations for looping and let the current looping item replica play to the end. The player's original actionAtItemEnd property will be restored afterwards. After this method is called, the value of the receiver's status property will be AVPlayerLooperStatusCancelled.
208        #[unsafe(method(disableLooping))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn disableLooping(&self);
211
212        /// Number of times the specified AVPlayerItem has been played
213        ///
214        /// Starts at 0 and increments when the player starts playback of the AVPlayerItem again. This property is key value observable.
215        #[unsafe(method(loopCount))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn loopCount(&self) -> NSInteger;
218
219        #[cfg(feature = "AVPlayerItem")]
220        /// Returns an array containing replicas of specified AVPlayerItem used to accomplish the looping
221        ///
222        /// AVPlayerLooper creates replicas of the template AVPlayerItem using -copyWithZone: and inserts the replicas in the specified AVQueuePlayer to accomplish the looping. The AVPlayerItem replicas are for informational purposes and to allow the client to apply properties that are not transferred from the template AVPlayerItem to the replicas. The client can determine the number of replicas created and can listen for notifications and property changes from the replicas if desired. AVPlayerItemOutputs and AVPlayerItemMediaDataCollectors are not transferred to the replicas so the client should add them to each replica if desired. The client shall not modify the properties on the replicas that would disrupt looping playback. Examples of such properties are playhead time/date, selected media option, and forward playback end time. This property is key value observable.
223        ///
224        /// Returns: Array containing replicas of specified AVPlayerItem
225        #[unsafe(method(loopingPlayerItems))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn loopingPlayerItems(
228            &self,
229            mtm: MainThreadMarker,
230        ) -> Retained<NSArray<AVPlayerItem>>;
231    );
232}