Adding custom full screen video player in UITableView , Not Working Properly

Viewed 21

enter image description here

extension ReelsVc : UITableViewDelegate,UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 4
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "ReelsTableViewCell", for: indexPath) as! ReelsTableViewCell
        
       let url = URL(string: "https://res.cloudinary.com/ajeethkumar707/video/upload/v1662359768/samples/elephants.mp4")
       // let url = URL(string: "https://www.youtube.com/watch?v=AwG-AtAtiB8")
            player = AVPlayer(url: url!)
            playerLayer = AVPlayerLayer(player: player)
        playerLayer.videoGravity = .resizeAspectFill
            cell.videoView.layer.addSublayer(playerLayer)
        playerLayer.frame = cell.videoView.frame
       
//        cell.videoView.clipsToBounds = true
            cell.videoView.clipsToBounds = false
    
           // player.rate = 1.0
            player.play()
        
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return reelsTableView.frame.size.height
    }
}
0 Answers
Related