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
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
//! 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-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemtimejumpednotification?language=objc)
    pub static AVPlayerItemTimeJumpedNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemdidplaytoendtimenotification?language=objc)
    pub static AVPlayerItemDidPlayToEndTimeNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemfailedtoplaytoendtimenotification?language=objc)
    pub static AVPlayerItemFailedToPlayToEndTimeNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemplaybackstallednotification?language=objc)
    pub static AVPlayerItemPlaybackStalledNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemnewaccesslogentrynotification?language=objc)
    pub static AVPlayerItemNewAccessLogEntryNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemnewerrorlogentrynotification?language=objc)
    pub static AVPlayerItemNewErrorLogEntryNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemrecommendedtimeoffsetfromlivedidchangenotification?language=objc)
    pub static AVPlayerItemRecommendedTimeOffsetFromLiveDidChangeNotification:
        &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemmediaselectiondidchangenotification?language=objc)
    pub static AVPlayerItemMediaSelectionDidChangeNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemfailedtoplaytoendtimeerrorkey?language=objc)
    pub static AVPlayerItemFailedToPlayToEndTimeErrorKey: &'static NSString;
}

extern "C" {
    /// Indicates a time jump was caused by another participant connected through AVPlayerPlaybackCoordinator.
    ///
    /// Informs the receiver of an AVPlayerItemTimeJumpedNotification that a time jump originated from another AVCoordinatedPlaybackParticipant connected through AVPlayerPlaybackCoordinator. This can be used to inform UI showing why the current time changed. The type of the value for this key is an AVCoordinatedPlaybackParticipant, which is part of the AVPlayerPlaybackCoordinator.otherParticipants array.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemtimejumpedoriginatingparticipantkey?language=objc)
    pub static AVPlayerItemTimeJumpedOriginatingParticipantKey: &'static NSString;
}

/// These constants are returned by the AVPlayerItem status property to indicate whether it can successfully be played.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemstatus?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerItemStatus(pub NSInteger);
impl AVPlayerItemStatus {
    /// Indicates that the status of the player item is not yet known because it has not tried to load new media resources for playback.
    #[doc(alias = "AVPlayerItemStatusUnknown")]
    pub const Unknown: Self = Self(0);
    /// Indicates that the player item is ready to be played.
    #[doc(alias = "AVPlayerItemStatusReadyToPlay")]
    pub const ReadyToPlay: Self = Self(1);
    /// Indicates that the player item can no longer be played because of an error. The error is described by the value of the player item's error property. The player item's errorLog property might contain additional information about the error.
    #[doc(alias = "AVPlayerItemStatusFailed")]
    pub const Failed: Self = Self(2);
}

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

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

extern_class!(
    /// An AVPlayerItem carries a reference to an AVAsset as well as presentation settings for that asset.
    ///
    /// Note that inspection of media assets is provided by AVAsset.
    /// This class is intended to represent presentation state for an asset that's played by an AVPlayer and to permit observation of that state.
    ///
    /// It is important to avoid key-value observation with a key path containing the asset's property. Observe the AVPlayerItem's property instead. For example, use the "duration" key path instead of the "asset.duration" key path.
    ///
    /// To allow clients to add and remove their objects as key-value observers safely, AVPlayerItem serializes notifications of
    /// changes that occur dynamically during playback on the same dispatch queue on which notifications of playback state changes
    /// are serialized by its associated AVPlayer. By default, this queue is the main queue. See dispatch_get_main_queue().
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritem?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItem;
);

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

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

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

impl AVPlayerItem {
    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(mtm: MainThreadMarker) -> Retained<Self>;

        /// Returns an instance of AVPlayerItem for playing a resource at the specified location.
        ///
        /// Equivalent to +playerItemWithAsset:, passing [AVAsset assetWithURL:URL] as the value of asset.
        ///
        /// - Parameter URL:
        ///
        /// - Returns: An instance of AVPlayerItem.
        #[unsafe(method(playerItemWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerItemWithURL(url: &NSURL, mtm: MainThreadMarker) -> Retained<Self>;

        #[cfg(feature = "AVAsset")]
        /// Returns an instance of AVPlayerItem for playing an AVAsset.
        ///
        /// Equivalent to +playerItemWithAsset:automaticallyLoadedAssetKeys:, passing
        /// @
        /// [
        /// "
        /// duration" ] as the value of automaticallyLoadedAssetKeys.
        ///
        /// This method, along with the companion `asset` property, is MainActor-isolated for Swift clients because AVAsset is not Sendable. If you are using a Sendable subclass of AVAsset, such as AVURLAsset, an overload of this initializer will be chosen automatically to allow you to initialize an AVPlayerItem while not running on the main actor.
        ///
        /// - Parameter asset:
        ///
        /// - Returns: An instance of AVPlayerItem.
        #[unsafe(method(playerItemWithAsset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerItemWithAsset(asset: &AVAsset, mtm: MainThreadMarker)
            -> Retained<Self>;

        #[cfg(feature = "AVAsset")]
        /// Returns an instance of AVPlayerItem for playing an AVAsset.
        ///
        /// The value of each key in automaticallyLoadedAssetKeys will be automatically be loaded by the underlying AVAsset before the receiver achieves the status AVPlayerItemStatusReadyToPlay; i.e. when the item is ready to play, the value of -[[AVPlayerItem asset] statusOfValueForKey:error:] will be one of the terminal status values greater than AVKeyValueStatusLoading.
        ///
        /// This method, along with the companion `asset` property, is MainActor-isolated for Swift clients because AVAsset is not Sendable. If you are using a Sendable subclass of AVAsset, such as AVURLAsset, you can use `init(asset:automaticallyLoadedAssetKeys:)` to initialize an AVPlayerItem while not running on the main actor.
        ///
        /// - Parameter asset:
        /// - Parameter automaticallyLoadedAssetKeys: An NSArray of NSStrings, each representing a property key defined by AVAsset. See AVAsset.h for property keys, e.g. duration.
        ///
        /// - Returns: An instance of AVPlayerItem.
        #[unsafe(method(playerItemWithAsset:automaticallyLoadedAssetKeys:))]
        #[unsafe(method_family = none)]
        pub unsafe fn playerItemWithAsset_automaticallyLoadedAssetKeys(
            asset: &AVAsset,
            automatically_loaded_asset_keys: Option<&NSArray<NSString>>,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        /// Initializes an AVPlayerItem with an NSURL.
        ///
        /// Equivalent to -initWithAsset:, passing [AVAsset assetWithURL:URL] as the value of asset.
        ///
        /// - Parameter URL:
        ///
        /// - Returns: An instance of AVPlayerItem
        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;

        #[cfg(feature = "AVAsset")]
        /// Initializes an AVPlayerItem with an AVAsset.
        ///
        /// Equivalent to -initWithAsset:automaticallyLoadedAssetKeys:, passing
        /// @
        /// [
        /// "
        /// duration" ] as the value of automaticallyLoadedAssetKeys.
        ///
        /// This method, along with the companion `asset` property, is MainActor-isolated for Swift clients because AVAsset is not Sendable. If you are using a Sendable subclass of AVAsset, such as AVURLAsset, an overload of this initializer will be chosen automatically to allow you to initialize an AVPlayerItem while not running on the main actor.
        ///
        /// - Parameter asset:
        ///
        /// - Returns: An instance of AVPlayerItem
        #[unsafe(method(initWithAsset:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset(this: Allocated<Self>, asset: &AVAsset) -> Retained<Self>;

        #[cfg(feature = "AVAsset")]
        /// Initializes an AVPlayerItem with an AVAsset.
        ///
        /// The value of each key in automaticallyLoadedAssetKeys will be automatically be loaded by the underlying AVAsset before the receiver achieves the status AVPlayerItemStatusReadyToPlay; i.e. when the item is ready to play, the value of -[[AVPlayerItem asset] statusOfValueForKey:error:] will be one of the terminal status values greater than AVKeyValueStatusLoading.
        ///
        /// This method, along with the companion `asset` property, is MainActor-isolated for Swift clients because AVAsset is not Sendable. If you are using a Sendable subclass of AVAsset, such as AVURLAsset, you can use `init(asset:automaticallyLoadedAssetKeys:)` to initialize an AVPlayerItem while not running on the main actor.
        ///
        /// - Parameter asset: An instance of AVAsset.
        /// - Parameter automaticallyLoadedAssetKeys: An NSArray of NSStrings, each representing a property key defined by AVAsset. See AVAsset.h for property keys, e.g. duration.
        ///
        /// - Returns: An instance of AVPlayerItem
        #[unsafe(method(initWithAsset:automaticallyLoadedAssetKeys:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithAsset_automaticallyLoadedAssetKeys(
            this: Allocated<Self>,
            asset: &AVAsset,
            automatically_loaded_asset_keys: Option<&NSArray<NSString>>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `zone` must be a valid pointer or null.
        #[unsafe(method(copyWithZone:))]
        #[unsafe(method_family = copy)]
        pub unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<AnyObject>;

        #[unsafe(method(copy))]
        #[unsafe(method_family = copy)]
        pub unsafe fn copy(&self) -> Retained<AnyObject>;

        /// The ability of the receiver to be used for playback.
        ///
        /// The value of this property is an AVPlayerItemStatus that indicates whether the receiver can be used for playback.
        /// When the value of this property is AVPlayerItemStatusFailed, the receiver can no longer be used for playback and
        /// a new instance needs to be created in its place. When this happens, clients can check the value of the error
        /// property to determine the nature of the failure. The value of this property will not be updated after the receiver
        /// is removed from an AVPlayer. This property is key value observable.
        #[unsafe(method(status))]
        #[unsafe(method_family = none)]
        pub unsafe fn status(&self) -> AVPlayerItemStatus;

        /// If the receiver's status is AVPlayerItemStatusFailed, this describes the error that caused the failure.
        ///
        /// The value of this property is an NSError that describes what caused the receiver to no longer be able to be played.
        /// If the receiver's status is not AVPlayerItemStatusFailed, the value of this property is nil.
        #[unsafe(method(error))]
        #[unsafe(method_family = none)]
        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
    );
}

/// AVPlayerItemInspection.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVAsset")]
        /// Accessor for underlying AVAsset.
        #[unsafe(method(asset))]
        #[unsafe(method_family = none)]
        pub unsafe fn asset(&self) -> Retained<AVAsset>;

        #[cfg(feature = "AVPlayerItemTrack")]
        /// Provides array of AVPlayerItem tracks. Observable (can change dynamically during playback).
        ///
        /// The value of this property will accord with the properties of the underlying media resource when the receiver becomes ready to play.
        /// Before the underlying media resource has been sufficiently loaded, its value is an empty NSArray. Use key-value observation to obtain
        /// a valid array of tracks as soon as it becomes available.
        #[unsafe(method(tracks))]
        #[unsafe(method_family = none)]
        pub unsafe fn tracks(&self) -> Retained<NSArray<AVPlayerItemTrack>>;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates the duration of the item, not considering either its forwardPlaybackEndTime or reversePlaybackEndTime.
        ///
        /// This property is observable. The duration of an item can change dynamically during playback.
        ///
        /// Unless you omit
        /// "
        /// duration" from the array of asset keys you pass to +playerItemWithAsset:automaticallyLoadedAssetKeys: or
        /// -initWithAsset:automaticallyLoadedAssetKeys:, the value of this property will accord with the properties of the underlying
        /// AVAsset and the current state of playback once the receiver becomes ready to play.
        ///
        /// Before the underlying duration has been loaded, the value of this property is kCMTimeIndefinite. Use key-value observation to
        /// obtain a valid duration as soon as it becomes available. (Note that the value of duration may remain kCMTimeIndefinite,
        /// e.g. for live streams.)
        #[unsafe(method(duration))]
        #[unsafe(method_family = none)]
        pub unsafe fn duration(&self) -> CMTime;

        #[cfg(feature = "objc2-core-foundation")]
        /// The size of the receiver as presented by the player.
        ///
        /// Indicates the size at which the visual portion of the item is presented by the player; can be scaled from this
        /// size to fit within the bounds of an AVPlayerLayer via its videoGravity property. Can be scaled arbitrarily for presentation
        /// via the frame property of an AVPlayerLayer.
        ///
        /// The value of this property will accord with the properties of the underlying media resource when the receiver becomes ready to play.
        /// Before the underlying media resource is sufficiently loaded, its value is CGSizeZero. Use key-value observation to obtain a valid
        /// presentationSize as soon as it becomes available. (Note that the value of presentationSize may remain CGSizeZero, e.g. for audio-only items.)
        #[unsafe(method(presentationSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentationSize(&self) -> CGSize;

        #[cfg(feature = "AVMetadataItem")]
        /// Provides an NSArray of AVMetadataItems representing the timed metadata encountered most recently within the media as it plays. May be nil.
        ///
        /// Notifications of changes are available via key-value observation.
        /// As an optimization for playback, AVPlayerItem may omit the processing of timed metadata when no observer of this property is registered. Therefore, when no such observer is registered, the value of the timedMetadata property may remain nil regardless of the contents of the underlying media.
        ///
        /// This property must be accessed on the main thread/queue.
        #[deprecated = "Use AVPlayerItemMetadataOutput to obtain timed metadata"]
        #[unsafe(method(timedMetadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn timedMetadata(&self) -> Option<Retained<NSArray<AVMetadataItem>>>;

        /// An array of property keys defined on AVAsset. The value of each key in the array is automatically loaded while the receiver is being made ready to play.
        ///
        /// The value of each key in automaticallyLoadedAssetKeys will be automatically be loaded by the underlying AVAsset before the receiver achieves the status AVPlayerItemStatusReadyToPlay; i.e. when the item is ready to play, the value of -[[AVPlayerItem asset] statusOfValueForKey:error:] will be AVKeyValueStatusLoaded. If loading of any of the values fails, the status of the AVPlayerItem will change instead to AVPlayerItemStatusFailed..
        #[unsafe(method(automaticallyLoadedAssetKeys))]
        #[unsafe(method_family = none)]
        pub unsafe fn automaticallyLoadedAssetKeys(&self) -> Retained<NSArray<NSString>>;
    );
}

/// AVPlayerItemRateAndSteppingSupport.
impl AVPlayerItem {
    extern_methods!(
        /// For releases of macOS prior to 10.9 and releases of iOS prior to 7.0, indicates whether the item can be played at rates greater than 1.0.
        /// Starting with macOS 10.9 and iOS 7.0, all AVPlayerItems with status AVPlayerItemReadyToPlay can be played at rates between 1.0 and 2.0, inclusive, even if canPlayFastForward is NO; for those releases canPlayFastForward indicates whether the item can be played at rates greater than 2.0.
        #[unsafe(method(canPlayFastForward))]
        #[unsafe(method_family = none)]
        pub unsafe fn canPlayFastForward(&self) -> bool;

        /// Indicates whether the item can be played at rates between 0.0 and 1.0
        #[unsafe(method(canPlaySlowForward))]
        #[unsafe(method_family = none)]
        pub unsafe fn canPlaySlowForward(&self) -> bool;

        /// Indicates whether the item can be played at rate -1.0
        #[unsafe(method(canPlayReverse))]
        #[unsafe(method_family = none)]
        pub unsafe fn canPlayReverse(&self) -> bool;

        /// Indicates whether the item can be played at rates less between 0.0 and -1.0
        #[unsafe(method(canPlaySlowReverse))]
        #[unsafe(method_family = none)]
        pub unsafe fn canPlaySlowReverse(&self) -> bool;

        /// Indicates whether the item can be played at rates less than -1.0
        #[unsafe(method(canPlayFastReverse))]
        #[unsafe(method_family = none)]
        pub unsafe fn canPlayFastReverse(&self) -> bool;

        /// Indicates whether the item supports stepping forward; see -stepByCount:. Once the item has become ready to play, the value of canStepForward does not change even when boundary conditions are reached, such as when the item's currentTime is its end time.
        #[unsafe(method(canStepForward))]
        #[unsafe(method_family = none)]
        pub unsafe fn canStepForward(&self) -> bool;

        /// Indicates whether the item supports stepping backward; see -stepByCount:. Once the item has become ready to play, the value of canStepBackward does not change even when boundary conditions are reached, such as when the item's currentTime is equal to kCMTimeZero.
        #[unsafe(method(canStepBackward))]
        #[unsafe(method_family = none)]
        pub unsafe fn canStepBackward(&self) -> bool;

        #[cfg(feature = "objc2-core-media")]
        /// Indicates how close to the latest content in a live stream playback will begin after a live start or a seek to kCMTimePositiveInfinity.
        ///
        /// For non-live assets this value is kCMTimeInvalid.
        #[unsafe(method(configuredTimeOffsetFromLive))]
        #[unsafe(method_family = none)]
        pub unsafe fn configuredTimeOffsetFromLive(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Setter for [`configuredTimeOffsetFromLive`][Self::configuredTimeOffsetFromLive].
        #[unsafe(method(setConfiguredTimeOffsetFromLive:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConfiguredTimeOffsetFromLive(
            &self,
            configured_time_offset_from_live: CMTime,
        );

        #[cfg(feature = "objc2-core-media")]
        /// A recommended value for configuredTimeOffsetFromLive, based on observed network conditions.
        ///
        /// For non-live assets this value is kCMTimeInvalid.
        #[unsafe(method(recommendedTimeOffsetFromLive))]
        #[unsafe(method_family = none)]
        pub unsafe fn recommendedTimeOffsetFromLive(&self) -> CMTime;

        /// Indicates that after the player spends a period of time buffering media, it will skip forward if necessary to restore the playhead's distance from the live edge of the presentation to what it was when buffering began.
        ///
        /// If the value of this property is YES and the player must buffer media from the network in order to resume playback, the player will seek forward if necessary before resuming playback to restore the position that the playhead had when rebuffering began, relative to the end of the current AVPlayerItem's seekableTimeRange.
        ///
        /// This behavior applies to media buffering that occurs as a consequence of starting playback, seeking, and recovering from a playback stall.
        ///
        /// Note that if the network cannot deliver media quickly enough to maintain the playback rate, playback may stall interminably.
        ///
        /// This property value has no effect if the asset is not a live stream. The default value of this property is NO.
        #[unsafe(method(automaticallyPreservesTimeOffsetFromLive))]
        #[unsafe(method_family = none)]
        pub unsafe fn automaticallyPreservesTimeOffsetFromLive(&self) -> bool;

        /// Setter for [`automaticallyPreservesTimeOffsetFromLive`][Self::automaticallyPreservesTimeOffsetFromLive].
        #[unsafe(method(setAutomaticallyPreservesTimeOffsetFromLive:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutomaticallyPreservesTimeOffsetFromLive(
            &self,
            automatically_preserves_time_offset_from_live: bool,
        );
    );
}

/// AVPlayerItemTimeControl.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Returns the current time of the item.
        ///
        /// Returns the current time of the item. Not key-value observable; use -[AVPlayer addPeriodicTimeObserverForInterval:queue:usingBlock:] instead.
        ///
        /// - Returns: A CMTime
        #[unsafe(method(currentTime))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentTime(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// The end time for forward playback.
        ///
        /// Specifies the time at which playback should end when the playback rate is positive (see AVPlayer's rate property).
        /// The default value is kCMTimeInvalid, which indicates that no end time for forward playback is specified.
        /// In this case, the effective end time for forward playback is the receiver's duration.
        ///
        /// When the end time is reached, the receiver will post AVPlayerItemDidPlayToEndTimeNotification and the AVPlayer will take
        /// the action indicated by the value of its actionAtItemEnd property (see AVPlayerActionAtItemEnd in AVPlayer.h).
        ///
        /// The value of this property has no effect on playback when the rate is negative.
        #[unsafe(method(forwardPlaybackEndTime))]
        #[unsafe(method_family = none)]
        pub unsafe fn forwardPlaybackEndTime(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Setter for [`forwardPlaybackEndTime`][Self::forwardPlaybackEndTime].
        #[unsafe(method(setForwardPlaybackEndTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setForwardPlaybackEndTime(&self, forward_playback_end_time: CMTime);

        #[cfg(feature = "objc2-core-media")]
        /// The end time for reverse playback.
        ///
        /// Specifies the time at which playback should end when the playback rate is negative (see AVPlayer's rate property).
        /// The default value is kCMTimeInvalid, which indicates that no end time for reverse playback is specified.
        /// In this case, the effective end time for reverse playback is kCMTimeZero.
        ///
        /// When the end time is reached, the receiver will post AVPlayerItemDidPlayToEndTimeNotification and the AVPlayer will take
        /// the action indicated by the value of its actionAtItemEnd property (see AVPlayerActionAtItemEnd in AVPlayer.h).
        ///
        /// The value of this property has no effect on playback when the rate is positive.
        #[unsafe(method(reversePlaybackEndTime))]
        #[unsafe(method_family = none)]
        pub unsafe fn reversePlaybackEndTime(&self) -> CMTime;

        #[cfg(feature = "objc2-core-media")]
        /// Setter for [`reversePlaybackEndTime`][Self::reversePlaybackEndTime].
        #[unsafe(method(setReversePlaybackEndTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setReversePlaybackEndTime(&self, reverse_playback_end_time: CMTime);

        /// This property provides a collection of time ranges that the player item can seek to. The ranges provided might be discontinous.
        ///
        /// Returns an NSArray of NSValues containing CMTimeRanges.
        #[unsafe(method(seekableTimeRanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekableTimeRanges(&self) -> Retained<NSArray<NSValue>>;

        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
        /// Moves the playback cursor and invokes the specified block when the seek operation has either been completed or been interrupted.
        ///
        /// Use this method to seek to a specified time for the item and to be notified when the seek operation is complete.
        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter
        /// set to NO. If the new request completes without being interrupted by another seek request or by any other operation the specified
        /// completion handler will be invoked with the finished parameter set to YES.
        /// If the seek time is outside of seekable time ranges as indicated by seekableTimeRanges property, the seek request will be cancelled and the completion handler will be invoked with the finished parameter set to NO.
        ///
        /// This method throws an exception if time is invalid or indefinite.
        ///
        /// - Parameter time:
        /// - Parameter completionHandler:
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(seekToTime:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToTime_completionHandler(
            &self,
            time: CMTime,
            completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
        );

        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
        /// Moves the playback cursor within a specified time bound and invokes the specified block when the seek operation has either been completed or been interrupted.
        ///
        /// Use this method to seek to a specified time for the item and to be notified when the seek operation is complete.
        /// The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency.
        /// Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay.
        /// Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly.
        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter set to NO. If the new
        /// request completes without being interrupted by another seek request or by any other operation the specified completion handler will be invoked with the
        /// finished parameter set to YES.
        /// If the seek time is outside of seekable time ranges as indicated by seekableTimeRanges property, the seek request will be cancelled and the completion handler will be invoked with the finished parameter set to NO.
        ///
        /// This method throws an exception if time is invalid or indefinite or if tolerance before or tolerance after is invalid or negative.
        ///
        /// - Parameter time:
        /// - Parameter toleranceBefore:
        /// - Parameter toleranceAfter:
        /// - Parameter completionHandler:
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToTime_toleranceBefore_toleranceAfter_completionHandler(
            &self,
            time: CMTime,
            tolerance_before: CMTime,
            tolerance_after: CMTime,
            completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
        );

        /// Cancel any pending seek requests and invoke the corresponding completion handlers if present.
        ///
        /// Use this method to cancel and release the completion handlers of pending seeks. The finished parameter of the completion handlers will
        /// be set to NO.
        #[unsafe(method(cancelPendingSeeks))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancelPendingSeeks(&self);

        /// If currentTime is mapped to a particular (real-time) date, return that date.
        ///
        /// - Returns: Returns the date of current playback, or nil if playback is not mapped to any date.
        #[unsafe(method(currentDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "block2")]
        /// move playhead to a point corresponding to a particular date, and invokes the specified block when the seek operation has either been completed or been interrupted.
        ///
        /// For playback content that is associated with a range of dates, move the
        /// playhead to point within that range and invokes the completion handler when the seek operation is complete.
        /// Will fail if the supplied date is outside the range or if the content is not associated with a range of dates.
        /// The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter
        /// set to NO. If the new request completes without being interrupted by another seek request or by any other operation, the specified
        /// completion handler will be invoked with the finished parameter set to YES.
        ///
        /// - Parameter date: The new position for the playhead.
        /// - Parameter completionHandler: The block to invoke when seek operation is complete
        ///
        /// - Returns: Returns true if the playhead was moved to the supplied date.
        ///
        /// # Safety
        ///
        /// `completion_handler` block must be sendable.
        #[unsafe(method(seekToDate:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToDate_completionHandler(
            &self,
            date: &NSDate,
            completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
        ) -> bool;

        /// Moves player's current item's current time forward or backward by the specified number of steps.
        ///
        /// The size of each step depends on the enabled AVPlayerItemTracks of the AVPlayerItem.
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
        ///
        /// - Parameter stepCount: The number of steps by which to move. A positive number results in stepping forward, a negative number in stepping backward.
        #[unsafe(method(stepByCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stepByCount(&self, step_count: NSInteger);

        #[cfg(feature = "objc2-core-media")]
        /// The item's timebase.
        ///
        /// You can examine the timebase to discover the relationship between the item's time and the source clock used for drift synchronization.
        /// This timebase is read-only; you cannot set its time or rate to affect playback.
        #[unsafe(method(timebase))]
        #[unsafe(method_family = none)]
        pub unsafe fn timebase(&self) -> Option<Retained<CMTimebase>>;
    );
}

/// AVPlayerItemVisualPresentation.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVVideoComposition")]
        /// Indicates the video composition settings to be applied during playback.
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
        ///
        /// This property throws an exception if a video composition is set with any of the following values:
        /// - renderSize, renderScale, or frameDuration is less than or equal to zero
        /// - sourceTrackIDForFrameTiming is less than or equal to zero
        /// - uses AVVideoCompositionCoreAnimationTool (works for offline rendering only)
        #[unsafe(method(videoComposition))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoComposition(&self) -> Option<Retained<AVVideoComposition>>;

        #[cfg(feature = "AVVideoComposition")]
        /// Setter for [`videoComposition`][Self::videoComposition].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setVideoComposition:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVideoComposition(&self, video_composition: Option<&AVVideoComposition>);

        #[cfg(feature = "AVVideoCompositing")]
        /// Indicates the custom video compositor instance.
        ///
        /// This property is nil if there is no video compositor, or if the internal video compositor is in use. This reference can be used to provide extra context to the custom video compositor instance if required. The value of this property can change as a result of setting the `videoComposition` property.
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this property must be accessed on the main thread/queue.
        #[unsafe(method(customVideoCompositor))]
        #[unsafe(method_family = none)]
        pub unsafe fn customVideoCompositor(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVVideoCompositing>>>;

        /// Indicates whether the item's timing follows the displayed video frame when seeking with a video composition
        ///
        /// By default, item timing is updated as quickly as possible, not waiting for media at new times to be rendered when seeking or
        /// during normal playback. The latency that occurs, for example, between the completion of a seek operation and the display of a
        /// video frame at a new time is negligible in most situations. However, when video compositions are in use, the processing of
        /// video for any particular time may introduce noticeable latency. Therefore it may be desirable when a video composition is in
        /// use for the item's timing be updated only after the video frame for a time has been displayed. This allows, for instance, an
        /// AVSynchronizedLayer associated with an AVPlayerItem to remain in synchronization with the displayed video and for the
        /// currentTime property to return the time of the displayed video.
        ///
        /// This property has no effect on items for which videoComposition is nil.
        #[unsafe(method(seekingWaitsForVideoCompositionRendering))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekingWaitsForVideoCompositionRendering(&self) -> bool;

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

        #[cfg(feature = "AVTextStyleRule")]
        /// An array of AVTextStyleRules representing text styling that can be applied to subtitles and other legible media.
        ///
        /// The styling information contained in each AVTextStyleRule object in the array is used only when no equivalent styling information is provided by the media resource being played. For example, if the text style rules specify Courier font but the media resource specifies Helvetica font, the text will be drawn using Helvetica font.
        ///
        /// This property has an effect only for tracks with media subtype kCMSubtitleFormatType_WebVTT.
        #[unsafe(method(textStyleRules))]
        #[unsafe(method_family = none)]
        pub unsafe fn textStyleRules(&self) -> Option<Retained<NSArray<AVTextStyleRule>>>;

        #[cfg(feature = "AVTextStyleRule")]
        /// Setter for [`textStyleRules`][Self::textStyleRules].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setTextStyleRules:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTextStyleRules(&self, text_style_rules: Option<&NSArray<AVTextStyleRule>>);

        #[cfg(feature = "AVVideoSettings")]
        /// Specifies the video aperture mode to apply during playback.
        ///
        /// See AVVideoApertureMode constants defined in AVVideoSettings.h. Default is AVVideoApertureModeCleanAperture.
        #[unsafe(method(videoApertureMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoApertureMode(&self) -> Retained<AVVideoApertureMode>;

        #[cfg(feature = "AVVideoSettings")]
        /// Setter for [`videoApertureMode`][Self::videoApertureMode].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setVideoApertureMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVideoApertureMode(&self, video_aperture_mode: &AVVideoApertureMode);

        /// Controls whether or not to apply the per frame HDR display metadata of the source during playback.
        #[unsafe(method(appliesPerFrameHDRDisplayMetadata))]
        #[unsafe(method_family = none)]
        pub unsafe fn appliesPerFrameHDRDisplayMetadata(&self) -> bool;

        /// Setter for [`appliesPerFrameHDRDisplayMetadata`][Self::appliesPerFrameHDRDisplayMetadata].
        #[unsafe(method(setAppliesPerFrameHDRDisplayMetadata:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAppliesPerFrameHDRDisplayMetadata(
            &self,
            applies_per_frame_hdr_display_metadata: bool,
        );
    );
}

/// AVPlayerItemAudioProcessing.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVAudioProcessingSettings")]
        /// Indicates the processing algorithm used to manage audio pitch at varying rates and for scaled audio edits.
        ///
        /// Constants for various time pitch algorithms, e.g. AVAudioTimePitchSpectral, are defined in AVAudioProcessingSettings.h.
        /// The default value for applications linked on or after iOS 15.0 or macOS 12.0 is AVAudioTimePitchAlgorithmTimeDomain. For iOS versions prior to 15.0 the default value is AVAudioTimePitchAlgorithmLowQualityZeroLatency.
        /// For macOS versions prior to 12.0 the default value is AVAudioTimePitchAlgorithmSpectral.
        #[unsafe(method(audioTimePitchAlgorithm))]
        #[unsafe(method_family = none)]
        pub unsafe fn audioTimePitchAlgorithm(&self) -> Retained<AVAudioTimePitchAlgorithm>;

        #[cfg(feature = "AVAudioProcessingSettings")]
        /// Setter for [`audioTimePitchAlgorithm`][Self::audioTimePitchAlgorithm].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAudioTimePitchAlgorithm:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAudioTimePitchAlgorithm(
            &self,
            audio_time_pitch_algorithm: &AVAudioTimePitchAlgorithm,
        );

        /// Indicates whether audio spatialization is allowed
        ///
        /// When audio spatialization is allowed for an AVPlayerItem, the AVPlayer may render multichannel audio if available even if the output device doesn't support multichannel audio on its own, via use of a synthetic channel layout. When audio spatialization is not allowed, the AVPlayer must render audio with a channel layout that best matches the capabilities of the output device. This property is not observable. Defaults to YES.
        #[deprecated = "Use allowedAudioSpatializationFormats instead"]
        #[unsafe(method(isAudioSpatializationAllowed))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAudioSpatializationAllowed(&self) -> bool;

        /// Setter for [`isAudioSpatializationAllowed`][Self::isAudioSpatializationAllowed].
        #[deprecated = "Use allowedAudioSpatializationFormats instead"]
        #[unsafe(method(setAudioSpatializationAllowed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAudioSpatializationAllowed(&self, audio_spatialization_allowed: bool);

        #[cfg(feature = "AVAudioProcessingSettings")]
        /// Indicates the source audio channel layouts allowed by the receiver for spatialization.
        ///
        /// Spatialization uses psychoacoustic methods to create a more immersive audio rendering when the content is played on specialized headphones and speaker arrangements. When an AVPlayerItem's allowedAudioSpatializationFormats property is set to AVAudioSpatializationFormatMonoAndStereo the AVPlayer will attempt to spatialize content tagged with a stereo channel layout, two-channel content with no layout specified as well as mono. It is considered incorrect to render a binaural recording with spatialization. A binaural recording is captured using two carefully placed microphones at each ear where the intent, when played on headphones, is to reproduce a naturally occurring spatial effect. Content tagged with a binaural channel layout will ignore this property value. When an AVPlayerItem's allowedAudioSpatializationFormats property is set to AVAudioSpatializationFormatMultichannel the AVPlayer will attempt to spatialize any decodable multichannel layout. Setting this property to AVAudioSpatializationFormatMonoStereoAndMultichannel indicates that the sender allows the AVPlayer to spatialize any decodable mono, stereo or multichannel layout. This property is not observable. The default value for this property with video content is AVAudioSpatializationFormatMonoStereoAndMultichannel. Otherwise, audio only content default value is AVAudioSpatializationFormatMultichannel.
        #[unsafe(method(allowedAudioSpatializationFormats))]
        #[unsafe(method_family = none)]
        pub unsafe fn allowedAudioSpatializationFormats(&self) -> AVAudioSpatializationFormats;

        #[cfg(feature = "AVAudioProcessingSettings")]
        /// Setter for [`allowedAudioSpatializationFormats`][Self::allowedAudioSpatializationFormats].
        #[unsafe(method(setAllowedAudioSpatializationFormats:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAllowedAudioSpatializationFormats(
            &self,
            allowed_audio_spatialization_formats: AVAudioSpatializationFormats,
        );

        #[cfg(feature = "AVAudioMix")]
        /// Indicates the audio mix parameters to be applied during playback
        ///
        /// The inputParameters of the AVAudioMix must have trackIDs that correspond to a track of the receiver's asset. Otherwise they will be ignored. (See AVAudioMix.h for the declaration of AVAudioMixInputParameters and AVPlayerItem's asset property.)
        #[unsafe(method(audioMix))]
        #[unsafe(method_family = none)]
        pub unsafe fn audioMix(&self) -> Option<Retained<AVAudioMix>>;

        #[cfg(feature = "AVAudioMix")]
        /// Setter for [`audioMix`][Self::audioMix].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAudioMix:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAudioMix(&self, audio_mix: Option<&AVAudioMix>);
    );
}

/// AVPlayerItemPlayability.
impl AVPlayerItem {
    extern_methods!(
        /// This property provides a collection of time ranges for which the player has the media data readily available. The ranges provided might be discontinuous.
        ///
        /// Returns an NSArray of NSValues containing CMTimeRanges.
        #[unsafe(method(loadedTimeRanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;

        /// Indicates whether the item will likely play through without stalling.
        ///
        /// This property communicates a prediction of playability. Factors considered in this prediction
        /// include I/O throughput and media decode performance. It is possible for playbackLikelyToKeepUp to
        /// indicate NO while the property playbackBufferFull indicates YES. In this event the playback buffer has
        /// reached capacity but there isn't the statistical data to support a prediction that playback is likely to
        /// keep up. It is left to the application programmer to decide to continue media playback or not.
        /// See playbackBufferFull below.
        #[unsafe(method(isPlaybackLikelyToKeepUp))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlaybackLikelyToKeepUp(&self) -> bool;

        /// Indicates that the internal media buffer is full and that further I/O is suspended.
        ///
        /// This property reports that the data buffer used for playback has reach capacity.
        /// Despite the playback buffer reaching capacity there might not exist sufficient statistical
        /// data to support a playbackLikelyToKeepUp prediction of YES. See playbackLikelyToKeepUp above.
        #[unsafe(method(isPlaybackBufferFull))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlaybackBufferFull(&self) -> bool;

        #[unsafe(method(isPlaybackBufferEmpty))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPlaybackBufferEmpty(&self) -> bool;

        /// Indicates whether the player item can use network resources to keep playback state up to date while paused
        ///
        /// For live streaming content, the player item may need to use extra networking and power resources to keep playback state up to date when paused. For example, when this property is set to YES, the seekableTimeRanges property will be periodically updated to reflect the current state of the live stream.
        ///
        /// For clients linked on or after macOS 10.11 or iOS 9.0, the default value is NO. To minimize power usage, avoid setting this property to YES when you do not need playback state to stay up to date while paused.
        #[unsafe(method(canUseNetworkResourcesForLiveStreamingWhilePaused))]
        #[unsafe(method_family = none)]
        pub unsafe fn canUseNetworkResourcesForLiveStreamingWhilePaused(&self) -> bool;

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

        /// Indicates the media duration the caller prefers the player to buffer from the network ahead of the playhead to guard against playback disruption.
        ///
        /// The value is in seconds. If it is set to 0, the player will choose an appropriate level of buffering for most use cases.
        /// Note that setting this property to a low value will increase the chance that playback will stall and re-buffer, while setting it to a high value will increase demand on system resources.
        /// Note that the system may buffer less than the value of this property in order to manage resource consumption.
        #[unsafe(method(preferredForwardBufferDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredForwardBufferDuration(&self) -> NSTimeInterval;

        /// Setter for [`preferredForwardBufferDuration`][Self::preferredForwardBufferDuration].
        #[unsafe(method(setPreferredForwardBufferDuration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredForwardBufferDuration(
            &self,
            preferred_forward_buffer_duration: NSTimeInterval,
        );
    );
}

/// These constants can be used in any combination as the value of variantPreferences.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avvariantpreferences?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVVariantPreferences(pub NSUInteger);
bitflags::bitflags! {
    impl AVVariantPreferences: NSUInteger {
/// Indicates that only the basic behaviors of the player for choosing among variants should be applied, including considerations of available bandwidth, compatibility of the indicated codec or codecs, the dimensions of visual output, and the number of available audio output channels.
        #[doc(alias = "AVVariantPreferenceNone")]
        const None = 0;
/// Directs the item to permit the use of variants with lossless audio encodings, if sufficient bandwidth is available for their use.
        #[doc(alias = "AVVariantPreferenceScalabilityToLosslessAudio")]
        const ScalabilityToLosslessAudio = 1<<0;
    }
}

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

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

/// AVPlayerItemVariantControl.
impl AVPlayerItem {
    extern_methods!(
        /// Indicates the desired limit of network bandwidth consumption for this item.
        ///
        /// Set preferredPeakBitRate to non-zero to indicate that the player should attempt to limit item playback to that bit rate, expressed in bits per second.
        ///
        /// If network bandwidth consumption cannot be lowered to meet the preferredPeakBitRate, it will be reduced as much as possible while continuing to play the item.
        #[unsafe(method(preferredPeakBitRate))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredPeakBitRate(&self) -> c_double;

        /// Setter for [`preferredPeakBitRate`][Self::preferredPeakBitRate].
        #[unsafe(method(setPreferredPeakBitRate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredPeakBitRate(&self, preferred_peak_bit_rate: c_double);

        /// Indicates the desired limit of network bandwidth consumption for this item over expensive networks.
        ///
        /// When preferredPeakBitRateForExpensiveNetworks is set to non-zero, the player will attempt to limit item playback to that bit rate
        /// when streaming over an expensive network, such as when using a cellular data plan. (See -[NWPath isExpensive])
        ///
        /// If network bandwidth consumption cannot be lowered to meet the preferredPeakBitRateForExpensiveNetworks, it will be reduced as much as possible while continuing to play the item.
        ///
        /// Note that preferredPeakBitRate still applies unconditionally. If preferredPeakBitRateForExpensiveNetworks is less restrictive (greater) than preferredPeakBitRate,
        /// preferredPeakBitRateForExpensiveNetworks has no practical effect.
        #[unsafe(method(preferredPeakBitRateForExpensiveNetworks))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredPeakBitRateForExpensiveNetworks(&self) -> c_double;

        /// Setter for [`preferredPeakBitRateForExpensiveNetworks`][Self::preferredPeakBitRateForExpensiveNetworks].
        #[unsafe(method(setPreferredPeakBitRateForExpensiveNetworks:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredPeakBitRateForExpensiveNetworks(
            &self,
            preferred_peak_bit_rate_for_expensive_networks: c_double,
        );

        #[cfg(feature = "objc2-core-foundation")]
        /// Indicates a preferred upper limit on the resolution of the video to be downloaded (or otherwise transferred) and rendered by the player.
        ///
        /// The default value is CGSizeZero, which indicates that the client enforces no limit on video resolution. Other values indicate a preferred maximum video resolution.
        /// It only applies to HTTP Live Streaming asset.
        #[unsafe(method(preferredMaximumResolution))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMaximumResolution(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredMaximumResolution`][Self::preferredMaximumResolution].
        #[unsafe(method(setPreferredMaximumResolution:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMaximumResolution(&self, preferred_maximum_resolution: CGSize);

        #[cfg(feature = "objc2-core-foundation")]
        /// Indicates a preferred upper limit on the resolution of the video to be downloaded that applies only when the download occurs over expensive networks.
        ///
        /// The default value is CGSizeZero, which indicates that the client enforces no limit on video resolution. Other values indicate a preferred maximum video resolution.
        /// This limit applies only when streaming over an expensive network, such as when using a cellular data plan. (See -[NWPath isExpensive])
        ///
        /// It only applies to HTTP Live Streaming asset.
        ///
        /// Note that preferredMaximumResolution still applies unconditionally. If preferredMaximumResolutionForExpensiveNetworks is less restrictive (higher resolution)
        /// than preferredMaximumResolution, preferredMaximumResolutionForExpensiveNetworks has no practical effect.
        #[unsafe(method(preferredMaximumResolutionForExpensiveNetworks))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredMaximumResolutionForExpensiveNetworks(&self) -> CGSize;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`preferredMaximumResolutionForExpensiveNetworks`][Self::preferredMaximumResolutionForExpensiveNetworks].
        #[unsafe(method(setPreferredMaximumResolutionForExpensiveNetworks:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredMaximumResolutionForExpensiveNetworks(
            &self,
            preferred_maximum_resolution_for_expensive_networks: CGSize,
        );

        /// Directs the player to start playback with the first eligible variant that appears in the stream's master playlist.
        ///
        /// This property influences AVPlayer's algorithm for selecting which of the eligible variant streams in an HTTP Live Streaming master playlist is selected when playback first begins.
        /// In all cases, AVPlayer may switch to other variants during playback.
        ///
        /// On releases prior to macOS 10.15, iOS 13, tvOS 13 and watchOS 6, AVPlayer starts HLS playback with the first eligible variant in the master playlist.
        /// On releases starting with macOS 10.15, iOS 13, tvOS 13 and watchOS 6, AVPlayer starts HLS playback by choosing an initial variant that optimizes the startup experience.
        /// On releases starting with macOS 11.0, iOS 14, tvOS 14 and watchOS 7, applications may set this property to YES to request that AVPlayer use the previous behaviour of using the first eligible variant in the master playlist. This would be appropriate, for example, for applications which wish to control initial variant selection by ordering the variants in the master playlist.
        ///
        /// Note that changing this property may impact stream startup performance and quality. In order to be effective this property must be set before initial variant selection occurs.
        /// This property only applies to HTTP Live Streaming assets. The default value of this property is NO.
        #[unsafe(method(startsOnFirstEligibleVariant))]
        #[unsafe(method_family = none)]
        pub unsafe fn startsOnFirstEligibleVariant(&self) -> bool;

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

        /// Indicates preferences for variant switching.
        ///
        /// Changing variant preferences during playback may result in a variant switch.
        /// The default value is AVVariantPreferenceNone.
        #[unsafe(method(variantPreferences))]
        #[unsafe(method_family = none)]
        pub unsafe fn variantPreferences(&self) -> AVVariantPreferences;

        /// Setter for [`variantPreferences`][Self::variantPreferences].
        #[unsafe(method(setVariantPreferences:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVariantPreferences(&self, variant_preferences: AVVariantPreferences);
    );
}

/// AVPlayerItemMediaSelection.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Selects the media option described by the specified instance of AVMediaSelectionOption in the specified AVMediaSelectionGroup and deselects all other options in that group.
        ///
        /// If the specified media selection option isn't a member of the specified media selection group, no change in presentation state will result.
        /// If the value of the property allowsEmptySelection of the AVMediaSelectionGroup is YES, you can pass nil for mediaSelectionOption to deselect
        /// all media selection options in the group.
        /// Note that if multiple options within a group meet your criteria for selection according to locale or other considerations, and if these options are otherwise indistinguishable to you according to media characteristics that are meaningful for your application, content is typically authored so that the first available option that meets your criteria is appropriate for selection.
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
        ///
        /// - Parameter mediaSelectionOption: The option to select.
        /// - Parameter mediaSelectionGroup: The media selection group, obtained from the receiver's asset, that contains the specified option.
        #[unsafe(method(selectMediaOption:inMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectMediaOption_inMediaSelectionGroup(
            &self,
            media_selection_option: Option<&AVMediaSelectionOption>,
            media_selection_group: &AVMediaSelectionGroup,
        );

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Selects the media option in the specified media selection group that best matches the AVPlayer's current automatic selection criteria. Also allows automatic selection to be re-applied to the specified group subsequently if the relevant criteria are changed.
        ///
        /// Has no effect unless the appliesMediaSelectionCriteriaAutomatically property of the associated AVPlayer is YES and unless automatic media selection has previously been overridden via -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:].
        ///
        /// Before macOS 13, iOS 16, tvOS 16, and watchOS 9, this method must be invoked on the main thread/queue.
        ///
        /// - Parameter mediaSelectionGroup: The media selection group, obtained from the receiver's asset, that contains the specified option.
        #[unsafe(method(selectMediaOptionAutomaticallyInMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectMediaOptionAutomaticallyInMediaSelectionGroup(
            &self,
            media_selection_group: &AVMediaSelectionGroup,
        );

        #[cfg(feature = "AVMediaSelection")]
        /// Provides an instance of AVMediaSelection carrying current selections for each of the receiver's media selection groups.
        #[unsafe(method(currentMediaSelection))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentMediaSelection(&self) -> Retained<AVMediaSelection>;
    );
}

/// AVPlayerItemCustomMediaSelectionScheme.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Indicates the AVCustomMediaSelectionSchemes of AVMediaSelectionGroups of the receiver's asset with which an associated UI implementation should configure its interface for media selection.
        ///
        /// Recommended usage: if use of a custom media selection scheme is desired, set this property before either replacing an AVPlayer's current item with the receiver or adding the receiver to an AVQueuePlayer's play queue. This will satisfy requirements of UI implementations that commit to a configuration of UI elements as the receiver becomes ready to play.
        #[unsafe(method(preferredCustomMediaSelectionSchemes))]
        #[unsafe(method_family = none)]
        pub unsafe fn preferredCustomMediaSelectionSchemes(
            &self,
        ) -> Retained<NSArray<AVCustomMediaSelectionScheme>>;

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Setter for [`preferredCustomMediaSelectionSchemes`][Self::preferredCustomMediaSelectionSchemes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setPreferredCustomMediaSelectionSchemes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPreferredCustomMediaSelectionSchemes(
            &self,
            preferred_custom_media_selection_schemes: &NSArray<AVCustomMediaSelectionScheme>,
        );

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// When the associated AVPlayer's appliesMediaSelectionCriteriaAutomatically property is set to YES, configures the player item to prefer a particular language, replacing any previous preference for available languages of the specified group's custom media selection scheme.
        ///
        /// Overrides preferences for languages specified by the AVPlayer's current media selection criteria.
        /// This method has no effect when the associated AVPlayer's appliesMediaSelectionCriteriaAutomatically property has a value of NO, in which case you must use -selectMediaOption:inMediaSelectionGroup: instead in order to alter the presentation state of the media.
        ///
        /// - Parameter languages: A BCP 47 language tag, typically obtained from the availableLanguages of the AVCustomMediaSelectionScheme of the specified AVMediaSelectionGroup.
        /// - Parameter mediaSelectionGroup: The media selection group, obtained from the receiver's asset, to which the specified setting is to be applied.
        #[unsafe(method(selectMediaPresentationLanguage:forMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectMediaPresentationLanguage_forMediaSelectionGroup(
            &self,
            language: &NSString,
            media_selection_group: &AVMediaSelectionGroup,
        );

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Returns the selected media presentation language for the specified media selection group, if any language has previously been selected via use of -selectMediaPresentationLanguages:forMediaSelectionGroup:.
        ///
        /// - Parameter mediaSelectionGroup: The media selection group, obtained from the receiver's asset, for which the selected media presentation language is requested.
        #[unsafe(method(selectedMediaPresentationLanguageForMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedMediaPresentationLanguageForMediaSelectionGroup(
            &self,
            media_selection_group: &AVMediaSelectionGroup,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// When the associated AVPlayer's appliesMediaSelectionCriteriaAutomatically property is set to YES, configures the player item to prefer a particular presentation setting, replacing any previous preference for settings of the same media presentation selector.
        ///
        /// Note that preferences for media characteristics indicated by selected AVMediaPresentationSettings are treated as supplemental to the associated AVPlayer's media selection criteria for the AVMediaSelectionGroup. An AVPlayer's default media selection criteria can also indicate preferences for media characteristics, such as those indicating the availability of accessibility affordances such as audio descriptions, and these media characteristics can be left up to the AVPlayer to manage even when an AVCustomMediaSelectionScheme is in use. But if you wish to do so, you can use AVMediaPresentationSettings offered by a AVCustomMediaSelectionScheme in combination with custom AVPlayerMediaSelectionCriteria.
        /// If the specified setting isn't offered by an AVMediaPresentationSelector of the AVCustomMediaSelectionScheme of the specified AVMediaSelectionGroup, no change in the presentation of the media will result.
        /// This method has no effect when the associated AVPlayer's appliesMediaSelectionCriteriaAutomatically property has a value of NO, in which case you must use -selectMediaOption:inMediaSelectionGroup: instead in order to alter the presentation state of the media.
        ///
        /// - Parameter mediaPresentationSetting: The setting to select.
        /// - Parameter mediaSelectionGroup: The media selection group, obtained from the receiver's asset, to which the specified setting is to be applied.
        #[unsafe(method(selectMediaPresentationSetting:forMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectMediaPresentationSetting_forMediaSelectionGroup(
            &self,
            media_presentation_setting: &AVMediaPresentationSetting,
            media_selection_group: &AVMediaSelectionGroup,
        );

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Indicates the media presentation settings that have most recently been selected for each AVMediaPresentationSelector of the AVCustomMediaSelectionScheme of the specified AVMediaSelectionGroup.
        ///
        /// - Parameter mediaSelectionGroup: An AVMediaSelectionGroup obtained from the receiver's asset for which the currently selected media presentation settings are desired.
        ///
        /// - Returns: A dictionary with AVMediaPresentationSelectors as keys and AVMediaPresentationSettings as values, providing the most recently selected setting for each selector or, if no setting has previously been selected, NSNull.
        #[unsafe(method(selectedMediaPresentationSettingsForMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedMediaPresentationSettingsForMediaSelectionGroup(
            &self,
            media_selection_group: &AVMediaSelectionGroup,
        ) -> Retained<NSDictionary<AVMediaPresentationSelector, AnyObject>>;

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Indicates the media presentation settings with media characteristics that are possessed by the currently selected AVMediaSelectionOption in the specified AVMediaSelectionGroup.
        ///
        /// Effective media presentation settings can differ from the currently effective media presentation settings if no AVMediaSelectionOption of the specified AVMediaSelectionGroup with the currently selected media presentation language possesses all of the characteristics associated with the currently selected settings.
        /// A value of NSNull for an AVMediaPresentationSelector can occur if either the content is inappropriately authored for the use of the AVCustomMediaSelectionScheme or if the currently selected AVMediaSelectionOption has been selected by means other than through the use of AVMediaPresentationSettings.
        ///
        /// - Parameter mediaSelectionGroup: An AVMediaSelectionGroup obtained from the receiver's asset for which the currently effective media presentation settings are desired.
        ///
        /// - Returns: A dictionary with AVMediaPresentationSelectors as keys and AVMediaPresentationSettings as values, unless the AVMediaSelectionOption currently selected in the group possesses none of the characteristics associated with the selector's settings. In that case the dictionary value will be NSNull.
        #[unsafe(method(effectiveMediaPresentationSettingsForMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn effectiveMediaPresentationSettingsForMediaSelectionGroup(
            &self,
            media_selection_group: &AVMediaSelectionGroup,
        ) -> Retained<NSDictionary<AVMediaPresentationSelector, AnyObject>>;
    );
}

/// AVPlayerItemLogging.
impl AVPlayerItem {
    extern_methods!(
        /// Returns an object that represents a snapshot of the network access log. Can be nil.
        ///
        /// An AVPlayerItemAccessLog provides methods to retrieve the network access log in a format suitable for serialization.
        /// If nil is returned then there is no logging information currently available for this AVPlayerItem.
        /// An AVPlayerItemNewAccessLogEntryNotification will be posted when new logging information becomes available. However, accessLog might already return a non-nil value even before the first notification is posted.
        ///
        /// In certain situations, this method may temporarily block the calling thread during the ongoing log collection process.
        /// It is strongly recommended that the caller take appropriate measures to prevent blocking essential services such as the user interface, for example, by avoiding calling this method in the main thread.
        ///
        /// - Returns: An autoreleased AVPlayerItemAccessLog instance.
        #[unsafe(method(accessLog))]
        #[unsafe(method_family = none)]
        pub unsafe fn accessLog(&self) -> Option<Retained<AVPlayerItemAccessLog>>;

        /// Returns an object that represents a snapshot of the error log. Can be nil.
        ///
        /// An AVPlayerItemErrorLog provides methods to retrieve the error log in a format suitable for serialization.
        /// If nil is returned then there is no logging information currently available for this AVPlayerItem.
        ///
        /// In certain situations, this method may temporarily block the calling thread during the ongoing log collection process.
        /// It is strongly recommended that the caller take appropriate measures to prevent blocking essential services such as the user interface, for example, by avoiding calling this method in the main thread.
        ///
        /// - Returns: An autoreleased AVPlayerItemErrorLog instance.
        #[unsafe(method(errorLog))]
        #[unsafe(method_family = none)]
        pub unsafe fn errorLog(&self) -> Option<Retained<AVPlayerItemErrorLog>>;
    );
}

/// AVPlayerItemOutputs.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVPlayerItemOutput")]
        /// Adds the specified instance of AVPlayerItemOutput to the receiver's collection of outputs.
        ///
        /// The class of AVPlayerItemOutput provided dictates the data structure that decoded samples are vended in.
        ///
        /// When an AVPlayerItemOutput is associated with an AVPlayerItem, samples are provided for a media type in accordance with the rules for mixing, composition, or exclusion that the AVPlayer honors among multiple enabled tracks of that media type for its own rendering purposes. For example, video media will be composed according to the instructions provided via AVPlayerItem.videoComposition, if present. Audio media will be mixed according to the parameters provided via AVPlayerItem.audioMix, if present.
        ///
        /// - Parameter output: An instance of AVPlayerItemOutput
        #[unsafe(method(addOutput:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addOutput(&self, output: &AVPlayerItemOutput);

        #[cfg(feature = "AVPlayerItemOutput")]
        /// Removes the specified instance of AVPlayerItemOutput from the receiver's collection of outputs.
        ///
        /// - Parameter output: An instance of AVPlayerItemOutput
        #[unsafe(method(removeOutput:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeOutput(&self, output: &AVPlayerItemOutput);

        #[cfg(feature = "AVPlayerItemOutput")]
        /// The collection of associated outputs.
        #[unsafe(method(outputs))]
        #[unsafe(method_family = none)]
        pub unsafe fn outputs(&self) -> Retained<NSArray<AVPlayerItemOutput>>;
    );
}

/// AVPlayerItemMediaDataCollectors.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "AVPlayerItemMediaDataCollector")]
        /// Adds the specified instance of AVPlayerItemMediaDataCollector to the receiver's collection of mediaDataCollectors.
        ///
        /// This method may incur additional I/O to collect the requested media data asynchronously.
        ///
        /// - Parameter collector: An instance of AVPlayerItemMediaDataCollector
        #[unsafe(method(addMediaDataCollector:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addMediaDataCollector(&self, collector: &AVPlayerItemMediaDataCollector);

        #[cfg(feature = "AVPlayerItemMediaDataCollector")]
        /// Removes the specified instance of AVPlayerItemMediaDataCollector from the receiver's collection of mediaDataCollectors.
        ///
        /// - Parameter collector: An instance of AVPlayerItemMediaDataCollector
        #[unsafe(method(removeMediaDataCollector:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeMediaDataCollector(&self, collector: &AVPlayerItemMediaDataCollector);

        #[cfg(feature = "AVPlayerItemMediaDataCollector")]
        /// The collection of associated mediaDataCollectors.
        #[unsafe(method(mediaDataCollectors))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaDataCollectors(
            &self,
        ) -> Retained<NSArray<AVPlayerItemMediaDataCollector>>;
    );
}

/// AVPlayerItemDeprecated.
impl AVPlayerItem {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Moves the playback cursor.
        ///
        /// Use this method to seek to a specified time for the item.
        /// The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:.
        /// If the seek time is outside of seekable time ranges as indicated by seekableTimeRanges property, the seek request will be cancelled.
        ///
        /// - Parameter time:
        #[deprecated = "Use -seekToTime:completionHandler:, passing nil for the completionHandler if you don't require notification of completion"]
        #[unsafe(method(seekToTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToTime(&self, time: CMTime);

        #[cfg(feature = "objc2-core-media")]
        /// Moves the playback cursor within a specified time bound.
        ///
        /// Use this method to seek to a specified time for the item.
        /// The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency.
        /// Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay.
        /// Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly.
        /// Seeking is constrained by the collection of seekable time ranges. If you seek to a time outside all of the seekable ranges the seek will result in a currentTime
        /// within the seekable ranges.
        /// If the seek time is outside of seekable time ranges as indicated by seekableTimeRanges property, the seek request will be cancelled.
        ///
        /// - Parameter time:
        /// - Parameter toleranceBefore:
        /// - Parameter toleranceAfter:
        #[deprecated = "Use -seekToTime:toleranceBefore:toleranceAfter:completionHandler:, passing nil for the completionHandler if you don't require notification of completion"]
        #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToTime_toleranceBefore_toleranceAfter(
            &self,
            time: CMTime,
            tolerance_before: CMTime,
            tolerance_after: CMTime,
        );

        /// move playhead to a point corresponding to a particular date.
        ///
        /// For playback content that is associated with a range of dates, move the
        /// playhead to point within that range. Will fail if the supplied date is outside
        /// the range or if the content is not associated with a range of dates.
        ///
        /// - Parameter date: The new position for the playhead.
        ///
        /// - Returns: Returns true if the playhead was moved to the supplied date.
        #[deprecated = "Use -seekToDate:completionHandler:, passing nil for the completionHandler if you don't require notification of completion"]
        #[unsafe(method(seekToDate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn seekToDate(&self, date: &NSDate) -> bool;

        #[cfg(feature = "AVMediaSelectionGroup")]
        /// Indicates the media selection option that's currently selected from the specified group. May be nil.
        ///
        /// If the value of the property allowsEmptySelection of the AVMediaSelectionGroup is YES, the currently selected option in the group may be nil.
        ///
        /// - Parameter mediaSelectionGroup: A media selection group obtained from the receiver's asset.
        ///
        /// - Returns: An instance of AVMediaSelectionOption that describes the currently selection option in the group.
        #[deprecated = "Use currentMediaSelection to obtain an instance of AVMediaSelection, which encompasses the currently selected AVMediaSelectionOption in each of the available AVMediaSelectionGroups"]
        #[unsafe(method(selectedMediaOptionInMediaSelectionGroup:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectedMediaOptionInMediaSelectionGroup(
            &self,
            media_selection_group: &AVMediaSelectionGroup,
        ) -> Option<Retained<AVMediaSelectionOption>>;
    );
}

extern_class!(
    /// An AVPlayerItemAccessLog provides methods to retrieve the access log in a format suitable for serialization.
    ///
    /// An AVPlayerItemAccessLog acculumulates key metrics about network playback and presents them as a collection
    /// of AVPlayerItemAccessLogEvent instances. Each AVPlayerItemAccessLogEvent instance collates the data
    /// that relates to each uninterrupted period of playback.
    ///
    /// 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/avplayeritemaccesslog?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemAccessLog;
);

unsafe impl Send for AVPlayerItemAccessLog {}

unsafe impl Sync for AVPlayerItemAccessLog {}

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

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

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

impl AVPlayerItemAccessLog {
    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>;

        /// Serializes an AVPlayerItemAccessLog in the Extended Log File Format.
        ///
        /// This method converts the webserver access log into a textual format that conforms to the
        /// W3C Extended Log File Format for web server log files.
        /// For more information see: http://www.w3.org/pub/WWW/TR/WD-logfile.html
        ///
        /// - Returns: An autoreleased NSData instance.
        #[unsafe(method(extendedLogData))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendedLogData(&self) -> Option<Retained<NSData>>;

        /// Returns the NSStringEncoding for extendedLogData, see above.
        ///
        /// A string suitable for console output is obtainable by:
        /// [[NSString alloc] initWithData:[myLog extendedLogData] encoding:[myLog extendedLogDataStringEncoding]]
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(extendedLogDataStringEncoding))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendedLogDataStringEncoding(&self) -> NSStringEncoding;

        /// An ordered collection of AVPlayerItemAccessLogEvent instances.
        ///
        /// An ordered collection of AVPlayerItemAccessLogEvent instances that represent the chronological
        /// sequence of events contained in the access log.
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(events))]
        #[unsafe(method_family = none)]
        pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerItemAccessLogEvent>>;
    );
}

extern_class!(
    /// An AVPlayerItemErrorLog provides methods to retrieve the error log in a format suitable for serialization.
    ///
    /// An AVPlayerItemErrorLog provides data to identify if, and when, network resource playback failures occured.
    ///
    /// 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/avplayeritemerrorlog?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemErrorLog;
);

unsafe impl Send for AVPlayerItemErrorLog {}

unsafe impl Sync for AVPlayerItemErrorLog {}

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

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

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

impl AVPlayerItemErrorLog {
    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>;

        /// Serializes an AVPlayerItemErrorLog in the Extended Log File Format.
        ///
        /// This method converts the webserver error log into a textual format that conforms to the
        /// W3C Extended Log File Format for web server log files.
        /// For more information see: http://www.w3.org/pub/WWW/TR/WD-logfile.html
        ///
        /// - Returns: An autoreleased NSData instance.
        #[unsafe(method(extendedLogData))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendedLogData(&self) -> Option<Retained<NSData>>;

        /// Returns the NSStringEncoding for extendedLogData, see above.
        ///
        /// A string suitable for console output is obtainable by:
        /// [[NSString alloc] initWithData:[myLog extendedLogData] encoding:[myLog extendedLogDataStringEncoding]]
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(extendedLogDataStringEncoding))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendedLogDataStringEncoding(&self) -> NSStringEncoding;

        /// An ordered collection of AVPlayerItemErrorLogEvent instances.
        ///
        /// An ordered collection of AVPlayerItemErrorLogEvent instances that represent the chronological
        /// sequence of events contained in the error log.
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(events))]
        #[unsafe(method_family = none)]
        pub unsafe fn events(&self) -> Retained<NSArray<AVPlayerItemErrorLogEvent>>;
    );
}

extern_class!(
    /// An AVPlayerItemAccessLogEvent represents a single log entry.
    ///
    /// An AVPlayerItemAccessLogEvent provides named properties for accessing the data
    /// fields of each log event. None of the properties of this class are observable.
    ///
    /// 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/avplayeritemaccesslogevent?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemAccessLogEvent;
);

unsafe impl Send for AVPlayerItemAccessLogEvent {}

unsafe impl Sync for AVPlayerItemAccessLogEvent {}

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

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

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

impl AVPlayerItemAccessLogEvent {
    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>;

        /// A count of media segments downloaded.
        ///
        /// Value is negative if unknown. A count of media segments downloaded from the server to this client. Corresponds to "sc-count".
        /// This property is not observable.
        /// This property is deprecated. Use numberOfMediaRequests instead.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[deprecated]
        #[unsafe(method(numberOfSegmentsDownloaded))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfSegmentsDownloaded(&self) -> NSInteger;

        /// A count of media read requests.
        ///
        /// Value is negative if unknown. A count of media read requests from the server to this client. Corresponds to "sc-count".
        /// For HTTP live Streaming, a count of media segments downloaded from the server to this client.
        /// For progressive-style HTTP media downloads, a count of HTTP GET (byte-range) requests for the resource.
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfMediaRequests))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfMediaRequests(&self) -> NSInteger;

        /// The date/time at which playback began for this event. Can be nil.
        ///
        /// If nil is returned the date is unknown. Corresponds to "date".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(playbackStartDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackStartDate(&self) -> Option<Retained<NSDate>>;

        /// The URI of the playback item. Can be nil.
        ///
        /// If nil is returned the URI is unknown. Corresponds to "uri".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(URI))]
        #[unsafe(method_family = none)]
        pub unsafe fn URI(&self) -> Option<Retained<NSString>>;

        /// The IP address of the server that was the source of the last delivered media segment. Can be nil.
        ///
        /// If nil is returned the address is unknown. Can be either an IPv4 or IPv6 address. Corresponds to "s-ip".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(serverAddress))]
        #[unsafe(method_family = none)]
        pub unsafe fn serverAddress(&self) -> Option<Retained<NSString>>;

        /// A count of changes to the property serverAddress, see above, over the last uninterrupted period of playback.
        ///
        /// Value is negative if unknown. Corresponds to "s-ip-changes".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfServerAddressChanges))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfServerAddressChanges(&self) -> NSInteger;

        /// A GUID that identifies the playback session. This value is used in HTTP requests. Can be nil.
        ///
        /// If nil is returned the GUID is unknown. Corresponds to "cs-guid".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(playbackSessionID))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackSessionID(&self) -> Option<Retained<NSString>>;

        /// An offset into the playlist where the last uninterrupted period of playback began. Measured in seconds.
        ///
        /// Value is negative if unknown. Corresponds to "c-start-time".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(playbackStartOffset))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackStartOffset(&self) -> NSTimeInterval;

        /// The accumulated duration of the media downloaded. Measured in seconds.
        ///
        /// Value is negative if unknown. Corresponds to "c-duration-downloaded".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(segmentsDownloadedDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn segmentsDownloadedDuration(&self) -> NSTimeInterval;

        /// The accumulated duration of the media played. Measured in seconds.
        ///
        /// Value is negative if unknown. Corresponds to "c-duration-watched".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(durationWatched))]
        #[unsafe(method_family = none)]
        pub unsafe fn durationWatched(&self) -> NSTimeInterval;

        /// The total number of playback stalls encountered.
        ///
        /// Value is negative if unknown. Corresponds to "c-stalls".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfStalls))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfStalls(&self) -> NSInteger;

        /// The accumulated number of bytes transferred.
        ///
        /// Value is negative if unknown. Corresponds to "bytes".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfBytesTransferred))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfBytesTransferred(&self) -> c_longlong;

        /// The accumulated duration of active network transfer of bytes. Measured in seconds.
        ///
        /// Value is negative if unknown. Corresponds to "c-transfer-duration".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(transferDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn transferDuration(&self) -> NSTimeInterval;

        /// The empirical throughput across all media downloaded. Measured in bits per second.
        ///
        /// Value is negative if unknown. Corresponds to "c-observed-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(observedBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn observedBitrate(&self) -> c_double;

        /// The throughput required to play the stream, as advertised by the server. Measured in bits per second.
        ///
        /// Value is negative if unknown. Corresponds to "sc-indicated-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(indicatedBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn indicatedBitrate(&self) -> c_double;

        /// Average throughput required to play the stream, as advertised by the server. Measured in bits per second.
        ///
        /// Value is negative if unknown. Corresponds to "sc-indicated-avg-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(indicatedAverageBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn indicatedAverageBitrate(&self) -> c_double;

        /// The average bitrate of video track if it is unmuxed. Average bitrate of combined content if muxed. Measured in bits per second.
        ///
        /// Value is negative if unknown. Corresponds to "c-avg-video-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(averageVideoBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn averageVideoBitrate(&self) -> c_double;

        /// The average bitrate of audio track. This is not available if audio is muxed with video. Measured in bits per second.
        ///
        /// Value is negative if unknown. Corresponds to "c-avg-audio-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(averageAudioBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn averageAudioBitrate(&self) -> c_double;

        /// The total number of dropped video frames.
        ///
        /// Value is negative if unknown. Corresponds to "c-frames-dropped".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfDroppedVideoFrames))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfDroppedVideoFrames(&self) -> NSInteger;

        /// The accumulated duration until player item is ready to play. Measured in seconds.
        ///
        /// Value is negative if unknown. Corresponds to "c-startup-time".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(startupTime))]
        #[unsafe(method_family = none)]
        pub unsafe fn startupTime(&self) -> NSTimeInterval;

        /// The total number of times the download of the segments took too long.
        ///
        /// Value is negative if unknown. Corresponds to "c-overdue".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(downloadOverdue))]
        #[unsafe(method_family = none)]
        pub unsafe fn downloadOverdue(&self) -> NSInteger;

        /// Maximum observed segment download bit rate.
        ///
        /// Value is negative if unknown. Corresponds to "c-observed-max-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[deprecated = "Use observedBitrateStandardDeviation to monitor variance in network bitrate."]
        #[unsafe(method(observedMaxBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn observedMaxBitrate(&self) -> c_double;

        /// Minimum observed segment download bit rate.
        ///
        /// Value is negative if unknown. Corresponds to "c-observed-min-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[deprecated = "Use observedBitrateStandardDeviation to monitor variance in network bitrate."]
        #[unsafe(method(observedMinBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn observedMinBitrate(&self) -> c_double;

        /// Standard deviation of observed segment download bit rates.
        ///
        /// Value is negative if unknown. Corresponds to "c-observed-bitrate-sd".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(observedBitrateStandardDeviation))]
        #[unsafe(method_family = none)]
        pub unsafe fn observedBitrateStandardDeviation(&self) -> c_double;

        /// Playback type (LIVE, VOD, FILE).
        ///
        /// If nil is returned the playback type is unknown. Corresponds to "s-playback-type".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(playbackType))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackType(&self) -> Option<Retained<NSString>>;

        /// Number of network read requests over WWAN.
        ///
        /// Value is negative if unknown. Corresponds to "sc-wwan-count".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(mediaRequestsWWAN))]
        #[unsafe(method_family = none)]
        pub unsafe fn mediaRequestsWWAN(&self) -> NSInteger;

        /// Bandwidth that caused us to switch (up or down).
        ///
        /// Value is negative if unknown. Corresponds to "c-switch-bitrate".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(switchBitrate))]
        #[unsafe(method_family = none)]
        pub unsafe fn switchBitrate(&self) -> c_double;
    );
}

extern_class!(
    /// An AVPlayerItemErrorLogEvent represents a single log entry.
    ///
    /// An AVPlayerItemErrorLogEvent provides named properties for accessing the data
    /// fields of each log event. None of the properties of this class are observable.
    ///
    /// 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/avplayeritemerrorlogevent?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct AVPlayerItemErrorLogEvent;
);

unsafe impl Send for AVPlayerItemErrorLogEvent {}

unsafe impl Sync for AVPlayerItemErrorLogEvent {}

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

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

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

impl AVPlayerItemErrorLogEvent {
    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>;

        /// The date and time when the error occured. Can be nil.
        ///
        /// If nil is returned the date is unknown. Corresponds to "date".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(date))]
        #[unsafe(method_family = none)]
        pub unsafe fn date(&self) -> Option<Retained<NSDate>>;

        /// The URI of the playback item. Can be nil.
        ///
        /// If nil is returned the URI is unknown. Corresponds to "uri".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(URI))]
        #[unsafe(method_family = none)]
        pub unsafe fn URI(&self) -> Option<Retained<NSString>>;

        /// The IP address of the server that was the source of the error. Can be nil.
        ///
        /// If nil is returned the address is unknown. Can be either an IPv4 or IPv6 address. Corresponds to "s-ip".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(serverAddress))]
        #[unsafe(method_family = none)]
        pub unsafe fn serverAddress(&self) -> Option<Retained<NSString>>;

        /// A GUID that identifies the playback session. This value is used in HTTP requests. Can be nil.
        ///
        /// If nil is returned the GUID is unknown. Corresponds to "cs-guid".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(playbackSessionID))]
        #[unsafe(method_family = none)]
        pub unsafe fn playbackSessionID(&self) -> Option<Retained<NSString>>;

        /// A unique error code identifier.
        ///
        /// Corresponds to "status".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(errorStatusCode))]
        #[unsafe(method_family = none)]
        pub unsafe fn errorStatusCode(&self) -> NSInteger;

        /// The domain of the error.
        ///
        /// Corresponds to "domain".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(errorDomain))]
        #[unsafe(method_family = none)]
        pub unsafe fn errorDomain(&self) -> Retained<NSString>;

        /// A description of the error encountered. Can be nil.
        ///
        /// If nil is returned further information is not available. Corresponds to "comment".
        /// This property is not observable.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(errorComment))]
        #[unsafe(method_family = none)]
        pub unsafe fn errorComment(&self) -> Option<Retained<NSString>>;

        /// The HTTP header fields returned by the server, if an HTTP response was received as part of this error.
        ///
        /// See -[NSHTTPURLResponse allHeaderFields] for more information.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(allHTTPResponseHeaderFields))]
        #[unsafe(method_family = none)]
        pub unsafe fn allHTTPResponseHeaderFields(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;
    );
}

/// AVMetricEventStreamPublisher.
impl AVPlayerItem {
    extern_methods!();
}

#[cfg(feature = "AVMetrics")]
extern_conformance!(
    unsafe impl AVMetricEventStreamPublisher for AVPlayerItem {}
);