I've a url = http//www.dd.com/mysong.mp4, and I've a UIView controller in portrait mode of iphones using Auto layout and size classes. and I need to rotate the viewController and then play my video in fullscreen. because I cant use orientation, cause constraints wont support. it is Compact and regular size class. how to play video in fullscreen using AV PLAYER. Atleast help me with playing video in fullscreen what ever the things may be? Any related stuff Please
Asked
Active
Viewed 4,759 times
1
Jack
- 81
- 2
- 9
-
Your app is in portrait view and you want video in landscape view? Plus your app supports landscape view? – Saqib Omer Dec 02 '15 at 13:05
1 Answers
0
You can create instance of and present it.
import AVKit
import AVFoundation
func playVideo(urlString: String) {
guard let url = URL(string: urlString) else {return}
DispatchQueue.main.async {
let player = AVPlayer(url: url)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true, completion: {
playerViewController.player!.play()
})
}
}
Saqib Omer
- 5,387
- 7
- 50
- 71
-
1
-
-
https://developer.apple.com/documentation/avkit/avplayerviewcontroller – Raildex Oct 25 '21 at 12:06
-
Hmm, yeah it is right, but I can derived classes from AVPlayerViewController. Updating my answer though. @Raildex – Saqib Omer Oct 26 '21 at 08:33