1

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

Jack
  • 81
  • 2
  • 9

1 Answers1

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