Posts

Showing posts with the label iPhone

How to play an audio file in iOS using Swift 2.0 and Xcode 7.0

Image
How to play an audio file in iOS using Swift/Xcode version 7.0 I've also been fascinated by mobile applications. But I've spent most of my career coding desktop or web based applications. So I decided to change that by taking Udacity's Intro to iOS App Development with Swift . Good decision, right? Right. For the first project, we develop a very basic application which records audio and plays it back. The first iteration requires playing a predefined audio file back at different speeds (or rates, according to AVAudioPlayer nomenclature). Below are the high level steps and code samples to play an audio file using Swift 2.0. First things first, you need an audio file, say a movie_quote.mp3 somewhere on your file system.  Locate it! Drag that file from source directory to the target directory. In this case, the target directory is the Pitch Perfect project directory in Xcode. Now the file will be made available to the application source code. Make sure you select t