2017-07-07 162 views
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") 
    } 

回答

0

錯誤它的自我,顯然告訴你,

值類型的「AVPlayer?沒有會員'查看'

因爲AVPlayer不是UIView的子類。它並沒有和任何財產叫view

而代碼行player.view.addSubview(view)無法執行。

+0

謝謝,但我怎樣才能實現全屏幕模式視頻播放時雙擊。我花了兩天請 – cristainlika3

+0

你可以分享任何演示項目? @ cristainlika3 –