gpt4 book ai didi

ios - 使用 MPMoviePlayerController 和 Swift 播放电影

转载 作者:行者123 更新时间:2023-11-28 07:15:12 25 4
gpt4 key购买 nike

我正在尝试将 MPMoviePlayerController 作为 View 的 subview ,但我正在尝试使用 Swift 来做到这一点,这是我目前所做的:

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.

let moviePath = NSBundle.mainBundle().pathForResource("splash", ofType: "mp4")
let movieURL = NSURL.fileURLWithPath(moviePath!)

let moviePlayer = MPMoviePlayerController(contentURL: movieURL)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayerDidFinishPlaying:" , name: MPMoviePlayerPlaybackDidFinishNotification, object: moviePlayer)

moviePlayer.controlStyle = .None
moviePlayer.scalingMode = .Fill
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.play()
}

func moviePlayerDidFinishPlaying(notification: NSNotification) {

}

它不工作,我在这里做错了什么?

最佳答案

您可能忘记将您的资源添加为“捆绑资源”按照以下步骤添加:

  1. 在 Project Navigator 中选择您的项目根目录
  2. 选择“构建阶段”选项卡
  3. 在“捆绑资源”部分点击“+”添加您的资源

在那之后,我认为您可以让您的代码正常工作。

关于ios - 使用 MPMoviePlayerController 和 Swift 播放电影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26650173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com