【问题标题】:How to create a wave visualiser from AVPlayerItem? (iOS)如何从 AVPlayerItem 创建波形可视化器? (iOS)
【发布时间】:2018-05-16 11:02:50
【问题描述】:

我一直在使用这个 https://github.com/teodorpatras/Jukebox 库来帮助播放来自 URL 的音频,但我在尝试创建像 https://github.com/ApplikeySolutions/PandoraPlayer 这样的波形可视化器时遇到了问题,但它只允许从音乐库播放。在 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)
}

【问题讨论】:

    标签: ios swift audio buffer


    【解决方案1】:

    参考这个https://github.com/alankarmisra/SwiftSiriWaveformView 这将帮助您创建波形。

    @IBOutlet weak var audioView: SwiftSiriWaveformView!
    

    你可以使用

    audioView.amplitude = 1.0
    

    安装(CocoaPods):

    SwiftSiriWaveformView 可通过 CocoaPods 获得。要安装它, 只需将以下行添加到您的 Podfile 中:

    对于 Cocoapods >= 1.0 使用框架!目标“YOUR_PROJECT_NAME”做 pod "SwiftSiriWaveformView" end 对于 Cocoapods

    【讨论】:

    • 嗨,Sachin,这是一种可视化音乐波的好方法,谢谢,但是如果我使用它,我还有一个问题,那就是我正在使用 AVPlayer 流式传输音频,我需要以某种方式制作它指向您发送给我的可视化工具的链接。
    【解决方案2】:

    尝试将此 pod 与 Cocoa Pods 一起使用 pod 'SpeechRecognizerButton' 很棒的东西,而且很简单。

    链接:https://github.com/alexruperez/SpeechRecognizerButton

    【讨论】:

    • 这很好,但这只能用于来自外部的输入音频,我需要获取当前流歌曲的内部音频然后操作波形。知道怎么做吗?
    猜你喜欢
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 2012-03-19
    • 1970-01-01
    相关资源
    最近更新 更多