1

I'm having trouble trying to display video I just recorded in an image view. It's pretty simple to display an image in an image view but I don't know where to start. This is all I have so far:

import UIKit
import AVKit
import AVFoundation
import MobileCoreServices

class VideoViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet weak var videoImageView: UIImageView!        
    override func viewWillAppear(_ animated: Bool) {
        super.viewDidAppear(animated)            
        if self.isBeingPresented || self.isMovingToParentViewController {
            let imagePicker = UIImagePickerController()                
            imagePicker.sourceType = .camera
            imagePicker.mediaTypes = [kUTTypeMovie as String]
            imagePicker.allowsEditing = false
            imagePicker.delegate = self                
            present(imagePicker, animated: true, completion: {})
        }            
    }
}

I can open the video camera and record then do the action "use video". But once I do that I'm returned to the view controller with nothing in the UIImageView. I know I haven't stored the information in a data but I haven't seen anything online that'll help me with that. I'd appreciate any advice on this. Thanks.

Andrew Vergunov
  • 1,007
  • 8
  • 24
  • UIImageView it is not a Movie Player – Leo Dabus Feb 02 '17 at 21:47
  • So if UIImageView isn't the way to display a video, what do you use then? – Cornelius N. Feb 02 '17 at 21:56
  • 1
    A very very quick search on Google for *iOS Swift play video site:stack overflow.com* returned some 44,000 hits. This looks like a good one: http://stackoverflow.com/questions/25932570/how-to-play-video-with-avplayerviewcontroller-avkit-in-swift. Please, try to do some simple searching! – dfd Feb 02 '17 at 22:01
  • Possible duplicate of [How to play video with AVPlayerViewController (AVKit) in Swift](http://stackoverflow.com/questions/25932570/how-to-play-video-with-avplayerviewcontroller-avkit-in-swift) – dfd Feb 02 '17 at 22:02
  • Thanks. I did a lot of research before asking this. I was just asking the wrong questions because I didn't even know about the AVPlayer. – Cornelius N. Feb 02 '17 at 22:07
  • No problem. The reason I flagged it as a duplicate is for others who find this question - they'll get directed to the right thing. – dfd Feb 02 '17 at 23:20

0 Answers0