Check example project inside
Swift 5
A UIView subclass that displays waveform of a provided local audio file.
This view has 2 gesture recognizers attached:
UITapGestureRecognizer
- Play - Pause associated with a view audio file.UIPanGestureRecognizer
- Seek audio file to specified position.
There are 3 public properties:
normalColor
- default color of waveform, fills section of waveform that is yet to be played.progressColor
- already played section of waveform has this color.allowSpacing
- inserts a little spacing between bars in waveform.
Example:
let waveform = try ASWaveformPlayerView(audioURL: audioURL, // URL to local a audio file
sampleCount: 1024, // higher numbers makes waveform more detailed
amplificationFactor: 500) // constant that affects height of each 'bar' in waveform
waveform.normalColor = .lightGray
waveform.progressColor = .orange
//with high sampleCount passed to init method to avoid artifacts set this to false
waveform.allowSpacing = false
Alexey Savchenko, [email protected]
ASWaveformPlayerView is available under the MIT license. See the LICENSE file for more info.