- draw waveform of mp3 file on screen
- draw current play position
- zoom-in and zoom-out waveform while playing
- use swift 3 version
- Install library : add pod 'waveFormLibrary', '~> 1.0' similar to the following to your Podfile:
target 'MyApp' do
pod 'waveFormLibrary', '~> 1.0'
end
Then run a pod install inside your terminal, or from CocoaPods.app.
- Use storyboard
-The first : add a UIView(which you want to hold waveform view) to your view, in identity inspector
change custom class to ControllerWaveForm
class.
-Now you can change waveform line color and current play position line color in attribute inspector
-Connect your waveForm view to viewController
@IBOutlet weak var controller: ControllerWaveForm!
set mp3 url which you need draw waveform
controller.setMp3Url(mp3Url: url)
-In this example I create mp3 url by copy file 02.mp3 to my project and then add below code
let mp3file = Bundle.main.path(forResource: "02", ofType: "mp3")
let url = URL(fileURLWithPath: mp3file!)
- Please email me thongds@gmail.com if you need help!