Reputation: 1
I am tying to place 4 videos, side by side in a scroll view I have created in a storyboard. The side scroll works as expected, and I also have a basic video player going, so I have the video working, but its not constrained to the scroll view. I am assuming I need to tell the video to be in the scroll view and to constrain to the height of the scroll view, but haven't been able to find any tutorials that talk about that specifically. I am also assuming I would need to set some coordinates for the other videos to place them side by side? or is it similar to html/css where I can set some padding or space between? See attached for how I set up the scroll view, and below is my video code.
import AVKit
import AVFoundation
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let player = AVPlayer(url: URL(fileURLWithPath: Bundle.main.path(forResource: "final-S3-r1", ofType: "mp4")!))
let layer = AVPlayerLayer(player: player)
layer.frame = view.bounds
view.layer.addSublayer(layer)
player.volume = 0
player.play()
}
}
Upvotes: 0
Views: 79