how to play a private video from AWS S3 using AVPlayer.

I am unable to play a private video from AWS S3 using AVPlayer. I have generated a presignedURL and trying to play a video in AVPLayer using that url. Can anyone help me regarding this. please help me if are there any better way to play a private videos of AWS S3 in iOS.

Thanks & Regards,
Narayanareddy
What happens when you try to play the video?
I got an error message like "NSURLConnection finished with error - code -1002". AVPlayer opens with blank screen.

I have followed the below code to play the video from AWS S3

   var avPlayerVC = AVPlayerViewController()
  var playerView = AVPlayer()
   
  
  func playFromS3(){

    let getPreSignedURLRequest = AWSS3GetPreSignedURLRequest()
    getPreSignedURLRequest.bucket = "elearningtestprep-userfiles-mobilehub-1056529852"
    getPreSignedURLRequest.key = "public/teststats/satdemovideo/Of_Mice.mp4"
    getPreSignedURLRequest.httpMethod = .GET
    getPreSignedURLRequest.expires = Date(timeIntervalSinceNow: 3600)

    AWSS3PreSignedURLBuilder.default().getPreSignedURL(getPreSignedURLRequest).continueWith { (task:AWSTask<NSURL>) -> Any? in
      if let error = task.error {
        print("AWSS3PreSignedURLBuilder Error: \(error)")
        return nil
      }
       
      let presignedURL = task.result
      let url:URL = URL(string : String(describing: presignedURL))!
      self.playerView = AVPlayer(url: url)
      self.avPlayerVC.player = self.playerView
      DispatchQueue.main.async {

        self.present(self.avPlayerVC, animated: true) {
          self.avPlayerVC.player?.play()
        }
       }

        return nil;

    }
  }

using the above presignedURL, video is playing in browswer but not in app.
Looks like that error code is:
    NSURLErrorUnsupportedURL = -1002
Did you figure this out? I'm trying to do this as well

Have you solved it? I'm stuck with this as well

how to play a private video from AWS S3 using AVPlayer.
 
 
Q