Search code examples
iosavplayer

How to control AVPlayer subview in storyboards without breaking function


this is my current code:

    @IBOutlet weak var videoView: UIView!
var player: AVPlayer!
var avpController = AVPlayerViewController()

override func viewDidLoad() {
    super.viewDidLoad()
    let url = URL(string:"https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8")

    player = AVPlayer(url: url!)

    avpController.player = player

    avpController.view.frame.size.height = videoView.frame.size.height

    avpController.view.frame.size.width = videoView.frame.size.width

    self.videoView.addSubview(avpController.view)
    // Do any additional setup after loading the view, typically from a nib.
}

Story board:

Storyboard

the results =

ios

im aiming for it to fill the entire view in the future i plan to add the ability to swipe down to minimize and browse the app while watching the live stream.

currently im unable to make the view in storyboards have controll of the subview. is it possible to do this or am i better off writing it in code? my only concern is when the user is using other devices other then an X then.


Solution

  • Ok so this is a minor technical problem... it turnsout even though i specified a width becuase i have not added side contraints it did not exstend to the sides... it's odd though a 375 width should have covered the scree with out the exstra contraints.