我想了解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种方法的代表?
我不想出示它,我希望它被嵌入到视图中... –