Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
My code is here
@IBAction func openVideo(_ sender: Any) {
//selectVideo(delegate: self, sourceType: .savedPhotosAlbum)
let mediaUI = UIImagePickerController()
mediaUI.sourceType = .savedPhotosAlbum
mediaUI.mediaTypes = [kUTTypeMovie as String]
mediaUI.allowsEditing = true
mediaUI.delegate = self
self.present(mediaUI, animated: true, completion: nil)
At this part I select video.
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func processVideo(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]){
let url = info[UIImagePickerController.InfoKey.mediaURL] as! URL
print("hey")
self.dismiss(animated: true) {
let player = AVPlayer(url: url)
let vcPlayer = AVPlayerViewController()
vcPlayer.player = player
self.present(vcPlayer, animated: true, completion: nil)
What am I doing wrong?
I can't get any print in processVideo function. I get this error after selecting the video from gallery.
"Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
You need to set for settings like this or in plist.
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
Documentation
–
Solved problem by changing name of processvideo func to imagePickerController. It seems like name is very important at delegate functions. I didn't notice that.
Tip for creating this delegate function write didfinish and you will get prefer function named imagePickerController, use it.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.