gpt4 book ai didi

ios - (OSStatus 错误 2003334207)从文件播放

转载 作者:行者123 更新时间:2023-11-28 16:10:45 25 4
gpt4 key购买 nike

我收到这个错误:

(OSStatus error 2003334207)

尝试从路径播放歌曲时,路径有效,因为我可以从目录播放 mp3,但我无法在音频播放器中播放它,路径如下所示 -

file:///XXXX/XXXX/Library/Developer/CoreSimulator/Devices/1ECD7193-872E-4108-A565-F12BED6A69E0/data/Containers/Data/Application/85FD4AD1-54AF-4AD1-81A2-3BDA5CCE9D0A/Documents/Blessings.mp3

let vc = ViewController()
var myAudioPlayer: AVAudioPlayer = AVAudioPlayer()

var downloadName = [String]()
var songDest = [String]()
var nameMusicFile = String()
var mp3Url : URL!

override func viewDidLoad() {
super.viewDidLoad()

print(downloadName)
print(songDest)
let convert = URL(fileURLWithPath: songDest[0])
playMusic(url: convert)
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}


func playMusic(url: URL) {

let path = url as URL!
do {


try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)

try AVAudioSession.sharedInstance().setActive(true)
try myAudioPlayer = AVAudioPlayer(contentsOf: path!)
myAudioPlayer.volume = 1
myAudioPlayer.play()
} catch let err as NSError{
print(err.localizedDescription)
}
}

最佳答案

通常当您尝试访问指定文件夹中不存在的文件或尝试解包具有 nil 值的变量时,会发生此错误。PL。检查 fetchedResultController 是否返回一个对象。

关于ios - (OSStatus 错误 2003334207)从文件播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39593874/

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