guide/Guibe/4_VideoViewController.swift
2019-05-29 02:20:18 +01:00

60 lines
1.8 KiB
Swift

//
// 4_VideoViewController.swift
// Guibe
//
// Created by Max Hunt on 28/05/2019.
// Copyright © 2019 8. All rights reserved.
//
import UIKit
import AVKit
import AVFoundation
class V4deoViewController: UIViewController {
@IBOutlet var videoBtn: UIButton!
@IBOutlet var nextBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func nextBtnPressed(_ sender: Any) {
let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "screen5") as! H5ndChoiceViewController
nextViewController.modalTransitionStyle = .crossDissolve
self.present(nextViewController, animated: true, completion: nil)
}
@IBAction func videoBtnPress(_ sender: Any) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.videoBtn.isHidden = true
self.nextBtn.isHidden = false}
playVideo()
}
private func playVideo() {
guard let path = Bundle.main.path(forResource: "Video", ofType:"mov") else {
debugPrint("Video.mov not found")
return
}
let player = AVPlayer(url: URL(fileURLWithPath: path))
let playerController = AVPlayerViewController()
playerController.player = player
// playerController.modalPresentationStyle = .popover
present(playerController, animated: true) {
player.play()
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}