Doug Smith
Doug Smith

Reputation: 29316

Rotate video 90 degrees in AVPlayerViewController - possible?

I cannot figure out how to rotate the video 90 degrees in AVPlayerViewController, anyone have any ideas as to how to do this? I'm unsure how to access the AVPlayerLayer as you normally would.

Upvotes: 2

Views: 1552

Answers (1)

Reinier Melian
Reinier Melian

Reputation: 20804

Try with this code, using AffineTransform we rotate the view but we need also adjust the frame

EDITED

UIView.animate(withDuration: 0.5) {
  self.avPlayerViewController?.view.transform = CGAffineTransform(rotationAngle: CGFloat((90 * Double.pi)/180))
  self.avPlayerViewController?.view.frame = CGRect(x: 0, y: 0, width: (self.avPlayerViewController?.view.frame.size.height)!, height: (self.avPlayerViewController?.view.frame.size.width)!)
}

Work just fine, was tested

Hope this helps you

Upvotes: 5

Related Questions