質問編集履歴
1
エラー追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
import Photos
|
8
8
|
|
9
9
|
class ViewController: UIViewController {
|
10
|
+
|
11
|
+
|
10
12
|
|
11
13
|
var videoPlayerView = AVPlayerLayer()
|
12
14
|
|
@@ -60,46 +62,68 @@
|
|
60
62
|
|
61
63
|
|
62
64
|
|
63
|
-
let exportPath = NSTemporaryDirectory().appendingFormat("
|
65
|
+
let exportPath: NSString = NSTemporaryDirectory().appendingFormat("video.mov")
|
64
66
|
|
65
|
-
let exportURL = URL(fileURLWithPath: exportPath)
|
67
|
+
let exportUrl: NSURL = NSURL.init(fileURLWithPath: exportPath as String)
|
68
|
+
|
69
|
+
print(exportUrl)
|
70
|
+
|
71
|
+
let exporter = AVAssetExportSession(asset: avAsset, presetName: AVAssetExportPresetHighestQuality)
|
72
|
+
|
73
|
+
exporter?.outputURL = exportUrl as URL
|
74
|
+
|
75
|
+
exporter?.shouldOptimizeForNetworkUse = true
|
76
|
+
|
77
|
+
exporter?.outputFileType = AVFileTypeQuickTimeMovie
|
66
78
|
|
67
79
|
|
68
80
|
|
69
|
-
|
81
|
+
exporter?.exportAsynchronously(completionHandler: {
|
70
82
|
|
71
|
-
exporter?.
|
83
|
+
if exporter?.status == AVAssetExportSessionStatus.completed {
|
72
84
|
|
73
|
-
|
85
|
+
PHPhotoLibrary.shared().performChanges({
|
74
86
|
|
75
|
-
PH
|
87
|
+
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: exportUrl as URL)
|
76
88
|
|
77
|
-
|
89
|
+
}) { saved, error in
|
78
90
|
|
79
|
-
|
91
|
+
if saved {
|
80
92
|
|
81
|
-
if saved
|
93
|
+
let alertController = UIAlertController(title: "Your video was successfully saved", message: nil, preferredStyle: .alert)
|
82
94
|
|
83
|
-
let al
|
95
|
+
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
|
84
96
|
|
85
|
-
|
97
|
+
alertController.addAction(defaultAction)
|
86
98
|
|
87
|
-
alertController
|
99
|
+
self.present(alertController, animated: true, completion: nil)
|
88
100
|
|
101
|
+
} else {
|
102
|
+
|
89
|
-
|
103
|
+
print("エラー")
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
90
108
|
|
91
109
|
} else {
|
92
110
|
|
93
|
-
|
111
|
+
print(exporter?.error.debugDescription)
|
94
112
|
|
95
113
|
}
|
96
114
|
|
97
|
-
}
|
115
|
+
})
|
98
116
|
|
99
117
|
}
|
100
118
|
|
101
119
|
}
|
102
120
|
|
121
|
+
|
122
|
+
|
103
123
|
```
|
104
124
|
|
105
125
|
AVURLAsset で読み込んだ動画をフォトライブラリに保存したいのでこのコードを書いたのですがエラーと出力されフォトライブラリへの保存がうまくいきません。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
エラー内容 Optional("Optional(Error Domain=AVFoundationErrorDomain Code=-11838 \"Operation Stopped\" UserInfo={NSUnderlyingError=0x6000000595f0 {Error Domain=NSOSStatusErrorDomain Code=-12109 \"(null)\"}, NSLocalizedFailureReason=The operation is not supported for this media., NSLocalizedDescription=Operation Stopped})")
|