Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 9532053

Browse files
author
zhanglong15
committed
修复无法导出iCloud视频的问题
1 parent 53509ac commit 9532053

File tree

4 files changed

+111
-12
lines changed

4 files changed

+111
-12
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
E4126B4A22FC085100D3E9DF /* ZLPhotoBrowser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4126B4922FC084500D3E9DF /* ZLPhotoBrowser.framework */; };
2020
E4126B4B22FC085100D3E9DF /* ZLPhotoBrowser.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E4126B4922FC084500D3E9DF /* ZLPhotoBrowser.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2121
E4126B5122FC08CF00D3E9DF /* SDWebImage.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E4126B4F22FC08CF00D3E9DF /* SDWebImage.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
22-
E4126B5222FC08CF00D3E9DF /* SDWebImageMapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E4126B5022FC08CF00D3E9DF /* SDWebImageMapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2322
E4A1F287231FC46B00315E4E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4A1F286231FC46B00315E4E /* AppDelegate.swift */; };
2423
E4A1F289231FC46B00315E4E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4A1F288231FC46B00315E4E /* SceneDelegate.swift */; };
2524
E4A1F28B231FC46B00315E4E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4A1F28A231FC46B00315E4E /* ViewController.swift */; };
@@ -60,7 +59,6 @@
6059
dstSubfolderSpec = 10;
6160
files = (
6261
E4126B5122FC08CF00D3E9DF /* SDWebImage.framework in Embed Frameworks */,
63-
E4126B5222FC08CF00D3E9DF /* SDWebImageMapKit.framework in Embed Frameworks */,
6462
E4126B4B22FC085100D3E9DF /* ZLPhotoBrowser.framework in Embed Frameworks */,
6563
);
6664
name = "Embed Frameworks";
@@ -100,7 +98,6 @@
10098
E4126B4122FC07FC00D3E9DF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
10199
E4126B4422FC084400D3E9DF /* ZLPhotoBrowser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ZLPhotoBrowser.xcodeproj; path = ../ZLPhotoBrowser.xcodeproj; sourceTree = "<group>"; };
102100
E4126B4F22FC08CF00D3E9DF /* SDWebImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImage.framework; path = ../Carthage/Build/iOS/SDWebImage.framework; sourceTree = "<group>"; };
103-
E4126B5022FC08CF00D3E9DF /* SDWebImageMapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImageMapKit.framework; path = ../Carthage/Build/iOS/SDWebImageMapKit.framework; sourceTree = "<group>"; };
104101
E4A1F284231FC46B00315E4E /* SwiftExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
105102
E4A1F286231FC46B00315E4E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
106103
E4A1F288231FC46B00315E4E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -141,7 +138,6 @@
141138
isa = PBXGroup;
142139
children = (
143140
E4126B4F22FC08CF00D3E9DF /* SDWebImage.framework */,
144-
E4126B5022FC08CF00D3E9DF /* SDWebImageMapKit.framework */,
145141
E4126B0E22FC077B00D3E9DF /* Example */,
146142
E4A1F285231FC46B00315E4E /* SwiftExample */,
147143
E4126B0D22FC077B00D3E9DF /* Products */,
@@ -526,7 +522,7 @@
526522
"$(inherited)",
527523
"@executable_path/Frameworks",
528524
);
529-
PRODUCT_BUNDLE_IDENTIFIER = ZL.Example2;
525+
PRODUCT_BUNDLE_IDENTIFIER = ZL.Example5;
530526
PRODUCT_NAME = "$(TARGET_NAME)";
531527
TARGETED_DEVICE_FAMILY = "1,2";
532528
};
@@ -545,7 +541,7 @@
545541
"$(inherited)",
546542
"@executable_path/Frameworks",
547543
);
548-
PRODUCT_BUNDLE_IDENTIFIER = ZL.Example2;
544+
PRODUCT_BUNDLE_IDENTIFIER = ZL.Example5;
549545
PRODUCT_NAME = "$(TARGET_NAME)";
550546
PROVISIONING_PROFILE_SPECIFIER = "";
551547
TARGETED_DEVICE_FAMILY = "1,2";
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1250"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "E4126B0B22FC077B00D3E9DF"
18+
BuildableName = "Example.app"
19+
BlueprintName = "Example"
20+
ReferencedContainer = "container:Example.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "E4126B0B22FC077B00D3E9DF"
48+
BuildableName = "Example.app"
49+
BlueprintName = "Example"
50+
ReferencedContainer = "container:Example.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "E4126B0B22FC077B00D3E9DF"
65+
BuildableName = "Example.app"
66+
BlueprintName = "Example"
67+
ReferencedContainer = "container:Example.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![image](https://github.com/longitachi/ImageFolder/blob/master/ZLPhotoBrowser-objc/ZLPhotoBrowser.png)
1+
®![image](https://github.com/longitachi/ImageFolder/blob/master/ZLPhotoBrowser-objc/ZLPhotoBrowser.png)
22

33
[![Version](https://img.shields.io/cocoapods/v/ZLPhotoBrowser-objc.svg?style=flat)](http://cocoadocs.org/docsets/ZLPhotoBrowser-objc)
44
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)&nbsp;
@@ -12,7 +12,7 @@
1212
该框架为原[`ZLPhotoBrowser`](https://github.com/longitachi/ZLPhotoBrowser)`4.0.0`版本以后由`Swift`重新编写,该`OC`版本不在维护,`Swift`版本有更多功能,请使用`Swift`版本
1313

1414
### 运行Demo
15-
下载完Demo请执行`carthage update --platform iOS` (运行时候请选择 `Example` target)`SDWebImage.framework``SDWebImageMapKit.framework` 路径如果报错的话,关掉项目,重新打开即可
15+
下载完Demo请执行`carthage update --use-xcframeworks --platform iOS` (运行时候请选择 `Example` target)`SDWebImage.framework``SDWebImageMapKit.framework` 路径如果报错的话,关掉项目,重新打开即可
1616

1717
### 框架整体介绍
1818
* [功能介绍](#功能介绍)

ZLPhotoBrowser/PhotoBrowser/ZLPhotoManager.m

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,38 @@ + (void)export:(PHAsset *)asset type:(ZLExportVideoType)type presetName:(NSStrin
886886
options.version = PHVideoRequestOptionsVersionOriginal;
887887
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
888888
options.networkAccessAllowed = YES;
889-
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
890-
[self export:asset range:CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity) type:type presetName:presetName renderSize:renderSize watermarkImage:watermarkImage watermarkLocation:location imageSize:imageSize effectImage:effectImage birthRate:birthRate velocity:velocity complete:^(NSString *exportFilePath, NSError *error) {
889+
890+
BOOL isInCloud = YES;
891+
if (@available(iOS 9, *)) {
892+
PHAssetResource *resource = [PHAssetResource assetResourcesForAsset:asset].firstObject;
893+
isInCloud = [[resource valueForKey:@"locallyAvailable"] boolValue] == NO;
894+
}
895+
896+
if (isInCloud) {
897+
[[PHImageManager defaultManager] requestExportSessionForVideo:asset options:options exportPreset:AVAssetExportPresetHighestQuality resultHandler:^(AVAssetExportSession * _Nullable exportSession, NSDictionary * _Nullable info) {
891898
dispatch_async(dispatch_get_main_queue(), ^{
892-
if (complete) complete(exportFilePath, error);
899+
if (exportSession.asset == nil) {
900+
if (complete) {
901+
complete(nil, exportSession.error);
902+
}
903+
return;
904+
}
905+
[self export:exportSession.asset range:CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity) type:type presetName:presetName renderSize:renderSize watermarkImage:watermarkImage watermarkLocation:location imageSize:imageSize effectImage:effectImage birthRate:birthRate velocity:velocity complete:^(NSString *exportFilePath, NSError *error) {
906+
dispatch_async(dispatch_get_main_queue(), ^{
907+
if (complete) complete(exportFilePath, error);
908+
});
909+
}];
893910
});
894911
}];
895-
}];
912+
} else {
913+
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
914+
[self export:asset range:CMTimeRangeMake(kCMTimeZero, kCMTimePositiveInfinity) type:type presetName:presetName renderSize:renderSize watermarkImage:watermarkImage watermarkLocation:location imageSize:imageSize effectImage:effectImage birthRate:birthRate velocity:velocity complete:^(NSString *exportFilePath, NSError *error) {
915+
dispatch_async(dispatch_get_main_queue(), ^{
916+
if (complete) complete(exportFilePath, error);
917+
});
918+
}];
919+
}];
920+
}
896921
}
897922

898923
+ (void)export:(AVAsset *)asset range:(CMTimeRange)range type:(ZLExportVideoType)type presetName:(NSString *)presetName renderSize:(CGSize)renderSize watermarkImage:(UIImage *)watermarkImage watermarkLocation:(ZLWatermarkLocation)location imageSize:(CGSize)imageSize effectImage:(UIImage *)effectImage birthRate:(NSInteger)birthRate velocity:(CGFloat)velocity complete:(void (^)(NSString *exportFilePath, NSError *error))complete

0 commit comments

Comments
 (0)