gpt4 book ai didi

swift 。在应用启动时创建介绍视频

转载 作者:可可西里 更新时间:2023-11-01 00:59:12 24 4
gpt4 key购买 nike

我想在我的应用启动时播放本地视频作为介绍视频。用户不应该以任何方式取消或暂停视频,知道我该怎么做吗?

import AVKit
import AVFoundation

class GetInfoView: SKScene {

var moviePlayer = AVPlayerViewController()
var player = AVPlayer()

override func didMoveToView(view: SKView) {

player = AVPlayer(URL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("intro", ofType: "mp4")!))
moviePlayer.showsPlaybackControls = false
moviePlayer.player = player

self.view?.window?.rootViewController?.presentViewController(moviePlayer, animated: false){
moviePlayer.player?.play()
}
}
}

我试过了,但是当它运行时 player = AVPlayer(URL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("intro", ofType: "mp4")!)) 它崩溃了。

错误:

"fatal error: unexpectedly found nil while unwrapping an Optional value"

我不知道问题出在哪里,我确实在构建中添加了“intro.mp4”

最佳答案

添加你的电影项目。File Inspector -> Project name -> Targets -> Project Name -> Build Phases -> Copy Bundle Resources -> + button

关于 swift 。在应用启动时创建介绍视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38125579/

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