現時点では、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)
}
以下を実行してオーディオを無効にする方法を読みました(どれもまったく機能しません)。Musicアプリ、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