0
我想實現播放表視圖單元格中的視頻,它工作正常。現在我想在雙擊時以全屏模式播放該視頻。我不確定,如何實現這一點。並嘗試與UITapGestureRecognizer
雙擊時,它將是全屏模式,但我收到以下錯誤。Tableview單元格播放視頻時,雙擊然後它將全屏模式
'AVPlayer?'類型的值沒有成員 '視圖'
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
let videoURL = URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(url: videoURL!)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = cell.bounds
cell.layer.addSublayer(playerLayer)
player.play()
//handle full screen mode
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.handleTap))
let view = UIView(frame: cell.contentView.frame)
view.addGestureRecognizer(tapGesture)
//player.view.addSubview(view) // /// Value of type 'AVPlayer?' has no member 'view'
return cell
}
func handleTap(_ recognizer: UITapGestureRecognizer) {
print("tap tap")
}
謝謝,但我怎樣才能實現全屏幕模式視頻播放時雙擊。我花了兩天請 – cristainlika3
你可以分享任何演示項目? @ cristainlika3 –