不符合任何可用过载(FileURLWithPath)

问题描述 投票:0回答:1

我不能得到这个代码工作,我不断收到一个错误说:

参数标签“(FileURLWithPath :)”不匹配任何可用过载

do {
    audioPlayer = try
        AVAudioPlayer(contentsOf:
            URL(FileURLWithPath: sound!))
    audioPlayer.prepareToPlay()
} catch {
    print("error")
}

你有什么建议吗?

url avaudioplayer
1个回答
0
投票

其中提到的错误Argument labels '(FileURLWithPath:)' do not match any available overloads是相当显着。

更换

AVAudioPlayer(contentsOf: URL(FileURLWithPath: sound!))

AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))
© www.soinside.com 2019 - 2024. All rights reserved.