My first iPhone app – Part 3

Waveform of Audio File

Installing

I’ve tried a component FDWaveformView. It uses CocoaPods, a dependecy management tool like Python’s pip or Rust’s cargo.

sudo gem install cocoapods

To add CocoaPods support to an existing project you must add a Podfile

cd XcodeProjects/PlayalongTrainer
touch Podfile

The content of the Podfile is pretty straght forward:

target 'PlayalongTrainer' do
    use_frameworks!
    pod 'FDWaveformView', '~> 2.0.1'
end
pod install

This creates a xcworkspace file which you have to use instead of the xcodeproj file to open the project.

open <YourProjectName>.xcworkspace

Integrating FDWaveformView

When you opened the workspace you have to compile the pods before you can use them. To use the library you add a view via InterfaceBuilder and assign FDWaveformView as a custom class. Then you can do the setup

 self.waveform.delegate = self
 self.waveform.alpha = 0.0
 self.waveform.audioURL = url
 self.waveform.progressSamples = 10000
 self.waveform.doesAllowScrubbing = true
 self.waveform.doesAllowStretch = true
 self.waveform.doesAllowScroll = true
 self.waveform.wavesColor = Stylesheet.Colors.DarkGray
 self.waveform.progressColor = Stylesheet.Colors.LightBlue

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *