Tag ‘audio’

iPhone hidden features: Bluetooth headset support and Voice Control

Mauro Dalu

iphone-voice-control-bluetooth-headset-musicThis is the first of an article series about features our iPhones have that are not-so-obivous until you find them and try them once. All these features are explained somewhere on the web, and most of them are well detailed on Apple’s website, but, if you’re like me, you’re not going to explore that website searching for features of your iPhone – you’ll search for a feature the moment you need it.

Voice Control is a new feature Apple introduced with the iPhone 3GS. You can use your voice to make a call or to play music… even through a bluetooth headset.

Continue reading

iPhone Audio: System Sound vs AVAudioPlayer

Radu Cojocaru

You want to play a short sound on certain actions (view swipe, data saved, data deleted) and the first question is: what library should I use, System Sound or AVAudioPlayer? Both libraries are fine for playing short sounds, but Apple recommends using AVAudioPlayer.

System Sound Services (AudioToolbox.framework) is a collection of C functions and it can be used to play short sounds of 30 seconds or less (it can also be used to vibrate the iPhone).

AVAudioPlayer class (AVFoundation.framework) provides a simple Objective-C interface for playing sounds (it was introduced in version 2.2). It can play audio data of any duration, from a file or memory. AVAudioPlayerDelegate Protocol allows you to handle interruptions (such as an incoming phone call) and to be notified when a sound has finished playing.

Example of using AVAudioPlayer:

NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:@”audio_file” ofType:@”wav”];
NSURL *audioFileURL = [NSURL fileURLWithPath:audioFilePath];
AVAudioPlayer *audioPlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL

Continue reading