iOS 13上的AVAssetReferenceRestrictions [英] AVAssetReferenceRestrictions on iOS 13
问题描述
工作区:iOS 13.0,Xcode 11.0
Workspace: iOS 13.0, Xcode 11.0
TL; DR:iOS 13中的AVAssetReferenceRestrictions有问题吗?
第1部分:
在 AVAsset.h
中, AVAssetReferenceRestrictions
定义为:
@enum AVAssetReferenceRestrictions
@abstract These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.
@constant AVAssetReferenceRestrictionForbidNone
Indicates that all types of references should be followed.
@constant AVAssetReferenceRestrictionForbidRemoteReferenceToLocal
Indicates that references from a remote asset (e.g. referenced via http URL) to local media data (e.g. stored in a local file) should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToRemote
Indicates that references from a local asset to remote media data should not be followed.
@constant AVAssetReferenceRestrictionForbidCrossSiteReference
Indicates that references from a remote asset to remote media data stored at a different site should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToLocal
Indicates that references from a local asset to local media data stored outside the asset's container file should not be followed.
@constant AVAssetReferenceRestrictionForbidAll
Indicates that only references to media data stored within the asset's container file should be allowed.
*/
typedef NS_OPTIONS(NSUInteger, AVAssetReferenceRestrictions) {
AVAssetReferenceRestrictionForbidNone = 0UL,
AVAssetReferenceRestrictionForbidRemoteReferenceToLocal = (1UL << 0),
AVAssetReferenceRestrictionForbidLocalReferenceToRemote = (1UL << 1),
AVAssetReferenceRestrictionForbidCrossSiteReference = (1UL << 2),
AVAssetReferenceRestrictionForbidLocalReferenceToLocal = (1UL << 3),
AVAssetReferenceRestrictionForbidAll = 0xFFFFUL,
AVAssetReferenceRestrictionDefaultPolicy = AVAssetReferenceRestrictionForbidLocalReferenceToRemote
};
并且 AVAsset
的属性定义为:
@property referenceRestrictions
@abstract Indicates the reference restrictions being used by the receiver.
@discussion
For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any. See AVURLAssetReferenceRestrictionsKey below for a full discussion of reference restrictions. The default value for this property is AVAssetReferenceRestrictionForbidNone.
@property (nonatomic, readonly) AVAssetReferenceRestrictions referenceRestrictions API_AVAILABLE(macos(10.7), ios(5.0), tvos(9.0)) API_UNAVAILABLE(watchos);
因此,尽管该属性的文档明确指出默认值为 AVAssetReferenceRestrictionForbidNone
,但 AVAssetReferenceRestrictionDefaultPolicy
当前为 AVAssetReferenceRestrictionForbidLocalReferenceToRemote
.文档是否没有正确更新,或者 AVAssetReferenceRestrictionDefaultPolicy
与我期望的有所不同?
So, although the documentation on the property explicitly says that the default value is AVAssetReferenceRestrictionForbidNone
, AVAssetReferenceRestrictionDefaultPolicy
is currently AVAssetReferenceRestrictionForbidLocalReferenceToRemote
. Is the documentation not updated properly, or is AVAssetReferenceRestrictionDefaultPolicy
something different than I expect?
第2部分:
在Swift副本中,它是这样定义的(转换?):
In Swift counterpart, it's defined (converted?) as such:
@enum AVAssetReferenceRestrictions
@abstract These constants can be passed in to AVURLAssetReferenceRestrictionsKey to control the resolution of references to external media data.
@constant AVAssetReferenceRestrictionForbidNone
Indicates that all types of references should be followed.
@constant AVAssetReferenceRestrictionForbidRemoteReferenceToLocal
Indicates that references from a remote asset (e.g. referenced via http URL) to local media data (e.g. stored in a local file) should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToRemote
Indicates that references from a local asset to remote media data should not be followed.
@constant AVAssetReferenceRestrictionForbidCrossSiteReference
Indicates that references from a remote asset to remote media data stored at a different site should not be followed.
@constant AVAssetReferenceRestrictionForbidLocalReferenceToLocal
Indicates that references from a local asset to local media data stored outside the asset's container file should not be followed.
@constant AVAssetReferenceRestrictionForbidAll
Indicates that only references to media data stored within the asset's container file should be allowed.
public struct AVAssetReferenceRestrictions : OptionSet {
public init(rawValue: UInt)
public static var forbidRemoteReferenceToLocal: AVAssetReferenceRestrictions { get }
public static var forbidLocalReferenceToRemote: AVAssetReferenceRestrictions { get }
public static var forbidCrossSiteReference: AVAssetReferenceRestrictions { get }
public static var forbidLocalReferenceToLocal: AVAssetReferenceRestrictions { get }
public static var forbidAll: AVAssetReferenceRestrictions { get }
public static var defaultPolicy: AVAssetReferenceRestrictions { get }
}
此处没有选项作为 AVAssetReferenceRestrictionForbidNone
.但是文档明确指出确实如此.那么,这是谁的错,还是我这边的误会?
There is no option as AVAssetReferenceRestrictionForbidNone
here. But the documentation explicitly says that there is so. So, who's in fault here, or is it a misunderstanding from my side?
第3部分:我如何在这里结束?
我不得不检查这些因为我们能够从
UIImagePickerController
中选择视频,然后将其导出为AVURLAsset
格式以用于AVAssetExportSession
.一切都很好,它可以无缝运行直到iOS 13.0.该功能可在装有iOS 12.4.1及更低版本的设备上使用.
I've had to examine these because we were able to select a video from
UIImagePickerController
, then export it inAVURLAsset
form to use inAVAssetExportSession
. Everything was fine, it was working seamlessly until iOS 13.0. The feature works in the devices with iOS 12.4.1 and below.
AVAssetReferenceRestrictions的用法在 AVURLAsset
,我相信默认值已更改,并且不允许我们再出口了.
The usage of AVAssetReferenceRestrictions is in the initializer of the
AVURLAsset
, and I believe that the default value has changed and it
doesn't let us export anymore.
推荐答案
这不是你的错.
Until 2019-06-19, in the Apple referenceRestrictions documentation, the default value was forbidNone
:
此属性的默认值为 forbidNone .看AVURLAssetReferenceRestrictionsKey有关参考限制的完整讨论.
The default value for this property is forbidNone . See AVURLAssetReferenceRestrictionsKey for a full discussion of reference restrictions.
此后,此页面已更改为此:>
Later, this page was changed to this:
此属性的默认值为 defaultPolicy .有关参考限制的完整讨论,请参见AVURLAssetReferenceRestrictionsKey.
The default value for this property is defaultPolicy. See AVURLAssetReferenceRestrictionsKey for a full discussion of reference restrictions.
默认策略现在为 forbidLocalReferenceToRemote
,仅在iOS 13中可用.
The defaultPolicy now is forbidLocalReferenceToRemote
, available only in iOS 13.
但是,我们有以下段落:
However, we have this paragraph:
对于AVURLAsset,此属性反映为 (如有)为AVURLAssetReferenceRestrictionsKey传递的值.
For AVURLAsset, this property reflects the value passed in for AVURLAssetReferenceRestrictionsKey, if any.
因此,显然,未传递strictKey应该与 forbidNone
相同.
So, apparently, not passing a restrictionKey should work the same as forbidNone
.
您尝试过吗?
let asset = AVURLAsset(url: url, options: nil)
这篇关于iOS 13上的AVAssetReferenceRestrictions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!