Easy Audio Playback With AVAudioPlayer – Tutorial [Mobile Orchard]


Can you guess what I’ve been doing lately?

Here’s another great tutorial from Dan Grigsby of Mobile Orchard, this time on playing audio with the AVAudioPlayer in the iOS SDK…

Tutorial: Easy Audio Playback With AVAudioPlayer

The iPhone SDK’s AVFoundation framework includes AVAudioPlayer, an easy, feature rich, Objective-C based way of playing audio files.

This tutorial demonstrates how to use AVAudioPlayer. When you’ve finished the tutorial you’ll have created a simple app that plays an MP3 audio file in a loop when the app starts.




Fixing the Mac OS X Zoom Button

I love Mac OS X, but there’s been something that has always annoyed me about mac resizing behavior, even back to the days when I started using Macs with System 6.x, and that’s the Zoom button behavior. I get what it’s supposed to do, but I never agreed with it and never used it for that purpose… one of the only things Windows got kinda right was Maximize, so here’s a tip for making the Zoom button behave like a maximize button. The nice thing is that the Right Zoom application can be configured selectively. 

Make the OS X maximize button work like Windows
One very, very common question/complaint from folks who have recently switched from Windows to Mac is “Why does the green button only resize windows and apps?”. It’s a totally valid question – the resizing behavior has always annoyed me too, and I made the switch years ago. Fortunately, there’s a very small and perfectly customizable program called Right Zoom that will change the default behavior and truly maximize programs when you click the green “Zoom” button” (). This tutorial will show you how to use it and set it up to best suit your needs.

Hope it helps.


Monitoring AVAudioRecorder Input on iOS

For a project I’m working on, I needed to know how to monitor the input level using AVAudioRecorder. Thankfully, this post from Dan Grigsby was very helpful in setting up the polling mechanism (though you might not guess it from the title!):

Tutorial: Detecting When A User Blows Into The Mic

If, a couple of years back, you’d told me that people would expect to be able to shake their phone or blow into the mic to make something happen I would have laughed. And here we are.

Detecting a shake gesture is straightforward, all the more so in 3.0 with the introduction of motion events.

Detecting when a user blows into the microphone is a bit more difficult. In this tutorial we’ll create a simple simple single-view app that writes a log message to the console when a user blows into the mic.

Thanks, Dan!

Selectors in Objective-C

I ran into this one yesterday since I needed to create a delegate method that took a couple arguments, and it wasn’t clear to me what the correct syntax was when one had more than one. So thanks to Adam Rosenfield on Stackoverflow for this one (he helped clear up another issue I was researching a couple of weeks ago but I failed to blog about that one I think…).

Selectors in Objective C – Stack Overflow:

You have to be very careful about the method names. In this case, the method name is just “lowercaseString”, not “lowercaseString:” (note the absence of the colon). That’s why you’re getting NO returned, because NSString objects respond to the lowercaseString message but not the lowercaseString: message.

How do you know when to add a colon? You add a colon to the message name if you would add a colon when calling it, which happens if it takes one argument. If it takes zero arguments (as is the case with lowercaseString), then there is no colon. If it takes more than one argument, you have to add the extra argument names along with their colons, as in compare:options:range:locale:. You can also look at the documentation and note the presence or absence of a trailing colon.