I'm having some trouble playing video content on both an ios device and in the simulator.
Goal: Stream a video from an online resource given here:
public video streams using hls using the AVPlayerViewController
, just to learn how it works.
This consistently resulted in no errors being thrown, but the view controller presenting me with this view.
I decided to step back and test on a local resource, so I filmed a short screen capture in quicktime (.m4v) and saved it right to the project. This resulted in the exact same behavior with no errors reported.
Here is the code (AVKit
and AVFoundation
are imported ):
var playerVC : AVPlayerViewController!
var playerItem : AVPlayerItem!
var player : AVPlayer!
var playerLayer: AVPlayerLayer!
override func viewDidAppear(animated: Bool) {
let bundle = NSBundle.mainBundle()
let path = bundle.pathForResource("testVideos", ofType: "m4v")
let url = NSURL.init(string: path!)
playerItem = AVPlayerItem.init(URL: url!)
player = AVPlayer.init(playerItem: playerItem)
playerVC = AVPlayerViewController.init();
playerVC.player = player;
self.presentViewController(playerVC, animated: true) { () -> Void in
self.playerVC.player?.play()
}
}
Seeing this warning when building to an IpadMini 4: <CATransformLayer: 0x136ea1030> - changing property masksToBounds in transform-only layer, will have no effect
Xcode: Version 7.1 Targeting: iOS 9.0
Update Just some nasty constraint output from the AVPlayerViewController. I don't think this is contributing, but here it is:
2015-10-28 15:12:02.777 AVKitTest[4441:94545] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "", "", "", "", "", "", "" )
Turns out it was something silly, just had to change:
let url = NSURL.init(string: path!)
playerItem = AVPlayerItem.init(URL: url!)
with:
let url = NSURL.init(fileURLWithPath: path!)
let playerItem = AVPlayerItem.init(URL: url)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With