我想了解AVPlayer & AVPlayerController的工作原理。 我在視圖中嵌入了我的播放器,所以我的播放器有兩種模式:小屏幕&全屏。 當播放/播放按鈕和全屏按鈕很少播放時很好。但一旦它是全屏幕,下面的按鈕不起作用:播放,暫停,完成,最小化。AVPlayerController - 按鈕無法在全屏幕上工作
這裏是我的代碼:
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let avPlayer:AVPLayer = AVPlayer(url: videoURL! as URL)
let playerController = AVPlayerViewController()
playerController.player = avPlayer
playerController.view.backgroundColor = UIColor.racingGreenColor();
playerController.view.translatesAutoresizingMaskIntoConstraints = false;
playerController.showsPlaybackControls = true;
self.middleView.addSubview(playerController.view)
//avPlayer.play()
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .width, relatedBy: .equal, toItem: self.middleView, attribute: .width, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .height, relatedBy: .equal, toItem: self.middleView, attribute: .height, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .centerX, relatedBy: .equal, toItem: self.middleView, attribute: .centerX, multiplier: 1, constant: 0));
self.middleView.addConstraint(NSLayoutConstraint(item: playerController.view, attribute: .centerY, relatedBy: .equal, toItem: self.middleView, attribute: .centerY, multiplier: 1, constant: 0));
有人能幫助我嗎? 是否有我感興趣的4種方法的代表?
我不想出示它,我希望它被嵌入到視圖中... –