gpt4 book ai didi

ios - Swift AVPlayer 无法播放 MP4 : Play Button With Line Through It

转载 作者:可可西里 更新时间:2023-11-01 04:28:42 25 4
gpt4 key购买 nike

enter image description here

我正在尝试在 iOS 应用程序上播放来自本地文件系统的 mp4 视频。视频时长约一个小时,可以在 quicktime 上播放。如果来自网络(NSURL(字符串:“http:domain.com/vid.mp4”)),我可以播放 mp4。我正在播放如下视频:

    let steamingURL:NSURL = NSURL(string: video.filePath)! //valid path
let player = AVPlayer(URL: steamingURL)
player.allowsExternalPlayback = false

PlayWorkoutViewController.playerController = AVPlayerViewController()
PlayWorkoutViewController.playerController.player = player
self.addChildViewController(PlayWorkoutViewController.playerController)
self.view.addSubview(PlayWorkoutViewController.playerController.view)
PlayWorkoutViewController.playerController.view.frame = videoContainerView.frame
PlayWorkoutViewController.playerController.showsPlaybackControls = false
player.play()

我是否需要更改某些设置才能播放更长的视频?谢谢。

最佳答案

先检查steamingURL是否为nil

如果你想使用 NSURL(string: "xxx") 初始化器,请检查以 file://开头的字符串,否则使用 NSURL(fileURLWithPath: "xxxx") 代替。

关于ios - Swift AVPlayer 无法播放 MP4 : Play Button With Line Through It,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34427636/

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