cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/QMUIComponents/AssetLibrary/QMUIAsset.h

159 lines
7.4 KiB
C
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// QMUIAsset.h
// qmui
//
// Created by QMUI Team on 15/6/30.
//
#import <UIKit/UIKit.h>
#import <Photos/PHImageManager.h>
typedef NS_ENUM(NSUInteger, QMUIAssetType) {
QMUIAssetTypeUnknow,
QMUIAssetTypeImage,
QMUIAssetTypeVideo,
QMUIAssetTypeAudio
};
typedef NS_ENUM(NSUInteger, QMUIAssetSubType) {
QMUIAssetSubTypeUnknow,
QMUIAssetSubTypeImage,
QMUIAssetSubTypeLivePhoto NS_ENUM_AVAILABLE_IOS(9_1),
QMUIAssetSubTypeGIF
};
/// Status when download asset from iCloud
typedef NS_ENUM(NSUInteger, QMUIAssetDownloadStatus) {
QMUIAssetDownloadStatusSucceed,
QMUIAssetDownloadStatusDownloading,
QMUIAssetDownloadStatusCanceled,
QMUIAssetDownloadStatusFailed
};
@class PHAsset;
/**
*
* @note QMUIAsset isEqual: QMUIAsset identifier 便 QMUIAsset
*/
@interface QMUIAsset : NSObject
@property(nonatomic, assign, readonly) QMUIAssetType assetType;
@property(nonatomic, assign, readonly) QMUIAssetSubType assetSubType;
- (instancetype)initWithPHAsset:(PHAsset *)phAsset;
@property(nonatomic, strong, readonly) PHAsset *phAsset;
@property(nonatomic, assign, readonly) QMUIAssetDownloadStatus downloadStatus; // 从 iCloud 下载资源大图的状态
@property(nonatomic, assign) double downloadProgress; // 从 iCloud 下载资源大图的进度
@property(nonatomic, assign) NSInteger requestID; // 从 iCloud 请求获得资源的大图的请求 ID
@property (nonatomic, copy, readonly) NSString *identifier;// Asset 的标识,每个 QMUIAsset 的 identifier 都不同。只要两个 QMUIAsset 的 identifier 相同则认为它们是同一个 asset
/// Asset 的原图(包含系统相册“编辑”功能处理后的效果)
- (UIImage *)originImage;
/**
* Asset
*
* @param size pt
*
* @return Asset
*/
- (UIImage *)thumbnailWithSize:(CGSize)size;
/**
* Asset
*
* @warning
* @return Asset
*/
- (UIImage *)previewImage;
/**
* Asset
*
* @param completion block block
*
* @param phProgressHandler handler线 block UI 线
*
* @return id
*/
- (NSInteger)requestOriginImageWithCompletion:(void (^)(UIImage *result, NSDictionary<NSString *, id> *info))completion withProgressHandler:(PHAssetImageProgressHandler)phProgressHandler;
/**
* Asset
*
* @param size
* @param completion block block
* block nil
*
* @return id
*/
- (NSInteger)requestThumbnailImageWithSize:(CGSize)size completion:(void (^)(UIImage *result, NSDictionary<NSString *, id> *info))completion;
/**
* Asset
*
* @param completion block block
*
* @param phProgressHandler handler线 block UI 线
*
* @return id
*/
- (NSInteger)requestPreviewImageWithCompletion:(void (^)(UIImage *result, NSDictionary<NSString *, id> *info))completion withProgressHandler:(PHAssetImageProgressHandler)phProgressHandler;
/**
* Live Photo
*
* @param completion block Live Photo assetType QMUIAssetTypeLivePhoto nil
* @param phProgressHandler handler线 block UI 线
*
* @warning iOS 9.1 Live Photo
*
* @return id
*/
- (NSInteger)requestLivePhotoWithCompletion:(void (^)(PHLivePhoto *livePhoto, NSDictionary<NSString *, id> *info))completion withProgressHandler:(PHAssetImageProgressHandler)phProgressHandler;
/**
* AVPlayerItem
*
* @param completion block AVPlayerItem assetType QMUIAssetTypeVideo nil
* @param phProgressHandler handler线 block UI 线
*
* @return AVPlayerItem id
*/
- (NSInteger)requestPlayerItemWithCompletion:(void (^)(AVPlayerItem *playerItem, NSDictionary<NSString *, id> *info))completion withProgressHandler:(PHAssetVideoProgressHandler)phProgressHandler;
/**
* Data
*
* @param completion block Data assetType QMUIAssetTypeImage QMUIAssetTypeLivePhoto nil GIF HEIC
*/
- (void)requestImageData:(void (^)(NSData *imageData, NSDictionary<NSString *, id> *info, BOOL isGIF, BOOL isHEIC))completion;
/**
* UIImageOrientation assetType QMUIAssetTypeImage QMUIAssetTypeLivePhoto
*/
- (UIImageOrientation)imageOrientation;
/// 更新下载资源的结果
- (void)updateDownloadStatusWithDownloadResult:(BOOL)succeed;
/**
* Asset
*/
- (void)assetSize:(void (^)(long long size))completion;
- (NSTimeInterval)duration;
@end