目前,这就是我在 UIViewController 的子视图上播放视频的方式:
override func viewDidAppear(animated: Bool) {
let filePath = NSBundle.mainBundle().pathForResource("musicvideo", ofType: "mp4")
self.moviePlayerController.contentURL = NSURL.fileURLWithPath(filePath)
self.moviePlayerController.play()
self.moviePlayerController.repeatMode = .One
self.moviePlayerController.view.frame = self.view.bounds
self.moviePlayerController.scalingMode = .AspectFill
self.moviePlayerController.controlStyle = .None
self.moviePlayerController.allowsAirPlay = false
self.view.addSubview(self.moviePlayerController.view)
}
我已经阅读了通过执行以下操作来禁用音频的方法(根本不起作用)。请记住,我正在尝试禁用它,以免中断通过音乐应用程序、Spotify 等播放的当前音乐。
// Playing media items with the applicationMusicPlayer will restore the user's Music state after the application quits.
// The current volume of playing music, in the range of 0.0 to 1.0.
// This property is deprecated -- use MPVolumeView for volume control instead.
1)MPMusicPlayerController.applicationMusicPlayer().volume = 0
2)MPVolumeView
甚至没有设置实际音量的设置?这是一个控制。
3)self.moviePlayerController.useApplicationAudioSession = false