First, we added a navigation control by embedding it from the drop down menu, created a second interface controller, and created a new Cocoa Touch class file and named it playSoundsViewController and connected it from the Record button on the main screen. So that when you click on the record button it takes you to the next screen. [NOTE: Make sure you name the file properly or it won't let y ou drag outlets or actions. Once you create a new screen and file, click on the new screen and go to the Identity Inspector and type in the new file's name, it will auto fill.]
Then we learnt how to add an mp3 file to the project and access using AV Foundation. We created a path to the audio file in the viewDidLoad section by creating a var filepath and using NSBundle with its subclass mainBundle.
We created an instance of the AVAudio player and converted NSString to NSUrl.
We added two buttons, playfast and playslow and connected them to the interface so they play the embedded audio file at the corresponding speeds by using the rate method in the AVAudioPlayer class.
We make sure the file, when accessed either plays the mp3 or returns an error message if the entry is invalid. Also, we need to have the variable audioPlayer needs to be a global variable so it can be accessed from other functions. [NOTE: I was redoing the lesson so I could take down all the steps, and was stuck on this error I didn't get before 'EXC_BAD_INSTRUCTION code=EXC_1386_INVOP'. Spent over an hour fixing this, then while comparing to the earlier working code, realised I had put - instead of _ in the mp3 file name. So in case you get that error, it could be this.]
We are supposed to take the common pieces of code and create a new function butI'm not sure where to add the function to, so I'll see if that gets addressed in the next lesson.