我正在尝试在 TableView Cell 中播放视频。我正在使用这段代码,但是当我运行时什么也不会出现。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let myCell:UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "myCell")!
let videoURL = NSURL(string: "http://techslides.com/demos/sample-videos/small.mp4")
let player = AVPlayer(url: videoURL! as URL)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = myCell.bounds
myCell.layer.addSublayer(playerLayer)
player.play()
return myCell
}
最佳答案
关于ios - 在 UItableView 单元格中快速播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40391699/