MPMoviePlayerController并在后台播放来自其他应用程序的音频,例如spotify

时间:2015-02-28 14:31:41

标签: ios swift mpmovieplayercontroller avaudioplayer avaudiosession

我使用MPMoviePlayerController,我希望用户能够观看包含音频的视频,并能够继续收听已经在后台运行的Spotify或其他音乐应用。如何让我的应用程序播放电影并允许用户继续听音乐?

        self.moviePlayer = MPMoviePlayerController(contentURL: url)
        if var player = self.moviePlayer {
            // let the preview loop
            self.stopPreview = false
            UIApplication.sharedApplication().statusBarHidden=true
            player.view.frame = self.view.bounds
            player.prepareToPlay()
            player.scalingMode = .AspectFill
            player.controlStyle = .None
            self.view.addSubview(player.view)

            // custom UI preview controlls
            // Back button and send buttons
            self.view.addSubview(self.confirmationView)
            self.view.bringSubviewToFront(self.confirmationView)
        }

0 个答案:

没有答案