0

I am trying to stream a video from backend to my device.I have a video url from backend but screen displays nothing. However, youtube url it works. Can anyone guide me why this video is not playing and how can it be played? I am using pod 'YouTubePlayer' to play the video.

 let cell: VideoTableViewCell = tableView.dequeueReusableCell(withIdentifier: "VideoTableViewCell") as! VideoTableViewCell
    var query = PFQuery(className:"Videos")

   query.getObjectInBackground(withId: "83kli72i62") { (parseObject, error) -> Void in
      let videoFile = parseObject!["Question"] as! PFFileObject
      self.videoUrl = videoFile.url
    let url = NSURL(string: self.videoUrl! )
    cell.playerView.loadVideoURL(url as! URL)

    }

 
iron
  • 715
  • 1
  • 6
  • 15
  • Maybe it is the content type of your video link. Could you check what is the content type that you have and/or share the link? – Davi Macêdo Sep 06 '21 at 20:05

1 Answers1

1

i have an app that is pulling videos from firebase and playing them with the avplayer, check out my code below and see how it works

class IsoLateralLowRowViewController: UIViewController {
    @IBOutlet weak var playv: UIButton!
    
  
    let avPlayerViewController = AVPlayerViewController()
    var avPlayer:AVPlayer?


    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.addBackground()
      
        let movieUrl:NSURL? = NSURL(string: "https://firebasestorage.googleapis.com/v0/b/messenger-test-d225b.appspot.com/o/test%2FTestVideo.mov?alt=media&token=bd4ccba3-b446-43bc-809e-b1152aa3c2ff")
        if let url = movieUrl {
        self.avPlayer = AVPlayer(url: url as URL)
        self.avPlayerViewController.player = self.avPlayer
        }
        NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: avPlayerViewController.player?.currentItem)
        
        
        self.present(self.avPlayerViewController, animated: true) { () -> Void in
                self.avPlayerViewController.player?.play()        // Do any additional setup after loading the view.
        }
    }
    
    @objc func playerDidFinishPlaying(note: NSNotification) {
            self.avPlayerViewController.dismiss(animated: true)
        }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }
   
flutterloop
  • 546
  • 3
  • 15