相关疑难解决方法(0)

使用Swift禁用MPMoviePlayerController的音频(和中断)

目前,这就是我在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)
}
Run Code Online (Sandbox Code Playgroud)

我已经通过以下方式阅读了关于禁用音频的方法(根本没有工作).请记住,我正在尝试禁用它,以便不通过音乐应用程序,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.
Run Code Online (Sandbox Code Playgroud)

1) MPMusicPlayerController.applicationMusicPlayer().volume = …

mpmovieplayercontroller avplayer avplayerlayer swift

5
推荐指数
1
解决办法
2535
查看次数