 class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
     @IBOutlet weak var livePhotoView: PHLivePhotoView! {
         didSet {
-            if let url = NSBundle.mainBundle().URLForResource("video", withExtension: "m4v") {
-                loadVideoWithVideoURL(url)
-            }
+            loadVideoWithVideoURL(NSBundle.mainBundle().URLForResource("video", withExtension: "m4v")!)
         }
     }
 

        }
    }

    func livePhotoWithImageURL(imageURL: NSURL, videoURL: NSURL) -> PHLivePhoto? {
        let livePhoto = PHLivePhoto()
        let initWithImageURLvideoURL = NSSelectorFromString("_initWithImageURL:videoURL:");
        if (livePhoto.respondsToSelector(initWithImageURLvideoURL) == true) {
            livePhoto.performSelector(initWithImageURLvideoURL, withObject:imageURL, withObject: videoURL)
            return livePhoto
        } else {
            return nil
        }
    }

    @IBAction func takePhoto(sender: UIBarButtonItem) {

    }

    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
        picker.dismissViewControllerAnimated(true) {
            if let url = info[UIImagePickerControllerMediaURL] as? NSURL {
                self.loadVideoWithVideoURL(url)
            }
        }
    }
