Nah*_*han 5 avfoundation ios swift swift3
我正在关注本教程:https : //miguesaldana.me/2017/03/13/how-to-create-a-soundcloud-like-waveform-in-swift-3/
我的代码如下。有一个例外:
错误域=com.apple.coreaudio.avfaudio Code=2003334207 “(null)” UserInfo={failed call=ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)}
let file = try! AVAudioFile(forReading: AudioLink) //Got Exception Here
let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: file.fileFormat.sampleRate, channels: file.fileFormat.channelCount, interleaved: false)
print(file.fileFormat.channelCount)
let buf = AVAudioPCMBuffer(pcmFormat: format!, frameCapacity: UInt32(file.length))
try! file.read(into: buf!)
// print("floatArray \(readFile.arrayFloatValues)\n")
//self.waveFormView.setNeedsDisplay()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
484 次 |
| 最近记录: |