Search code examples
swiftphasset

phasset subtypes rawValue meaning swift


I'm trying to detect the subtypes of a PHAsset.

asset.subtypes.rawvalue -> UInt

I found the meaning of subtypes .video (rawValue: 0) and photoLive (rawValue: 8) but I have livePhoto with HDR option and the subtypes rawavlue is 10 and I don't find the meaning of the value. Someone has all rawValue meaning of PHAsset subtypes? Thanks


Solution

  • According to the documentation of PHAssetMediaSubtype:

    Media subtypes are bit mask values, so you can combine them using bitwise operators to test for multiple subtypes.

    The definition helps to:

    typedef enum PHAssetMediaSubtype : NSUInteger {
        PHAssetMediaSubtypeNone = 0,
        PHAssetMediaSubtypePhotoPanorama = (1UL << 0),
        PHAssetMediaSubtypePhotoHDR = (1UL << 1),
        PHAssetMediaSubtypePhotoScreenshot = (1UL << 2),
        PHAssetMediaSubtypePhotoLive = (1UL << 3),
        PHAssetMediaSubtypePhotoDepthEffect = (1UL << 4),
        PHAssetMediaSubtypeVideoStreamed = (1UL << 16),
        PHAssetMediaSubtypeVideoHighFrameRate = (1UL << 17),
        PHAssetMediaSubtypeVideoTimelapse = (1UL << 18)
    } PHAssetMediaSubtype;
    

    So, if subtype is 10, then 10 being 8+2 (which the unique possible "sub-values"), it's whatever is the value 8 (.photoLive) and whatever is the value 2 (.HDR).