AVPlayer和GPUImagede学习iOS MediaPlayer 库

AVPlayerItem 的内容

2016-10-31  本文已影响3684人  helinyu

AVPlayerItem 是对于被AVPlayer对象播放的asset进行模拟和记时,它提供了接口访问媒体的不同时间、确定展示的大小、当前时间的唯一标示符等等;

Associating Metadata for Playback with AVKit : 链接元素(对于AVKit上的Playback)
Notifications 通知
Instance Properties 实例属性

开发中出现的问题:

一个quene中不能够有两个同样PlayItem
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem can occupy only one position in a player's queue at a time.'
ps:只能够占用一个位置 ,所以,应该是先删除,然后再进行添加;

playItem 是通过kvo 监听方式;
ps: PlayItem 和 url以及asset之间的关系;

对象相关的属性(这些属性可以查看官方文档)
——————————————————————————————————————

@property (nonatomic, readonly) CMTime duration; asset 资源的延时
如果providesPreciseDurationAndTiming == no,就会返回一个大概的值 ;入托timing relate 被设置在初始化的时候,应该是会返回精确的值; AVURLAssetPreferPreciseDurationAndTimingKey 键值;

@property (nonatomic, readonly) float preferredRate;
自然播放的速度

@property (nonatomic, readonly) float preferredVolume;
变向选择的卷

@property (nonatomic, readonly) CGAffineTransform preferredTransform;
这个是转化

@property (nonatomic, readonly) CGSize naturalSize NS_DEPRECATED(10_7, 10_8, 4_0, 5_0);
默认的大小(应该过时了)

同步下载
@interface AVAsset (AVAssetAsynchronousLoading)
@property (nonatomic, readonly) BOOL providesPreciseDurationAndTiming;

偏向的限制
@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; 读取的轨道

AVAsset元组的读取
@interface AVAsset (AVAssetMetadataReading)
@property (nonatomic, readonly, nullable) AVMetadataItem *creationDate NS_AVAILABLE(10_8, 5_0); //创建日期
@property (nonatomic, readonly, nullable) NSString *lyrics; 对应的文字词
@property (nonatomic, readonly) NSArray<AVMetadataItem *> *commonMetadata; 公共的元素
@property (nonatomic, readonly) NSArray<AVMetadataItem *> *metadata NS_AVAILABLE(10_10, 8_0); 元素
@property (nonatomic, readonly) NSArray<NSString *> *availableMetadataFormats; 元素中使用的类型

字幕的检测
@interface AVAsset (AVAssetChapterInspection)
@property (readonly) NSArray<NSLocale *> *availableChapterLocales NS_AVAILABLE(10_7, 4_3); //本地对象数组

媒体选择
@interface AVAsset (AVAssetMediaSelection)
@property (nonatomic, readonly) NSArray<NSString *> *availableMediaCharacteristicsWithMediaSelectionOptions NS_AVAILABLE(10_8, 5_0); //有用的媒体字符特征

保护的内容
@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); //执行
@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的关系
@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

@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 )

@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;
}

@interface AVFragmentedAsset (AVFragmentedAssetTrackInspection)

@class AVFragmentedAssetMinderInternal;
NS_CLASS_AVAILABLE_MAC(10_11)
@interface AVFragmentedAssetMinder : NSObject
{
@private
AVFragmentedAssetMinderInternal *_fragmentedAssetMinder;
}

源码链接:
https://github.com/helinyu/test_AVPlayer

上一篇下一篇

猜你喜欢

热点阅读