AVPlayerItem 是對于被AVPlayer對象播放的asset進行模擬和記時,它提供了接口訪問媒體的不同時間杖剪、確定展示的大小挚赊、當(dāng)前時間的唯一標示符等等苗踪;
Associating Metadata for Playback with AVKit : 鏈接元素(對于AVKit上的Playback)
Notifications 通知
Instance Properties 實例屬性
開發(fā)中出現(xiàn)的問題:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem can occupy only one position in a player's queue at a time.'
ps:只能夠占用一個位置 ,所以帚戳,應(yīng)該是先刪除玷或,然后再進行添加;
playItem 是通過kvo 監(jiān)聽方式片任;
ps: PlayItem 和 url以及asset之間的關(guān)系偏友;
對象相關(guān)的屬性(這些屬性可以查看官方文檔)
——————————————————————————————————————
- (instancetype)assetWithURL:(NSURL *)URL;
通過一個url返回一個asset對象
@property (nonatomic, readonly) CMTime duration; asset 資源的延時
如果providesPreciseDurationAndTiming == no,就會返回一個大概的值 对供;入托timing relate 被設(shè)置在初始化的時候位他,應(yīng)該是會返回精確的值; AVURLAssetPreferPreciseDurationAndTimingKey 鍵值犁钟;
@property (nonatomic, readonly) float preferredRate;
自然播放的速度
@property (nonatomic, readonly) float preferredVolume;
變向選擇的卷
@property (nonatomic, readonly) CGAffineTransform preferredTransform;
這個是轉(zhuǎn)化
@property (nonatomic, readonly) CGSize naturalSize NS_DEPRECATED(10_7, 10_8, 4_0, 5_0);
默認的大欣庥铡(應(yīng)該過時了)
同步下載
@interface AVAsset (AVAssetAsynchronousLoading)
@property (nonatomic, readonly) BOOL providesPreciseDurationAndTiming;
- (void)cancelLoading;
@end
偏向的限制
@interface AVAsset (AVAssetReferenceRestrictions)
typedef NS_OPTIONS(NSUInteger, AVAssetReferenceRestrictions) {
AVAssetReferenceRestrictionForbidNone = 0UL,
AVAssetReferenceRestrictionForbidRemoteReferenceToLocal = (1UL << 0),
AVAssetReferenceRestrictionForbidLocalReferenceToRemote = (1UL << 1),
AVAssetReferenceRestrictionForbidCrossSiteReference = (1UL << 2),
AVAssetReferenceRestrictionForbidLocalReferenceToLocal = (1UL << 3),
AVAssetReferenceRestrictionForbidAll = 0xFFFFUL,
};
@property (nonatomic, readonly) AVAssetReferenceRestrictions referenceRestrictions NS_AVAILABLE(10_7, 5_0);
@end
軌道檢測
@interface AVAsset (AVAssetTrackInspection)
@property (nonatomic, readonly) NSArray<AVAssetTrack *> *tracks; 讀取的軌道
- (nullable AVAssetTrack *)trackWithTrackID:(CMPersistentTrackID)trackID; //軌道的id
- (NSArray<AVAssetTrack *> *)tracksWithMediaType:(NSString *)mediaType; //規(guī)帶的媒體類型
- (NSArray<AVAssetTrack *> *)tracksWithMediaCharacteristic:(NSString *)mediaCharacteristic; //媒體的標示
@property (nonatomic, readonly) NSArray<AVAssetTrackGroup *> *trackGroups NS_AVAILABLE(10_9, 7_0); //軌道組
@end
AVAsset元組的讀取
@interface AVAsset (AVAssetMetadataReading)
@property (nonatomic, readonly, nullable) AVMetadataItem *creationDate NS_AVAILABLE(10_8, 5_0); //創(chuàng)建日期
@property (nonatomic, readonly, nullable) NSString *lyrics; 對應(yīng)的文字詞
@property (nonatomic, readonly) NSArray<AVMetadataItem *> *commonMetadata; 公共的元素
@property (nonatomic, readonly) NSArray<AVMetadataItem *> *metadata NS_AVAILABLE(10_10, 8_0); 元素
@property (nonatomic, readonly) NSArray<NSString *> *availableMetadataFormats; 元素中使用的類型
- (NSArray<AVMetadataItem *> *)metadataForFormat:(NSString *)format; 通過格式來獲取item
@end
字幕的檢測
@interface AVAsset (AVAssetChapterInspection)
@property (readonly) NSArray<NSLocale *> *availableChapterLocales NS_AVAILABLE(10_7, 4_3); //本地對象數(shù)組
- (NSArray<AVTimedMetadataGroup *> *)chapterMetadataGroupsWithTitleLocale:(NSLocale *)locale containingItemsWithCommonKeys:(nullable NSArray<NSString *> *)commonKeys NS_AVAILABLE(10_7, 4_3);
- (NSArray<AVTimedMetadataGroup *> *)chapterMetadataGroupsBestMatchingPreferredLanguages:(NSArray<NSString *> *)preferredLanguages NS_AVAILABLE(10_8, 6_0);
@end
媒體選擇
@interface AVAsset (AVAssetMediaSelection)
@property (nonatomic, readonly) NSArray<NSString *> *availableMediaCharacteristicsWithMediaSelectionOptions NS_AVAILABLE(10_8, 5_0); //有用的媒體字符特征
- (nullable AVMediaSelectionGroup *)mediaSelectionGroupForMediaCharacteristic:(NSString *)mediaCharacteristic NS_AVAILABLE(10_8, 5_0); //媒體選擇組
@property (nonatomic, readonly) AVMediaSelection *preferredMediaSelection NS_AVAILABLE(10_11, 9_0); //媒體的選擇
@end
保護的內(nèi)容
@interface AVAsset (AVAssetProtectedContent)
@property (nonatomic, readonly) BOOL hasProtectedContent NS_AVAILABLE(10_7, 4_2);
@end
碎片
@interface AVAsset (AVAssetFragments)
@property (nonatomic, readonly) BOOL canContainFragments NS_AVAILABLE(10_11, 9_0);
@property (nonatomic, readonly) BOOL containsFragments NS_AVAILABLE(10_11, 9_0);
@end
使用情況
@interface AVAsset (AVAssetUsability)
@property (nonatomic, readonly, getter=isPlayable) BOOL playable NS_AVAILABLE(10_7, 4_3);播放能力
@property (nonatomic, readonly, getter=isExportable) BOOL exportable NS_AVAILABLE(10_7, 4_3); //執(zhí)行
@property (nonatomic, readonly, getter=isReadable) BOOL readable NS_AVAILABLE(10_7, 4_3); //讀取能力
@property (nonatomic, readonly, getter=isComposable) BOOL composable NS_AVAILABLE(10_7, 4_3); // 組成
@property (nonatomic, readonly, getter=isCompatibleWithSavedPhotosAlbum) BOOL compatibleWithSavedPhotosAlbum NS_AVAILABLE_IOS(5_0); // 保存到相冊
@property (nonatomic, readonly, getter=isCompatibleWithAirPlayVideo) BOOL compatibleWithAirPlayVideo NS_AVAILABLE(10_11, 9_0); //與airplay的關(guān)系
@end
AVF_EXPORT NSString *const AVURLAssetPreferPreciseDurationAndTimingKey NS_AVAILABLE(10_7, 4_0);
AVF_EXPORT NSString *const AVURLAssetReferenceRestrictionsKey NS_AVAILABLE(10_7, 5_0);
AVF_EXPORT NSString *const AVURLAssetHTTPCookiesKey NS_AVAILABLE_IOS(8_0);
AVF_EXPORT NSString *const AVURLAssetAllowsCellularAccessKey NS_AVAILABLE_IOS(10_0);
@interface AVURLAsset : AVAsset
- (NSArray<NSString *> *)audiovisualTypes NS_AVAILABLE(10_7, 5_0); //音頻的類型
- (NSArray<NSString *> *)audiovisualMIMETypes NS_AVAILABLE(10_7, 5_0);
- (BOOL)isPlayableExtendedMIMEType: (NSString *)extendedMIMEType NS_AVAILABLE(10_7, 5_0);
- (instancetype)URLAssetWithURL:(NSURL *)URL options:(nullable NSDictionary<NSString *, id> *)options;
- (instancetype)initWithURL:(NSURL *)URL options:(nullable NSDictionary<NSString *, id> *)options NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly, copy) NSURL *URL;
@end
@class AVAssetResourceLoader;
@interface AVURLAsset (AVURLAssetURLHandling)
@property (nonatomic, readonly) AVAssetResourceLoader *resourceLoader NS_AVAILABLE(10_9, 6_0);
@end
@class AVAssetCache;
@interface AVURLAsset (AVURLAssetCache)
@property (nonatomic, readonly, nullable) AVAssetCache *assetCache NS_AVAILABLE(10_12, 10_0);
@end
@interface AVURLAsset (AVAssetCompositionUtility )
- (nullable AVAssetTrack *)compatibleTrackForCompositionTrack:(AVCompositionTrack *)compositionTrack;
@end
AVF_EXPORT NSString *const AVAssetDurationDidChangeNotification NS_AVAILABLE(10_11, 9_0);
AVF_EXPORT NSString *const AVAssetContainsFragmentsDidChangeNotification NS_AVAILABLE_MAC(10_11);
AVF_EXPORT NSString *const AVAssetWasDefragmentedNotification NS_AVAILABLE_MAC(10_11);
AVF_EXPORT NSString *const AVAssetChapterMetadataGroupsDidChangeNotification NS_AVAILABLE(10_11, 9_0);
AVF_EXPORT NSString *const AVAssetMediaSelectionGroupsDidChangeNotification NS_AVAILABLE(10_11, 9_0);
@end
@protocol AVFragmentMinding
@property (nonatomic, readonly, getter=isAssociatedWithFragmentMinder) BOOL associatedWithFragmentMinder NS_AVAILABLE_MAC(10_11);
@end
@class AVFragmentedAssetInternal;
NS_CLASS_AVAILABLE_MAC(10_11)
@interface AVFragmentedAsset : AVURLAsset <AVFragmentMinding>
{
@private
AVFragmentedAssetInternal *_fragmentedAsset;
}
- (instancetype)fragmentedAssetWithURL:(NSURL *)URL options:(nullable NSDictionary<NSString *, id> *)options;
@property (nonatomic, readonly) NSArray<AVFragmentedAssetTrack *> *tracks;
@end
@interface AVFragmentedAsset (AVFragmentedAssetTrackInspection)
- (nullable AVFragmentedAssetTrack *)trackWithTrackID:(CMPersistentTrackID)trackID;
- (NSArray<AVFragmentedAssetTrack *> *)tracksWithMediaType:(NSString *)mediaType;
- (NSArray<AVFragmentedAssetTrack *> *)tracksWithMediaCharacteristic:(NSString *)mediaCharacteristic;
@end
@class AVFragmentedAssetMinderInternal;
NS_CLASS_AVAILABLE_MAC(10_11)
@interface AVFragmentedAssetMinder : NSObject
{
@private
AVFragmentedAssetMinderInternal *_fragmentedAssetMinder;
}
- (instancetype)fragmentedAssetMinderWithAsset:(AVAsset<AVFragmentMinding> *)asset mindingInterval:(NSTimeInterval)mindingInterval;
@property (nonatomic) NSTimeInterval mindingInterval;
@property (nonatomic, readonly) NSArray<AVAsset<AVFragmentMinding> *> *assets;
- (void)addFragmentedAsset:(AVAsset<AVFragmentMinding> *)asset;
- (void)removeFragmentedAsset:(AVAsset<AVFragmentMinding> *)asset;
@end