forked from jhinericusername/TheraView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreExerciseViewController.swift
55 lines (44 loc) · 1.61 KB
/
PreExerciseViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import UIKit
import AVKit
import AVFoundation
class PreExerciseViewController: UIViewController {
// let videoView =
// @IBOutlet weak var videoContainerView: UIView!
//
// func setUpVideoPlayer() {
// print("trying to show video")
// guard let videoURL = Bundle.main.url(forResource: "jj", withExtension: "mp4") else {
// print("Video not found")
// return
// }
//
// let player = AVPlayer(url: videoURL)
// let playerLayer = AVPlayerLayer(player: player)
//
// playerLayer.frame = videoContainerView.bounds
// playerLayer.videoGravity = .resizeAspect // Adjust this to .resizeAspectFill if you want the video to fill the container view
// videoContainerView.layer.addSublayer(playerLayer)
//
// player.play()
//
// // Loop the video
// NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player.currentItem, queue: .main) { _ in
// player.seek(to: CMTime.zero)
// player.play()
// }
// }
override func viewDidLoad() {
super.viewDidLoad()
// Add any setup code you need to run when the view loads
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let player = AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "jj", ofType: "mp4")!))
let layer = AVPlayerLayer(player: player)
layer.frame = view.bounds
view.layer.addSublayer(layer)
player.play()
}
// MARK: - IBActions
// MARK: - Private Methods
}