I need to put a video inside a view, in that it has to rotate only within that square not in fullscreen. (facebook type)
I already researched and only saw full screen tutorials. How to do this?
I got this code:
class BeginController: UIViewController {
@IBOutlet weak var videoPreviewLayer: UIView!
var player: AVPlayer!
var avpController = AVPlayerViewController!()
override func viewDidLoad() {
super.viewDidLoad()
let moviePath = NSBundle.mainBundle().pathForResource("Hello Moto", ofType: "mp4")
if let path = moviePath{
let url = NSURL.fileURLWithPath(path)
let item = AVPlayerItem(URL: url)
self.player = AVPlayer(playerItem: item)
self.avpController = AVPlayerViewController()
self.avpController.player = self.player
avpController.view.frame = videoPreviewLayer.frame
self.addChildViewController(avpController)
self.view.addSubview(avpController.view)
}
// Do any additional setup after loading the view.
}