【问题标题】:Cant Play the Video in Custome Tableview Cell无法在自定义 Uitableviewcell 中播放视频
【发布时间】:2016-11-01 12:36:18
【问题描述】:

我在单元格容器中创建服装单元格,我需要播放视频但我尝试使用我的代码显示为空..

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
    {
        let cell = tableView.dequeueReusableCell(withIdentifier: "VedioCell", for: indexPath) as! FeedCell

        let videoURL = NSURL(string: "http://clips.vorwaerts-gmbh.de/VfE_html5.mp4")
        let player = AVPlayer(url: videoURL! as URL)

        let playerLayer = AVPlayerLayer(player: player)
        playerLayer.frame = cell.bounds

        cell.layer.addSublayer(playerLayer)
        player.play()



        return cell
    }

提前致谢

【问题讨论】:

    标签: ios swift uitableview avplayer tableviewcell


    【解决方案1】:

    func tableView(_tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell: FeedCell = tableView.dequeueReusableCell(withIdentifier: "VedioCell", for: indexPath) as! FeedCell
    
        let player = playerArray[indexPath.row]
        let playerLayer = AVPlayerLayer(player: player)
        playerLayer.frame = CGRect(x:0, y: 0, width: UIScreen.main.bounds.width, height: 200)
       cell.PlayerView?.layer.addSublayer(playerLayer)
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多