objc2-av-foundation 0.3.2

Bindings to the AVFoundation framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

/// These constants can be specified when creating AVPlayerInterstitialEvents in order to configure their behavior.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventrestrictions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerInterstitialEventRestrictions(pub NSUInteger);
bitflags::bitflags! {
    impl AVPlayerInterstitialEventRestrictions: NSUInteger {
/// 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.
        #[doc(alias = "AVPlayerInterstitialEventRestrictionNone")]
        const None = 0;
/// 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.
        #[doc(alias = "AVPlayerInterstitialEventRestrictionConstrainsSeekingForwardInPrimaryContent")]
        const ConstrainsSeekingForwardInPrimaryContent = 1<<0;
/// 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.
        #[doc(alias = "AVPlayerInterstitialEventRestrictionRequiresPlaybackAtPreferredRateForAdvancement")]
        const RequiresPlaybackAtPreferredRateForAdvancement = 1<<2;
/// 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.
        #[doc(alias = "AVPlayerInterstitialEventRestrictionDefaultPolicy")]
        const DefaultPolicy = AVPlayerInterstitialEventRestrictions::None.0;
    }
}

unsafe impl Encode for AVPlayerInterstitialEventRestrictions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for AVPlayerInterstitialEventRestrictions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// A particular cue can be specified when creating AVPlayerInterstitialEvents to override the start time/date to a predefined position.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventcue?language=objc)
// NS_TYPED_ENUM
pub type AVPlayerInterstitialEventCue = NSString;

extern "C" {
    /// No cue specified; event playback should start at event time (or date).
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventnocue?language=objc)
    pub static AVPlayerInterstitialEventNoCue: &'static AVPlayerInterstitialEventCue;
}

extern "C" {
    /// Event playback should occur before starting primary playback, regardless of initial primary playback position.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventjoincue?language=objc)
    pub static AVPlayerInterstitialEventJoinCue: &'static AVPlayerInterstitialEventCue;
}

extern "C" {
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventleavecue?language=objc)
    pub static AVPlayerInterstitialEventLeaveCue: &'static AVPlayerInterstitialEventCue;
}

/// These constants specify how an event occupies time on AVPlayerItemIntegratedTimeline.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventtimelineoccupancy?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerInterstitialEventTimelineOccupancy(pub NSInteger);
impl AVPlayerInterstitialEventTimelineOccupancy {
    /// Indicates this interstitial event occupies a single point on AVPlayerItemIntegratedTimeline.
    #[doc(alias = "AVPlayerInterstitialEventTimelineOccupancySinglePoint")]
    pub const SinglePoint: Self = Self(0);
    /// Indicates this interstitial event fills AVPlayerItemIntegratedTimeline with the duration of this event.
    #[doc(alias = "AVPlayerInterstitialEventTimelineOccupancyFill")]
    pub const Fill: Self = Self(1);
}

unsafe impl Encode for AVPlayerInterstitialEventTimelineOccupancy {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for AVPlayerInterstitialEventTimelineOccupancy {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// These constants describe the status of the asset list response for an AVPlayerInterstitialEvent.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventassetlistresponsestatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerInterstitialEventAssetListResponseStatus(pub NSInteger);
impl AVPlayerInterstitialEventAssetListResponseStatus {
    /// Indicates that the asset list response is now available and non-nil, meaning the asset list read was successful.
    #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusAvailable")]
    pub const Available: Self = Self(0);
    /// Indicates that asset list response has been cleared and reverted to its original state of nil.
    #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusCleared")]
    pub const Cleared: Self = Self(1);
    /// Indicates that the asset list response is unavailable, meaning the asset list read failed.
    #[doc(alias = "AVPlayerInterstitialEventAssetListResponseStatusUnavailable")]
    pub const Unavailable: Self = Self(2);
}

unsafe impl Encode for AVPlayerInterstitialEventAssetListResponseStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for AVPlayerInterstitialEventAssetListResponseStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// These constants describe the state for a skippable AVPlayerInterstitialEvent.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventskippableeventstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerInterstitialEventSkippableEventState(pub NSInteger);
impl AVPlayerInterstitialEventSkippableEventState {
    /// Indicates that the interstitial event is not skippable.
    #[doc(alias = "AVPlayerInterstitialEventSkippableEventStateNotSkippable")]
    pub const NotSkippable: Self = Self(0);
    /// Indicates that the interstitial event will eventually become eligible to be skipped.
    #[doc(alias = "AVPlayerInterstitialEventSkippableEventStateNotYetEligible")]
    pub const NotYetEligible: Self = Self(1);
    /// Indicates that the interstitial event is currently skippable.
    #[doc(alias = "AVPlayerInterstitialEventSkippableEventStateEligible")]
    pub const Eligible: Self = Self(2);
    /// Indicates that the interstitial event is no longer eligible to be skipped.
    #[doc(alias = "AVPlayerInterstitialEventSkippableEventStateNoLongerEligible")]
    pub const NoLongerEligible: Self = Self(3);
}

unsafe impl Encode for AVPlayerInterstitialEventSkippableEventState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for AVPlayerInterstitialEventSkippableEventState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// 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.
    ///
    /// The primary content is specified as an instance of AVPlayerItem, designated as the primary item of the interstitial event.
    ///
    /// 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.
    ///
    /// 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.
    ///
    /// 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.
    ///
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialevent?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerInterstitialEvent;
);

extern_conformance!(
    unsafe impl NSCopying for AVPlayerInterstitialEvent {}
);

unsafe impl CopyingHelper for AVPlayerInterstitialEvent {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerInterstitialEvent {}
);

impl AVPlayerInterstitialEvent {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
        /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
        ///
        /// - 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.
        /// - Parameter identifier: An external identifier for the event.
        /// - 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.
        /// - 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.
        /// - Parameter restrictions: Indicates restrictions on the use of end user playback controls that are imposed by the event.
        /// - 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.
        /// - 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.
        /// - Parameter userDefinedAttributes: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEvent.
        ///
        /// # Safety
        ///
        /// `user_defined_attributes` generic should be of the correct type.
        #[deprecated = "Use interstitialEventWithPrimaryItem:time: instead"]
        #[unsafe(method(interstitialEventWithPrimaryItem:identifier:time:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventWithPrimaryItem_identifier_time_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes(
            primary_item: &AVPlayerItem,
            identifier: Option<&NSString>,
            time: CMTime,
            template_items: &NSArray<AVPlayerItem>,
            restrictions: AVPlayerInterstitialEventRestrictions,
            resumption_offset: CMTime,
            playout_limit: CMTime,
            user_defined_attributes: Option<&NSDictionary>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
        /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
        ///
        /// - 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.
        /// - Parameter identifier: An external identifier for the event.
        /// - 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.
        /// - 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.
        /// - Parameter restrictions: Indicates restrictions on the use of end user playback controls that are imposed by the event.
        /// - 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.
        /// - 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.
        /// - Parameter userDefinedAttributes: Storage for attributes defined by the client or the content vendor. Attribute names should begin with X- for uniformity with server insertion.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEvent.
        ///
        /// # Safety
        ///
        /// `user_defined_attributes` generic should be of the correct type.
        #[deprecated = "Use interstitialEventWithPrimaryItem:date: instead"]
        #[unsafe(method(interstitialEventWithPrimaryItem:identifier:date:templateItems:restrictions:resumptionOffset:playoutLimit:userDefinedAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventWithPrimaryItem_identifier_date_templateItems_restrictions_resumptionOffset_playoutLimit_userDefinedAttributes(
            primary_item: &AVPlayerItem,
            identifier: Option<&NSString>,
            date: &NSDate,
            template_items: &NSArray<AVPlayerItem>,
            restrictions: AVPlayerInterstitialEventRestrictions,
            resumption_offset: CMTime,
            playout_limit: CMTime,
            user_defined_attributes: Option<&NSDictionary>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "AVPlayerItem", feature = "objc2-core-media"))]
        /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
        ///
        /// - 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.
        /// - 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.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEvent.
        #[unsafe(method(interstitialEventWithPrimaryItem:time:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventWithPrimaryItem_time(
            primary_item: &AVPlayerItem,
            time: CMTime,
        ) -> Retained<Self>;

        #[cfg(feature = "AVPlayerItem")]
        /// Returns an instance of AVPlayerInterstitialEvent for use in scheduling interstitial playback.
        ///
        /// - 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.
        /// - 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.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEvent.
        #[unsafe(method(interstitialEventWithPrimaryItem:date:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventWithPrimaryItem_date(
            primary_item: &AVPlayerItem,
            date: &NSDate,
        ) -> Retained<Self>;

        #[cfg(feature = "AVPlayerItem")]
        /// 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.
        #[unsafe(method(primaryItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn primaryItem(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayerItem>>;

        /// An external identifier for the event.
        ///
        /// 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.
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn identifier(&self) -> Retained<NSString>;

        #[cfg(feature = "objc2-core-media")]
        /// 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.
        ///
        /// Will have a value equal to kCMTimeInvalid if the event was initialized with a date instead of a time.
        #[unsafe(method(time))]
        #[unsafe(method_family = none)]
        pub unsafe fn time(&self) -> CMTime;

        /// 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.
        ///
        /// Will have a value of nil if the event was initialized with a time instead of a date.
        #[unsafe(method(date))]
        #[unsafe(method_family = none)]
        pub unsafe fn date(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "AVPlayerItem")]
        /// An array of AVPlayerItems with configurations that will be reproduced for the playback of interstitial content.
        ///
        /// 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.
        ///
        /// An NSInvalidArgumentException will be raised if any of the template items employs an AVAsset that lacks a URL, such as an AVComposition.
        #[unsafe(method(templateItems))]
        #[unsafe(method_family = none)]
        pub unsafe fn templateItems(
            &self,
            mtm: MainThreadMarker,
        ) -> Retained<NSArray<AVPlayerItem>>;

        /// Indicates restrictions on the use of end user playback controls that are imposed by the event.
        #[unsafe(method(restrictions))]
        #[unsafe(method_family = none)]
        pub unsafe fn restrictions(&self) -> AVPlayerInterstitialEventRestrictions;

        #[cfg(feature = "objc2-core-media")]
        /// 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; this value is typically suitable for live broadcasts. The default value is kCMTimeZero.
        #[unsafe(method(resumptionOffset))]
        #[unsafe(method_family = none)]
        pub unsafe fn resumptionOffset(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Specifies the offset in time at which playback of the interstitial event should end.
        ///
        /// Can be any positive numeric value, or invalid. The default value is kCMTimeInvalid, which means there is no limit.
        #[unsafe(method(playoutLimit))]
        #[unsafe(method_family = none)]
        pub unsafe fn playoutLimit(&self) -> CMTime;

        /// Specifies that the start time of interstitial playback should be snapped to a segment boundary of the primary asset
        ///
        /// 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.
        #[unsafe(method(alignsStartWithPrimarySegmentBoundary))]
        #[unsafe(method_family = none)]
        pub unsafe fn alignsStartWithPrimarySegmentBoundary(&self) -> bool;

        /// Specifies that the resumption time of primary playback should be snapped to a segment boundary of the primary asset
        ///
        /// 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.
        #[unsafe(method(alignsResumptionWithPrimarySegmentBoundary))]
        #[unsafe(method_family = none)]
        pub unsafe fn alignsResumptionWithPrimarySegmentBoundary(&self) -> bool;

        /// The cue property is used to schedule event playback at a predefined position of primary playback.
        #[unsafe(method(cue))]
        #[unsafe(method_family = none)]
        pub unsafe fn cue(&self) -> Retained<AVPlayerInterstitialEventCue>;

        /// Specifies that the interstitial should be scheduled for playback once only, and suppressed for subsequent replay.
        ///
        /// 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.
        #[unsafe(method(willPlayOnce))]
        #[unsafe(method_family = none)]
        pub unsafe fn willPlayOnce(&self) -> bool;

        /// Attributes of the event defined by the content vendor or the client.
        ///
        /// Dictionary keys are attribute names. Dictionary values are attribute values.
        #[unsafe(method(userDefinedAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn userDefinedAttributes(&self) -> Retained<NSDictionary>;

        /// The asset list JSON response as a dictionary, or nil if no asset list response has been loaded for the event.
        ///
        /// 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.
        #[unsafe(method(assetListResponse))]
        #[unsafe(method_family = none)]
        pub unsafe fn assetListResponse(&self) -> Option<Retained<NSDictionary>>;

        /// Indicates this event's occupancy on AVPlayerItemIntegratedTimeline. The default value is AVPlayerInterstitialEventTimelineSinglePointOccupancy.
        #[unsafe(method(timelineOccupancy))]
        #[unsafe(method_family = none)]
        pub unsafe fn timelineOccupancy(&self) -> AVPlayerInterstitialEventTimelineOccupancy;

        /// Indicates this event will supplement the primary content and should be presented unified with the primary item. The default value is NO.
        #[unsafe(method(supplementsPrimaryContent))]
        #[unsafe(method_family = none)]
        pub unsafe fn supplementsPrimaryContent(&self) -> bool;

        /// Indicates this event's content is dynamic and server may respond with different interstitial assets for other particpants in coordinated playback.
        ///
        /// 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.
        #[unsafe(method(contentMayVary))]
        #[unsafe(method_family = none)]
        pub unsafe fn contentMayVary(&self) -> bool;

        #[cfg(feature = "objc2-core-media")]
        /// The time range within the duration of the interstitial event for which a skip button should be displayed.
        ///
        /// The start of the time range should indicate at which point the skip button should appear. The duration of the time range should indicate how long the skip button should be available. If this value is set to kCMTimePositiveInfinity, then the skip button will be available for the remainder of the interstitial's duration after appearing. If either the start or duration of the time range is kCMTimeInvalid, then the interstitial will NOT be eligible to be skipped.
        #[unsafe(method(skipControlTimeRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn skipControlTimeRange(&self) -> CMTimeRange;

        /// The key defined in the AVPlayerInterstitialEventController's localizedStringsBundle that points to the localized label for the skip button.
        ///
        /// If the value of the property is nil, the skip button may contain a generic label depending on the implementation of the UI that's in use. To ensure the best available user experience in various playback configurations, including external playback, set a value for this property that provides localized translations of skip control labels.
        #[unsafe(method(skipControlLocalizedLabelBundleKey))]
        #[unsafe(method_family = none)]
        pub unsafe fn skipControlLocalizedLabelBundleKey(&self) -> Option<Retained<NSString>>;
    );
}

extern_class!(
    /// 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.
    ///
    /// 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.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerInterstitialEventMonitor;
);

unsafe impl Send for AVPlayerInterstitialEventMonitor {}

unsafe impl Sync for AVPlayerInterstitialEventMonitor {}

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerInterstitialEventMonitor {}
);

impl AVPlayerInterstitialEventMonitor {
    extern_methods!(
        #[cfg(feature = "AVPlayer")]
        /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
        ///
        /// - Parameter primaryPlayer: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEventMonitor.
        #[unsafe(method(interstitialEventMonitorWithPrimaryPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventMonitorWithPrimaryPlayer(
            primary_player: &AVPlayer,
        ) -> Retained<Self>;

        #[cfg(feature = "AVPlayer")]
        #[unsafe(method(initWithPrimaryPlayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPrimaryPlayer(
            this: Allocated<Self>,
            primary_player: &AVPlayer,
        ) -> Retained<Self>;

        #[cfg(feature = "AVPlayer")]
        /// The AVPlayer that will play the primaryItems of the receiver's interstitial events.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(primaryPlayer))]
        #[unsafe(method_family = none)]
        pub unsafe fn primaryPlayer(&self, mtm: MainThreadMarker) -> Option<Retained<AVPlayer>>;

        #[cfg(feature = "AVPlayer")]
        /// The AVQueuePlayer that will play interstitial items during suspension of playback of primary items.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(interstitialPlayer))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialPlayer(&self, mtm: MainThreadMarker) -> Retained<AVQueuePlayer>;

        /// 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.
        ///
        /// 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.
        /// 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.
        /// 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.
        #[unsafe(method(events))]
        #[unsafe(method_family = none)]
        pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerInterstitialEvent>>;

        /// The current interstitial event. Has a value of nil during playback of primary content by the primary player.
        #[unsafe(method(currentEvent))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentEvent(&self) -> Option<Retained<AVPlayerInterstitialEvent>>;

        /// The skippable event state for the currentEvent.
        ///
        /// If currentEvent is nil, then the value will be AVPlayerInterstitialEventSkippableEventStateNotSkippable.
        #[unsafe(method(currentEventSkippableState))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentEventSkippableState(
            &self,
        ) -> AVPlayerInterstitialEventSkippableEventState;

        /// The skip control label for the currentEvent.
        ///
        /// If a localizedStringsBundle has been set on the AVPlayerInterstitialEventController, and a skipControlLocalizedLabelBundleKey is set on the currentEvent, then this value will be the localized string that was matched to the event's skipControlLocalizedLabelBundleKey for the corresponding system language in the supplied Bundle, if any.
        /// If currentEvent is nil, then the value will be nil.
        #[unsafe(method(currentEventSkipControlLabel))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentEventSkipControlLabel(&self) -> Option<Retained<NSString>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerInterstitialEventMonitor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern "C" {
    /// A notification that's posted whenever the value of events of an AVPlayerInterstitialEventMonitor is changed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitoreventsdidchangenotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorEventsDidChangeNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// A notification that's posted whenever the currentEvent of an AVPlayerInterstitialEventMonitor changes.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventdidchangenotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventDidChangeNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// A notification that is posted whenever an AVPlayerInterstitialEvent's asset list response status changes.
    ///
    /// Carries a userInfo dictionary that can contain the following keys and values:
    /// 1. AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeEventKey, with a value that indicates the AVPlayerInterstitialEvent for which the asset response status has changed.
    /// 2. AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeStatusKey, with a value of type AVPlayerInterstitialEventAssetListResponseStatus, indicating the changed asset response status.
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangenotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// The dictionary key for the AVPlayerInterstitial event that had its asset list response status changed in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangeeventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeEventKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key for the asset list response status in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEventAssetListResponseStatus.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangestatuskey?language=objc)
    pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeStatusKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key for the NSError in the payload of the AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeNotification.
    ///
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorassetlistresponsestatusdidchangeerrorkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorAssetListResponseStatusDidChangeErrorKey:
        &'static NSString;
}

extern "C" {
    /// A notification that's posted whenever the currentEventSkippableState of an AVPlayerInterstitialEventMonitor changes.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippablestatedidchangenotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// The dictionary key for the AVPlayerInterstitial event that had its skippable event state changed in the payload of the AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippablestatedidchangeeventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeEventKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key for the skippable event state in the payload of the AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeNotification.
    ///
    /// The value corresponding to this key is an NSNumber containing type AVPlayerInterstitialEventSkippableEventState.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippablestatedidchangestatekey?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeStateKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key for the skip label of the event in the payload of the AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeNotification.
    ///
    /// The value corresponding to this key is an NSString that's the localized skip label if a localizedStringsBundle is set on the AVPlayerInterstitialEventController and a skipControlLocalizedLabelBundleKey on the AVPlayerInterstitialEvent whose skippable event state changed. Note that this key will not be present if there is no localizedStringsBundle set, or if the currentEventSkippableState changed to AVPlayerInterstitialEventSkippableEventStateNotSkippable.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippablestatedidchangeskipcontrollabelkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippableStateDidChangeSkipControlLabelKey:
        &'static NSString;
}

extern "C" {
    /// A notification that's posted whenever an event was skipped via skip control.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippednotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippedNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// The dictionary key for the AVPlayerInterstitialEvent that was skipped in the payload of the AVPlayerInterstitialEventMonitorCurrentEventSkippedNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorcurrenteventskippedeventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorCurrentEventSkippedEventKey: &'static NSString;
}

extern "C" {
    /// A notification that is posted whenever an AVPlayerInterstitialEvent with loaded assets was unscheduled prior to playing.
    ///
    /// Carries a userInfo dictionary that can contain the following keys and values:
    /// 1. AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledEventKey, with a value that indicates which AVPlayerInterstitialEvent was unscheduled.
    /// 2. AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledErrorKey, with an NSError value. This key will only be present if the AVPlayerInterstitialEvent was unscheduled due to an error.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventwasunschedulednotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// The dictionary key for the AVPlayerInterstitialEvent that was unscheduled in the payload of the AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventwasunscheduledeventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledEventKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key to indicate whether the event that was unscheduled was due to an error.
    ///
    /// The value corresponding to this key is of type NSError. This key only exists in the payload of AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledNotification if the interstitial event was unscheduled due to an error.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventwasunschedulederrorkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventWasUnscheduledErrorKey:
        &'static NSString;
}

extern "C" {
    /// A notification that is posted whenever an AVPlayerInterstitialEvent finished playing.
    ///
    /// Carries a userInfo dictionary that can contain the following keys and values:
    /// 1. AVPlayerInterstitialEventMonitorInterstitialEventDidFinishEventKey, with a value that indicates the AVPlayerInterstitialEvent that finished playing.
    /// 2. AVPlayerInterstitialEventMonitorInterstitialEventDidFinishPlayoutTimeKey, with a value that indicates how long that AVPlayerInterstitialEvent played out for.
    /// 3. AVPlayerInterstitialEventMonitorInterstitialEventDidFinishDidPlayEntireEventKey, with a value that indicates whether the AVPlayerInterstitialEvent was fully played out.
    ///
    /// Note that cancelling an AVPlayerInterstitialEvent after playback started but prior to playback finishing will also trigger this event.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventdidfinishnotification?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventDidFinishNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// The dictionary key for the AVPlayerInterstitialEvent that finished playing in the payload of the AVPlayerInterstitialEventMonitorInterstitialEventDidFinishNotification.
    ///
    /// The value corresponding to this key is of type AVPlayerInterstitialEvent.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventdidfinisheventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventDidFinishEventKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key for the playout time of the event that finished playing in the payload of the AVPlayerInterstitialEventMonitorInterstitialEventDidFinishNotification.
    ///
    /// The value corresponding to this key is of type CMTime as a NSDictionary.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventdidfinishplayouttimekey?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventDidFinishPlayoutTimeKey:
        &'static NSString;
}

extern "C" {
    /// The dictionary key to indicate whether the event that finished playing was fully played out in the payload of the AVPlayerInterstitialEventMonitorInterstitialEventDidFinishNotification.
    ///
    /// The value corresponding to this key is of type NSNumber with a BOOL value.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventmonitorinterstitialeventdidfinishdidplayentireeventkey?language=objc)
    pub static AVPlayerInterstitialEventMonitorInterstitialEventDidFinishDidPlayEntireEventKey:
        &'static NSString;
}

extern_class!(
    /// An AVPlayerInterstitialEventController allows you to specify a schedule of interstitial events for items played by a primary player. 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.
    ///
    /// 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.
    ///
    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerinterstitialeventcontroller?language=objc)
    #[unsafe(super(AVPlayerInterstitialEventMonitor, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerInterstitialEventController;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for AVPlayerInterstitialEventController {}
);

impl AVPlayerInterstitialEventController {
    extern_methods!(
        #[cfg(feature = "AVPlayer")]
        /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
        ///
        /// This method throws an exception if the primary player is an interstitial player.
        ///
        /// - Parameter primaryPlayer: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEventController.
        #[unsafe(method(interstitialEventControllerWithPrimaryPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventControllerWithPrimaryPlayer(
            primary_player: &AVPlayer,
        ) -> Retained<Self>;

        #[cfg(feature = "AVPlayer")]
        /// This method throws an exception if the primary player is an interstitial player.
        #[unsafe(method(initWithPrimaryPlayer:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPrimaryPlayer(
            this: Allocated<Self>,
            primary_player: &AVPlayer,
        ) -> Retained<Self>;

        /// Specifies the current schedule of interstitial events.
        ///
        /// 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.
        ///
        /// 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:.
        ///
        /// 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.)
        ///
        /// If interstitial events are scheduled for the same date, they are ordered according to their position in the events array.
        ///
        /// 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.
        ///
        /// 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.
        #[unsafe(method(events))]
        #[unsafe(method_family = none)]
        pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerInterstitialEvent>>;

        /// Setter for [`events`][Self::events].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setEvents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEvents(&self, events: Option<&NSArray<AVPlayerInterstitialEvent>>);

        #[cfg(feature = "objc2-core-media")]
        /// Causes the playback of any and all interstitial content currently in progress to be abandoned and the playback of primary content to be resumed.
        ///
        /// If invoked during the handling of coinciding interstitial events, they will all be canceled.
        /// When you cancel interstitial events via the use of this method, the value of resumptionOffset that you pass overrides the events' resumptionOffset.
        /// Has no effect while currentEvent is nil.
        ///
        /// - 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 match with the wallclock time elapsed during interstitial playback, pass a value of kCMTimeIndefinite. To specify that the effective resumption time offset should match with the projected playback time, pass a value of kCMTimeInvalid.
        #[unsafe(method(cancelCurrentEventWithResumptionOffset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelCurrentEventWithResumptionOffset(&self, resumption_offset: CMTime);

        /// Causes the playback of the currently playing interstital event to be abandoned.
        ///
        /// Note that coinciding events will NOT be skipped.
        /// This results in AVPlayerInterstitialEventMonitorCurrentEventSkippedNotification being posted.
        /// Has no effect while the currentEvent is nil.
        #[unsafe(method(skipCurrentEvent))]
        #[unsafe(method_family = none)]
        pub unsafe fn skipCurrentEvent(&self);

        /// The bundle that contains the localized strings to be used by the AVPlayerInterstitialEventController.
        ///
        /// If the value of the property is nil, any UI elements triggered by the AVPlayerInterstitialEventController, such as the skip button, may contain a generic label based on the implementation of the UI that's in use. To ensure the best available user experience in various playback configurations, including external playback, set a value for this property that provides localized translations of skip control labels.
        #[unsafe(method(localizedStringsBundle))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedStringsBundle(&self) -> Option<Retained<NSBundle>>;

        /// Setter for [`localizedStringsBundle`][Self::localizedStringsBundle].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedStringsBundle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocalizedStringsBundle(&self, localized_strings_bundle: Option<&NSBundle>);

        /// The name of the table in the bundle that contains the localized strings to be used by the AVPlayerInterstitialEventController.
        ///
        /// If the value of the property is nil, it will default to "Localizable"
        #[unsafe(method(localizedStringsTableName))]
        #[unsafe(method_family = none)]
        pub unsafe fn localizedStringsTableName(&self) -> Option<Retained<NSString>>;

        /// Setter for [`localizedStringsTableName`][Self::localizedStringsTableName].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedStringsTableName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocalizedStringsTableName(
            &self,
            localized_strings_table_name: Option<&NSString>,
        );
    );
}

/// Methods declared on superclass `AVPlayerInterstitialEventMonitor`.
impl AVPlayerInterstitialEventController {
    extern_methods!(
        #[cfg(feature = "AVPlayer")]
        /// Returns an instance of AVPlayerInterstitialEvent for use in observing and scheduling interstitial playback.
        ///
        /// - Parameter primaryPlayer: The AVPlayer that will play the primaryItems of the receiver's interstitial events.
        ///
        /// - Returns: An instance of AVPlayerInterstitialEventMonitor.
        #[unsafe(method(interstitialEventMonitorWithPrimaryPlayer:))]
        #[unsafe(method_family = none)]
        pub unsafe fn interstitialEventMonitorWithPrimaryPlayer(
            primary_player: &AVPlayer,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl AVPlayerInterstitialEventController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern "C" {
    /// Indicates that the player is waiting for the completion of an interstitial event.
    ///
    /// The player is waiting for playback because an interstitial event is currently in progress. Interstitial events can be monitored via use of an AVPlayerInterstitialEventMonitor.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerwaitingduringinterstitialeventreason?language=objc)
    #[cfg(feature = "AVPlayer")]
    pub static AVPlayerWaitingDuringInterstitialEventReason: &'static AVPlayerWaitingReason;
}

/// AVPlayerInterstitialSupport.
#[cfg(feature = "AVPlayer")]
impl AVPlayer {
    extern_methods!();
}

/// AVPlayerInterstitialSupport.
#[cfg(feature = "AVPlayerItem")]
impl AVPlayerItem {
    extern_methods!(
        /// 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.
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
        #[unsafe(method(automaticallyHandlesInterstitialEvents))]
        #[unsafe(method_family = none)]
        pub unsafe fn automaticallyHandlesInterstitialEvents(&self) -> bool;

        /// Setter for [`automaticallyHandlesInterstitialEvents`][Self::automaticallyHandlesInterstitialEvents].
        #[unsafe(method(setAutomaticallyHandlesInterstitialEvents:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutomaticallyHandlesInterstitialEvents(
            &self,
            automatically_handles_interstitial_events: bool,
        );

        /// 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.
        #[unsafe(method(templatePlayerItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn templatePlayerItem(&self) -> Option<Retained<AVPlayerItem>>;
    );
}