我一直在使用这个https://github.com/teodorpatras/Jukebox库来帮助播放来自网址的音频,但我遇到了尝试创建像此https://github.com/ApplikeySolutions/PandoraPlayer这样的wave可视化工具的问题,但它只允许从音乐库播放。在Pandora Player中有开源波形可视化器https://github.com/ApplikeySolutions/PandoraPlayer/issues/3,但它需要转换为某种类型的缓冲区
public func audioPlayer(_ audioPlayer: EZAudioPlayer!, playedAudio buffer: UnsafeMutablePointer<UnsafeMutablePointer<Float>?>!, withBufferSize bufferSize: UInt32, withNumberOfChannels numberOfChannels: UInt32, in audioFile: EZAudioFile!) {
DispatchQueue.main.async {[weak self] in
self?.updatePlaybackStatus()
}
self.waveVisualizer?.updateWaveWithBuffer(buffer, withBufferSize: bufferSize, withNumberOfChannels: numberOfChannels)
}
答案 0 :(得分:3)
参考此https://github.com/alankarmisra/SwiftSiriWaveformView这将有助于您创建波形。
@IBOutlet weak var audioView: SwiftSiriWaveformView!
你可以使用
audioView.amplitude = 1.0
安装(CocoaPods):
SwiftSiriWaveformView可通过CocoaPods获得。要安装它, 只需将以下行添加到您的Podfile:
对于Cocoapods&gt; = 1.0 use_frameworks!目标“YOUR_PROJECT_NAME”做 pod“SwiftSiriWaveformView”结束对于Cocoapods&lt; 1.0 use_frameworks! pod“SwiftSiriWaveformView”
答案 1 :(得分:0)
尝试将此pod与Cocoa Pod pod 'SpeechRecognizerButton'
一起使用
很棒的事情,只是定制。