如何修复
我的Xcode 8项目出现init(URL :)已重命名为init(url :)
错误? 这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
// Load the video from the app bundle.
let videoURL: NSURL = Bundle.main.url(forResource: "IMG_4628", withExtension: "mp4")! as NSURL
player = AVPlayer (URL: videoURL)
player?.actionAtItemEnd = .none
player?.isMuted = true
let playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
playerLayer.zPosition = -1
playerLayer.frame = view.frame
view.layer.addSublayer(playerLayer)
player?.play()
//loop video
如何解决行player = AVPlayer(URL: videoURL)
中的错误?
感谢。
答案 0 :(得分:1)
您应该在初始化程序中用URL
替换大写的url
。
player = AVPlayer(url: videoURL)
答案 1 :(得分:0)
只需使用以下代码替换。
player = AVPlayer(url:videoURL!as URL)