objc2_av_foundation/generated/AVPlayerInterstitialEventController.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 can be specified when creating AVPlayerInterstitialEvents in order to configure their behavior.
13///
14///
15/// Indicates that the user may freely employ playback controls, as available, both within the primary content and in the interstitial content specified for the event.
16///
17/// Indicates that seeking within the primary content from a date prior to the date of the event to a date subsequent to the date of the event is not permitted.
18///
19/// Indicates that advancing the currentTime within an interstitial item, either by seeking ahead or by setting the playback rate to a value greater than the item's asset's preferredRate, is not permitted.
20///
21/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventrestrictions?language=objc)
22// NS_OPTIONS
23#[repr(transparent)]
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct AVPlayerInterstitialEventRestrictions(pub NSUInteger);
26bitflags::bitflags! {
27 impl AVPlayerInterstitialEventRestrictions: NSUInteger {
28 #[doc(alias = "AVPlayerInterstitialEventRestrictionNone")]
29 const None = 0;
30 #[doc(alias = "AVPlayerInterstitialEventRestrictionConstrainsSeekingForwardInPrimaryContent")]
31 const ConstrainsSeekingForwardInPrimaryContent = 1<<0;
32 #[doc(alias = "AVPlayerInterstitialEventRestrictionRequiresPlaybackAtPreferredRateForAdvancement")]
33 const RequiresPlaybackAtPreferredRateForAdvancement = 1<<2;
34 #[doc(alias = "AVPlayerInterstitialEventRestrictionDefaultPolicy")]
35 const DefaultPolicy = AVPlayerInterstitialEventRestrictions::None.0;
36 }
37}
38
39unsafe impl Encode for AVPlayerInterstitialEventRestrictions {
40 const ENCODING: Encoding = NSUInteger::ENCODING;
41}
42
43unsafe impl RefEncode for AVPlayerInterstitialEventRestrictions {
44 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47/// A particular cue can be specified when creating AVPlayerInterstitialEvents to override the start time/date to a predefined position.
48///
49///
50/// No cue specified; event playback should start at event time (or date).
51///
52/// Event playback should occur before starting primary playback, regardless of initial primary playback position.
53///
54/// Event playback should occur after primary playback ends without error, either at the end of the primary asset or at the client-specified forward playback end time.
55///
56/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventcue?language=objc)
57// NS_TYPED_ENUM
58pub type AVPlayerInterstitialEventCue = NSString;
59
60extern "C" {
61 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventnocue?language=objc)
62 pub static AVPlayerInterstitialEventNoCue: &'static AVPlayerInterstitialEventCue;
63}
64
65extern "C" {
66 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventjoincue?language=objc)
67 pub static AVPlayerInterstitialEventJoinCue: &'static AVPlayerInterstitialEventCue;
68}
69
70extern "C" {
71 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventleavecue?language=objc)
72 pub static AVPlayerInterstitialEventLeaveCue: &'static AVPlayerInterstitialEventCue;
73}
74
75/// These constants specify how an event occupies time on AVPlayerItemIntegratedTimeline.
76///
77///
78/// Indicates this interstitial event occupies a single point on AVPlayerItemIntegratedTimeline.
79///
80/// Indicates this interstitial event fills AVPlayerItemIntegratedTimeline with the duration of this event.
81///
82/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventtimelineoccupancy?language=objc)
83// NS_ENUM
84#[repr(transparent)]
85#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
86pub struct AVPlayerInterstitialEventTimelineOccupancy(pub NSInteger);
87impl AVPlayerInterstitialEventTimelineOccupancy {
88 #[doc(alias = "AVPlayerInterstitialEventTimelineOccupancySinglePoint")]
89 pub const SinglePoint: Self = Self(0);
90 #[doc(alias = "AVPlayerInterstitialEventTimelineOccupancyFill")]
91 pub const Fill: Self = Self(1);
92}
93
94unsafe impl Encode for AVPlayerInterstitialEventTimelineOccupancy {
95 const ENCODING: Encoding = NSInteger::ENCODING;
96}
97
98unsafe impl RefEncode for AVPlayerInterstitialEventTimelineOccupancy {
99 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
100}
101
102/// These constants describe the status of the asset list response for an AVPlayerInterstitialEvent.
103///
104///
105/// Indicates that the asset list response is now available and non-nil, meaning the asset list read was successful.
106///
107/// Indicates that asset list response has been cleared and reverted to its original state of nil.
108///
109/// Indicates that the asset list response is unavailable, meaning the asset list read failed.
110///
111/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventassetlistresponsestatus?language=objc)
112// NS_ENUM
113#[repr(transparent)]
114#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
115pub struct AVPlayerInterstitialEventAssetListResponseStatus(pub NSInteger);
116impl AVPlayerInterstitialEventAssetListResponseStatus {
117 #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusAvailable")]
118 pub const Available: Self = Self(0);
119 #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusCleared")]
120 pub const Cleared: Self = Self(1);
121 #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusUnavailable")]
122 pub const Unavailable: Self = Self(2);
123}
124
125unsafe impl Encode for AVPlayerInterstitialEventAssetListResponseStatus {
126 const ENCODING: Encoding = NSInteger::ENCODING;
127}
128
129unsafe impl RefEncode for AVPlayerInterstitialEventAssetListResponseStatus {
130 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
131}
132
133extern_class!(
134 /// An AVPlayerInterstitialEvent provides instructions for temporarily suspending the playback of primary content in order to play alternative interstitial content instead, resuming playback of the primary content when playback of the interstitial content is complete or is canceled.
135 ///
136 ///
137 /// The primary content is specified as an instance of AVPlayerItem, designated as the primary item of the interstitial event.
138 ///
139 /// The timing of interstitial playback is specified as a date within the date range of the primary item. Interstitial events are currently possible only for items with an intrinsic mapping from their timeline to real-time dates.
140 ///
141 /// The alternative interstitial content is specified as an array of one or more AVPlayerItems that will be used as templates for the creation of items for interstitial playback. In other words, these template items are not the actual items that will be played during interstitial playback; instead they are used to generate the items that are to be played, with property values that match the configuration of your template items.
142 ///
143 /// If you wish to observe the scheduling and progress of interstitial events, use an AVPlayerInterstitialEventMonitor. If you wish to specify your own schedule of interstitial events, use an AVPlayerInterstitialEventController.
144 ///
145 /// Note that while previously AVPlayerInterstitialEvent was an immutable object, it is now mutable. This allows it to be created and customized before being set on an AVPlayerInterstitialEventController.
146 ///
147 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialevent?language=objc)
148 #[unsafe(super(NSObject))]
149 #[derive(Debug, PartialEq, Eq, Hash)]
150 pub struct AVPlayerInterstitialEvent;
151);
152
153unsafe impl NSCopying for AVPlayerInterstitialEvent {}
154
155unsafe impl CopyingHelper for AVPlayerInterstitialEvent {
156 type Result = Self;
157}
158
159unsafe impl NSObjectProtocol for AVPlayerInterstitialEvent {}
160
161impl AVPlayerInterstitialEvent {
162 extern_methods!(
163 #[unsafe(method(init))]
164 #[unsafe(method_family = init)]
165 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
166
167 #[unsafe(method(new))]
168 #[unsafe(method_family = new)]
169 pub unsafe fn new() -> Retained<Self>;
170
171 #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
172 /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
173 ///
174 /// Parameter `primaryItem`: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.
175 ///
176 /// Parameter `identifier`: An external identifier for the event.
177 ///
178 /// Parameter `time`: The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
179 ///
180 /// Parameter `templateItems`: An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content. An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.
181 ///
182 /// Parameter `restrictions`: Indicates restrictions on the use of end user playback controls that are imposed by the event.
183 ///
184 /// Parameter `resumptionOffset`: Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished. Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback.
185 ///
186 /// Parameter `playoutLimit`: Specifies the offset from the beginning of the interstitial at which interstitial playback should end, if the interstitial asset(s) are longer. Pass a positive numeric value, or kCMTimeInvalid to indicate no playout limit.
187 ///
188 /// Parameter `userDefinedAttributes`: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.
189 ///
190 /// Returns: An instance of AVPlayerInterstitialEvent.
191 #[deprecated = "Use interstitialEventWithPrimaryItem:time: instead"]
192 #[unsafe(method(interstitialEventWithPrimaryItem:identifier:time:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn interstitialEventWithPrimaryItem_identifier_time_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes(
195 primary_item: &AVPlayerItem,
196 identifier: Option<&NSString>,
197 time: CMTime,
198 template_items: &NSArray<AVPlayerItem>,
199 restrictions: AVPlayerInterstitialEventRestrictions,
200 resumption_offset: CMTime,
201 playout_limit: CMTime,
202 user_defined_attributes: Option<&NSDictionary>,
203 ) -> Retained<Self>;
204
205 #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
206 /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
207 ///
208 /// Parameter `primaryItem`: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.
209 ///
210 /// Parameter `identifier`: An external identifier for the event.
211 ///
212 /// Parameter `date`: The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
213 ///
214 /// Parameter `templateItems`: An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content. An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.
215 ///
216 /// Parameter `restrictions`: Indicates restrictions on the use of end user playback controls that are imposed by the event.
217 ///
218 /// Parameter `resumptionOffset`: Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished. Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback.
219 ///
220 /// Parameter `playoutLimit`: Specifies the offset from the beginning of the interstitial at which interstitial playback should end, if the interstitial asset(s) are longer. Pass a positive numeric value, or kCMTimeInvalid to indicate no playout limit.
221 ///
222 /// Parameter `userDefinedAttributes`: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.
223 ///
224 /// Returns: An instance of AVPlayerInterstitialEvent.
225 #[deprecated = "Use interstitialEventWithPrimaryItem:date: instead"]
226 #[unsafe(method(interstitialEventWithPrimaryItem:identifier:date:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn interstitialEventWithPrimaryItem_identifier_date_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes(
229 primary_item: &AVPlayerItem,
230 identifier: Option<&NSString>,
231 date: &NSDate,
232 template_items: &NSArray<AVPlayerItem>,
233 restrictions: AVPlayerInterstitialEventRestrictions,
234 resumption_offset: CMTime,
235 playout_limit: CMTime,
236 user_defined_attributes: Option<&NSDictionary>,
237 ) -> Retained<Self>;
238
239 #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
240 /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
241 ///
242 /// Parameter `primaryItem`: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.
243 ///
244 /// Parameter `time`: The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
245 ///
246 /// Returns: An instance of AVPlayerInterstitialEvent.
247 #[unsafe(method(interstitialEventWithPrimaryItem:time:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn interstitialEventWithPrimaryItem_time(
250 primary_item: &AVPlayerItem,
251 time: CMTime,
252 ) -> Retained<Self>;
253
254 #[cfg(feature = "AVPlayerItem")]
255 /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
256 ///
257 /// Parameter `primaryItem`: An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.
258 ///
259 /// Parameter `date`: The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
260 ///
261 /// Returns: An instance of AVPlayerInterstitialEvent.
262 #[unsafe(method(interstitialEventWithPrimaryItem:date:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn interstitialEventWithPrimaryItem_date(
265 primary_item: &AVPlayerItem,
266 date: &NSDate,
267 ) -> Retained<Self>;
268
269 #[cfg(feature = "AVPlayerItem")]
270 /// An AVPlayerItem representing the primary content during the playback of which the interstitial event should occur. The primaryItem must have an AVAsset that provides an intrinsic mapping from its timeline to real-time dates.
271 #[unsafe(method(primaryItem))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn primaryItem(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayerItem>>;
274
275 /// An external identifier for the event.
276 ///
277 /// If an event is set on an AVPlayerInterstitialEventController that already has an event with the same identifier, the old event will be replaced by the new one.
278 #[unsafe(method(identifier))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn identifier(&self) -> Retained<NSString>;
281
282 #[cfg(feature = "objc2-core-media")]
283 /// The time within the duration of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
284 ///
285 /// Will have a value equal to kCMTimeInvalid if the event was initialized with a date instead of a time.
286 #[unsafe(method(time))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn time(&self) -> CMTime;
289
290 /// The date within the date range of the primary item at which playback of the primary content should be temporarily suspended and the interstitial items played.
291 ///
292 /// Will have a value of nil if the event was initialized with a time instead of a date.
293 #[unsafe(method(date))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn date(&self) -> Option<Retained<NSDate>>;
296
297 #[cfg(feature = "AVPlayerItem")]
298 /// An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content.
299 ///
300 /// If you want the instances of AVURLAsset used during interstitial playback to be identical to the ones you specify for templateItems in AVPlayerInterstitialEvents that you set on an AVPlayerInterstitialEventController, rather than equivalent AVURLAssets with the same URL, you must create them with a value for the key AVURLAssetPrimarySessionIdentifierKey that's equal to the httpSessionIdentifier of the primary AVPlayerItem's asset. See AVAsset.h. This is especially useful if you require the use of a custom AVAssetResourceLoader delegate for interstitial assets.
301 ///
302 /// An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.
303 #[unsafe(method(templateItems))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn templateItems(
306 &self,
307 mtm: MainThreadMarker,
308 ) -> Retained<NSArray<AVPlayerItem>>;
309
310 /// Indicates restrictions on the use of end user playback controls that are imposed by the event.
311 #[unsafe(method(restrictions))]
312 #[unsafe(method_family = none)]
313 pub unsafe fn restrictions(&self) -> AVPlayerInterstitialEventRestrictions;
314
315 #[cfg(feature = "objc2-core-media")]
316 /// Specifies the offset in time at which playback of the primary item should resume after interstitial playback has finished.
317 ///
318 /// Definite numeric values are supported. The value kCMTimeIndefinite can also be used, in order to specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback; this value is typically suitable for live broadcasts. The default value is kCMTimeZero.
319 #[unsafe(method(resumptionOffset))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn resumptionOffset(&self) -> CMTime;
322
323 #[cfg(feature = "objc2-core-media")]
324 /// Specifies the offset in time at which playback of the interstitial event should end.
325 ///
326 /// Can be any positive numeric value, or invalid. The default value is kCMTimeInvalid, which means there is no limit.
327 #[unsafe(method(playoutLimit))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn playoutLimit(&self) -> CMTime;
330
331 /// Specifies that the start time of interstitial playback should be snapped to a segment boundary of the primary asset
332 ///
333 /// If true, the start time or date of the interstitial will be adjusted to the nearest segment boundary when the primary player is playing an HTTP Live Streaming asset.
334 #[unsafe(method(alignsStartWithPrimarySegmentBoundary))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn alignsStartWithPrimarySegmentBoundary(&self) -> bool;
337
338 /// Specifies that the resumption time of primary playback should be snapped to a segment boundary of the primary asset
339 ///
340 /// If true, the resumption time of primary playback following an interstitial will be adjusted to the nearest segment boundary when the primary player is playing an HTTP Live Streaming asset.
341 #[unsafe(method(alignsResumptionWithPrimarySegmentBoundary))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn alignsResumptionWithPrimarySegmentBoundary(&self) -> bool;
344
345 /// The cue property is used to schedule event playback at a predefined position of primary playback.
346 #[unsafe(method(cue))]
347 #[unsafe(method_family = none)]
348 pub unsafe fn cue(&self) -> Retained<AVPlayerInterstitialEventCue>;
349
350 /// Specifies that the interstitial should be scheduled for playback once only, and suppressed for subsequent replay.
351 ///
352 /// The "once" provision takes effect at the start of interstitial playback. The interstitial will not be scheduled again even if the first playback is canceled before completion.
353 #[unsafe(method(willPlayOnce))]
354 #[unsafe(method_family = none)]
355 pub unsafe fn willPlayOnce(&self) -> bool;
356
357 /// Attributes of the event defined by the content vendor or the client.
358 ///
359 /// Dictionary keys are attribute names. Dictionary values are attribute values.
360 #[unsafe(method(userDefinedAttributes))]
361 #[unsafe(method_family = none)]
362 pub unsafe fn userDefinedAttributes(&self) -> Retained<NSDictionary>;
363
364 /// The asset list JSON response as a dictionary, or nil if no asset list response has been loaded for the event.
365 ///
366 /// If the AVPlayerInterstitialEvent's templateItems is empty and the assetListResponse is nil, then an asset list read is expected. If the AVPlayerInterstitialEvent's templateItems is not empty and the assetListResponse is nil, then an asset list read is not expected.
367 #[unsafe(method(assetListResponse))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn assetListResponse(&self) -> Option<Retained<NSDictionary>>;
370
371 /// Indicates this event's occupancy on AVPlayerItemIntegratedTimeline. The default value is AVPlayerInterstitialEventTimelineSinglePointOccupancy.
372 #[unsafe(method(timelineOccupancy))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn timelineOccupancy(&self) -> AVPlayerInterstitialEventTimelineOccupancy;
375
376 /// Indicates this event will supplement the primary content and should be presented unified with the primary item. The default value is NO.
377 #[unsafe(method(supplementsPrimaryContent))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn supplementsPrimaryContent(&self) -> bool;
380
381 /// Indicates this event's content is dynamic and server may respond with different interstitial assets for other particpants in coordinated playback.
382 ///
383 /// Indicates this event's content is dynamic and server may respond with different interstitial assets for other particpants in coordinated playback. If this value is set to NO and the primary asset is particpating in coordinated playback, this event will participate in coordinated playback as well. The default value is YES.
384 #[unsafe(method(contentMayVary))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn contentMayVary(&self) -> bool;
387 );
388}
389
390extern_class!(
391 /// An AVPlayerInterstitialEventMonitor allows you to observe the scheduling and progress of interstitial events, specified either intrinsically within the content of primary items, such as via use of directives carried by HLS media playlists, or via use of an AVPlayerInterstitialEventController.
392 ///
393 ///
394 /// The schedule of interstitial events is provided as an array of AVPlayerInterstitialEvents. For each AVPlayerInterstitialEvent, when the primary player's current item is the primary item of the interstitial event and its currentDate reaches the date of the event, playback of the primary item by the primary player is temporarily suspended, i.e. its timeControlStatus changes to AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate and its reasonForWaitingToPlay will change to AVPlayerWaitingDuringInterstitialEventReason. During this suspension, playback of items that replicate the interstitial template items of the event are played by the interstitial player, which temporarily assumes the output configuration of the primary player; for example, its visual content will be routed to AVPlayerLayers that reference the primary player. Once the interstitial player has advanced through playback of the interstitial items specified by the event or its current item otherwise becomes nil, playback of the primary content will resume, at an offset from the time at which it was suspended as specified by the event.
395 ///
396 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
397 ///
398 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitor?language=objc)
399 #[unsafe(super(NSObject))]
400 #[derive(Debug, PartialEq, Eq, Hash)]
401 pub struct AVPlayerInterstitialEventMonitor;
402);
403
404unsafe impl Send for AVPlayerInterstitialEventMonitor {}
405
406unsafe impl Sync for AVPlayerInterstitialEventMonitor {}
407
408unsafe impl NSObjectProtocol for AVPlayerInterstitialEventMonitor {}
409
410impl AVPlayerInterstitialEventMonitor {
411 extern_methods!(
412 #[cfg(feature = "AVPlayer")]
413 /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
414 ///
415 /// Parameter `primaryPlayer`: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
416 ///
417 /// Returns: An instance of AVPlayerInterstitialEventMonitor.
418 #[unsafe(method(interstitialEventMonitorWithPrimaryPlayer:))]
419 #[unsafe(method_family = none)]
420 pub unsafe fn interstitialEventMonitorWithPrimaryPlayer(
421 primary_player: &AVPlayer,
422 ) -> Retained<Self>;
423
424 #[cfg(feature = "AVPlayer")]
425 #[unsafe(method(initWithPrimaryPlayer:))]
426 #[unsafe(method_family = init)]
427 pub unsafe fn initWithPrimaryPlayer(
428 this: Allocated<Self>,
429 primary_player: &AVPlayer,
430 ) -> Retained<Self>;
431
432 #[cfg(feature = "AVPlayer")]
433 /// The AVPlayer that will play the primaryItems of the receiver's interstitial events.
434 #[unsafe(method(primaryPlayer))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn primaryPlayer(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayer>>;
437
438 #[cfg(feature = "AVPlayer")]
439 /// The AVQueuePlayer that will play interstitial items during suspension of playback of primary items.
440 #[unsafe(method(interstitialPlayer))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn interstitialPlayer(&self, mtm: MainThreadMarker) -> Retained<AVQueuePlayer>;
443
444 /// Provides the current schedule of interstitial events, specified either intrinsically within the content of primary items, such as via use of directives carried by HLS media playlists, or via use of an AVPlayerInterstitialEventController.
445 ///
446 /// When interstitial events follow a schedule specified intrinsically within the content of primary items, the value of this property will typically change whenever the currentItem of the primaryPlayer changes. For HLS content that specifies interstitials via the use of DATERANGE tags, the value of this property may also change whenever the set of DATERANGE tags in the currentItem's media playlist changes.
447 /// When interstitial events follow a schedule specified via use of an AVPlayerInterstitialEventController, the value of this property changes only when a new schedule is set on the AVPlayerInterstitialEventController.
448 /// The events returned in this array are immutable. Attempting to mutate them will trigger an exception. To alter an event, make a copy and mutate the copy.
449 #[unsafe(method(events))]
450 #[unsafe(method_family = none)]
451 pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerInterstitialEvent>>;
452
453 /// The current interstitial event. Has a value of nil during playback of primary content by the primary player.
454 #[unsafe(method(currentEvent))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn currentEvent(&self) -> Option<Retained<AVPlayerInterstitialEvent>>;
457 );
458}
459
460/// Methods declared on superclass `NSObject`.
461impl AVPlayerInterstitialEventMonitor {
462 extern_methods!(
463 #[unsafe(method(init))]
464 #[unsafe(method_family = init)]
465 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
466
467 #[unsafe(method(new))]
468 #[unsafe(method_family = new)]
469 pub unsafe fn new() -> Retained<Self>;
470 );
471}
472
473extern "C" {
474 /// A notification that's posted whenever the value of events of an AVPlayerInterstitialEventMonitor is changed.
475 ///
476 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitoreventsdidchangenotification?language=objc)
477 pub static AVPlayerInterstitialEventMonitorEventsDidChangeNotification:
478 &'static NSNotificationName;
479}
480
481extern "C" {
482 /// A notification that's posted whenever the currentEvent of an AVPlayerInterstitialEventMonitor changes.
483 ///
484 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventdidchangenotification?language=objc)
485 pub static AVPlayerInterstitialEventMonitorCurrentEventDidChangeNotification:
486 &'static NSNotificationName;
487}
488
489extern "C" {
490 /// A notification that is posted whenever an AVPlayerInterstitialEvent's asset list response status changes.
491 ///
492 /// Carries a userInfo dictionary that can contain the following keys and values:
493 /// 1. AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeEventKey, with a value that indicates the AVPlayerInterstitialEvent for which the asset response status has changed.
494 /// 2. AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeStatusKey, with a value of type AVPlayerInterstitialEventAssetListResponseStatus, indicating the changed asset response status.
495 /// 3. AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeErrorKey, with a value of type NSError that carries additional information about the failure to read the asset list. This key is only present when the new AVPlayerInterstitialEventAssetListResponseStatus is AVPlayerInterstitialEventAssetListResponseStatusUnavailable.
496 ///
497 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangenotification?language=objc)
498 pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification:
499 &'static NSNotificationName;
500}
501
502extern "C" {
503 /// The dictionary key for the AVPlayerInterstitial event that had its asset list response status changed in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
504 ///
505 /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
506 ///
507 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangeeventkey?language=objc)
508 pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeEventKey:
509 &'static NSString;
510}
511
512extern "C" {
513 /// The dictionary key for the asset list response status in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
514 ///
515 /// The value corresponding to this key is of type AVPlayerInterstitialEventAssetListResponseStatus.
516 ///
517 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangestatuskey?language=objc)
518 pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeStatusKey:
519 &'static NSString;
520}
521
522extern "C" {
523 /// The dictionary key for the NSError in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
524 ///
525 /// The value corresponding to this key is of type NSError. This key only exists in the payload of AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification if AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeStatusKey in the same payload points to a value of AVPlayerInterstitialEventAssetListResponseStatusUnavailable.
526 ///
527 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangeerrorkey?language=objc)
528 pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeErrorKey:
529 &'static NSString;
530}
531
532extern_class!(
533 /// An AVPlayerInterstitialEventController allows you to specify a schedule of interstitial events for items played by a primary player.
534 /// By creating an instance of AVPlayerInterstitialEventController and setting a schedule of interstitial events, you pre-empt directives the are intrinsic to the items played by the primary player, if any exist, causing them to be ignored.
535 ///
536 ///
537 /// The schedule of interstitial events is specified as an array of AVPlayerInterstitialEvents. For each AVPlayerInterstitialEvent, when the primary player's current item is the primary item of the interstitial event and its currentDate reaches the date of the event, playback of the primary item by the primary player is temporarily suspended, i.e. its timeControlStatus changes to AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate and its reasonForWaitingToPlay will change to AVPlayerWaitingDuringInterstitialEventReason. During this suspension, playback of items that replicate the interstitial template items of the event are played by the interstitial player, which temporarily assumes the output configuration of the primary player; for example, its visual content will be routed to AVPlayerLayers that reference the primary player. Once the interstitial player has advanced through playback of the interstitial items specified by the event or its current item otherwise becomes nil, playback of the primary content will resume, at an offset from the time at which it was suspended as specified by the event.
538 ///
539 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
540 ///
541 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventcontroller?language=objc)
542 #[unsafe(super(AVPlayerInterstitialEventMonitor, NSObject))]
543 #[derive(Debug, PartialEq, Eq, Hash)]
544 pub struct AVPlayerInterstitialEventController;
545);
546
547unsafe impl NSObjectProtocol for AVPlayerInterstitialEventController {}
548
549impl AVPlayerInterstitialEventController {
550 extern_methods!(
551 #[cfg(feature = "AVPlayer")]
552 /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
553 ///
554 /// Parameter `primaryPlayer`: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
555 ///
556 /// Returns: An instance of AVPlayerInterstitialEventController.
557 ///
558 /// This method throws an exception if the primary player is an interstitial player.
559 #[unsafe(method(interstitialEventControllerWithPrimaryPlayer:))]
560 #[unsafe(method_family = none)]
561 pub unsafe fn interstitialEventControllerWithPrimaryPlayer(
562 primary_player: &AVPlayer,
563 ) -> Retained<Self>;
564
565 #[cfg(feature = "AVPlayer")]
566 /// This method throws an exception if the primary player is an interstitial player.
567 #[unsafe(method(initWithPrimaryPlayer:))]
568 #[unsafe(method_family = init)]
569 pub unsafe fn initWithPrimaryPlayer(
570 this: Allocated<Self>,
571 primary_player: &AVPlayer,
572 ) -> Retained<Self>;
573
574 /// Specifies the current schedule of interstitial events.
575 ///
576 /// Setting this property to a non-nil value cancels and overrides all previously scheduled future interstitial events, including those that are intrinsically specified by the content of primary items, such as directives carried by HLS media playlists. Setting it to nil causes its value to be reset in accordance with the content of the current primary item.
577 ///
578 /// If you change the value of events during an interstitial event and the current event is not included in the new value of events, the current event is nevertheless allowed to continue until completion. If you wish to cancel the current event, use -cancelCurrentEventWithResumptionOffset:.
579 ///
580 /// If interstitial events are scheduled with dates that coincide either with the date of another scheduled interstitial event or with the date range of the primary content that's omitted according to the resumption offset of another scheduled interstitial event, the primary content will remain suspended until all coinciding interstitial events have been completed. The effective resumption offset will be the sum of the resumption offsets of the coinciding interstitial events. (Note that the sum of a numeric CMTime and kCMTimeIndefinite is kCMTimeIndefinite.)
581 ///
582 /// If interstitial events are scheduled for the same date, they are ordered according to their position in the events array.
583 ///
584 /// The receiver will make a copy of the events that are set on it. Subsequent mutations on the original events will have no effect on the copy.
585 ///
586 /// An NSInvalidArgumentException will be raised if an under-specified AVPlayerInterstitialEvent is set, such as one with a nil primaryItem, or with neither a time nor a date.
587 #[unsafe(method(events))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerInterstitialEvent>>;
590
591 /// Setter for [`events`][Self::events].
592 #[unsafe(method(setEvents:))]
593 #[unsafe(method_family = none)]
594 pub unsafe fn setEvents(&self, events: Option<&NSArray<AVPlayerInterstitialEvent>>);
595
596 #[cfg(feature = "objc2-core-media")]
597 /// Causes the playback of any and all interstitial content currently in progress to be abandoned and the playback of primary content to be resumed.
598 ///
599 /// Parameter `resumptionOffset`: Specifies the offset in time at which playback of the primary player's current item should resume after interstitial playback has finished. To specify that the effective resumption time offset should accord with the wallclock time elapsed during interstitial playback, pass a value of kCMTimeIndefinite.
600 ///
601 /// If invoked during the handling of coinciding interstitial events, they will all be canceled.
602 /// When you cancel interstitial events via the use of this method, the value of resumptionOffset that you pass overrides the events' resumptionOffset.
603 /// Has no effect while currentEvent is nil.
604 #[unsafe(method(cancelCurrentEventWithResumptionOffset:))]
605 #[unsafe(method_family = none)]
606 pub unsafe fn cancelCurrentEventWithResumptionOffset(&self, resumption_offset: CMTime);
607 );
608}
609
610/// Methods declared on superclass `AVPlayerInterstitialEventMonitor`.
611impl AVPlayerInterstitialEventController {
612 extern_methods!(
613 #[cfg(feature = "AVPlayer")]
614 /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
615 ///
616 /// Parameter `primaryPlayer`: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
617 ///
618 /// Returns: An instance of AVPlayerInterstitialEventMonitor.
619 #[unsafe(method(interstitialEventMonitorWithPrimaryPlayer:))]
620 #[unsafe(method_family = none)]
621 pub unsafe fn interstitialEventMonitorWithPrimaryPlayer(
622 primary_player: &AVPlayer,
623 ) -> Retained<Self>;
624 );
625}
626
627/// Methods declared on superclass `NSObject`.
628impl AVPlayerInterstitialEventController {
629 extern_methods!(
630 #[unsafe(method(init))]
631 #[unsafe(method_family = init)]
632 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
633
634 #[unsafe(method(new))]
635 #[unsafe(method_family = new)]
636 pub unsafe fn new() -> Retained<Self>;
637 );
638}
639
640extern "C" {
641 /// Indicates that the player is waiting for the completion of an interstitial event.
642 ///
643 /// The player is waiting for playback because an interstitial event is currently in progress. Interstitial events can be monitored via use of an AVPlayerInterstitialEventMonitor.
644 ///
645 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingduringinterstitialeventreason?language=objc)
646 #[cfg(feature = "AVPlayer")]
647 pub static AVPlayerWaitingDuringInterstitialEventReason: &'static AVPlayerWaitingReason;
648}
649
650/// AVPlayerInterstitialSupport.
651#[cfg(feature = "AVPlayer")]
652impl AVPlayer {
653 extern_methods!();
654}
655
656/// AVPlayerInterstitialSupport.
657#[cfg(feature = "AVPlayerItem")]
658impl AVPlayerItem {
659 extern_methods!(
660 /// Allows interstitials to be played according to a schedule that's specified by server-side directives. The default value is YES. A value of NO prevents automatic scheduling of future server-side interstitial events. Events specified by an AVPlayerInterstitialEventController override server-side events, regardless of the value of this property.
661 ///
662 /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
663 #[unsafe(method(automaticallyHandlesInterstitialEvents))]
664 #[unsafe(method_family = none)]
665 pub unsafe fn automaticallyHandlesInterstitialEvents(&self) -> bool;
666
667 /// Setter for [`automaticallyHandlesInterstitialEvents`][Self::automaticallyHandlesInterstitialEvents].
668 #[unsafe(method(setAutomaticallyHandlesInterstitialEvents:))]
669 #[unsafe(method_family = none)]
670 pub unsafe fn setAutomaticallyHandlesInterstitialEvents(
671 &self,
672 automatically_handles_interstitial_events: bool,
673 );
674
675 /// If the item was created automatically according to a template item for looping, for interstitial playback, or for other purposes, indicates the AVPlayerItem that was used as the template.
676 #[unsafe(method(templatePlayerItem))]
677 #[unsafe(method_family = none)]
678 pub unsafe fn templatePlayerItem(&self) -> Option<Retained<AVPlayerItem>>;
679 );
680}