質問編集履歴
1
詳細を追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
UIImagePickerControllerで
|
1
|
+
UIImagePickerControllerでライブラリから動画を取得出来ない
|
test
CHANGED
@@ -4,15 +4,79 @@
|
|
4
4
|
|
5
5
|
Privacy - Photo Library Usage Descriptionの設定をしたのですが
|
6
6
|
|
7
|
+
アクセス許可のアラートが出ません
|
8
|
+
|
9
|
+
ライブラリに遷移して動画を選択、再生する事は出来るのですが
|
10
|
+
|
7
|
-
|
11
|
+
取得する事が出来ません。
|
12
|
+
|
13
|
+
imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])が
|
14
|
+
|
15
|
+
呼ばれないみたいです。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
8
20
|
|
9
21
|
```swift
|
10
22
|
|
11
|
-
|
23
|
+
class Test: UIViewController {
|
12
24
|
|
25
|
+
let imagePickerController = UIImagePickerController()
|
26
|
+
|
27
|
+
@IBOutlet weak var imageView: UIImageView!
|
28
|
+
|
29
|
+
@IBAction func selsectImage(_ sender: Any) {
|
30
|
+
|
13
|
-
|
31
|
+
print("カメラロールから動画を選択")
|
32
|
+
|
33
|
+
imagePickerController.sourceType = .photoLibrary
|
34
|
+
|
35
|
+
imagePickerController.delegate = self
|
36
|
+
|
37
|
+
imagePickerController.mediaTypes = ["public.movie"]
|
38
|
+
|
39
|
+
present(imagePickerController, animated: true, completion: nil)
|
14
40
|
|
15
41
|
}
|
42
|
+
|
43
|
+
override func viewDidLoad() {
|
44
|
+
|
45
|
+
super.viewDidLoad()
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
extension Test: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
|
54
|
+
|
55
|
+
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
56
|
+
|
57
|
+
print("cancel")
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
|
64
|
+
|
65
|
+
videoURL = info["UIImagePickerControllerReferenceURL"] as? URL
|
66
|
+
|
67
|
+
print(videoURL!)
|
68
|
+
|
69
|
+
imageView.image = previewImageFromVideo(videoURL!)!
|
70
|
+
|
71
|
+
imageView.contentMode = .scaleAspectFit
|
72
|
+
|
73
|
+
imagePickerController.dismiss(animated: true, completion: nil)
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
}
|
16
80
|
|
17
81
|
```
|
18
82
|
|