Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-29-2009, 04:31 AM   #1 (permalink)
nikvpat
 
nikvpat's Avatar
 
Join Date: Jan 2009
Location: India
Age: 25
Posts: 105
nikvpat is on a distinguished road
Default Play sound on button click???

Hi all

I want to play a sound on button click..........

can any body give me some clue or any link to tutorial?????

Thanks in advance.
__________________
nikvpat
nikvpat is offline   Reply With Quote
Old 01-29-2009, 06:27 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

Here's one that helped me.

Matt Legend Gemmell – What have you tried?
lbendlin is offline   Reply With Quote
Old 01-29-2009, 10:50 PM   #3 (permalink)
nikvpat
 
nikvpat's Avatar
 
Join Date: Jan 2009
Location: India
Age: 25
Posts: 105
nikvpat is on a distinguished road
Default

Hi lbendlin

Thanks for helping me.

I didn't find any link there or i didn't get how to look for link given by you.

Can you please be more elaborative?????
__________________
nikvpat
nikvpat is offline   Reply With Quote
Old 01-29-2009, 10:54 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 32
genemartone is on a distinguished road
Default

have a look into this function

OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)pathToS ound, &theSound);

provided its a short sounds it works well...


Part of the AudioToolBox framework
genemartone is offline   Reply With Quote
Old 01-29-2009, 10:56 PM   #5 (permalink)
Tutorial Author
 
Steaps's Avatar
 
Join Date: Oct 2008
Location: Ontario, Canada
Posts: 464
Steaps is on a distinguished road
Default

Quote:
Originally Posted by nikvpat View Post
Hi lbendlin

Thanks for helping me.

I didn't find any link there or i didn't get how to look for link given by you.

Can you please be more elaborative?????
He's asking what have you tried. You need to post some information.
After reading that, i now know i need to too sometimes.
Steaps is offline   Reply With Quote
Old 01-30-2009, 02:54 AM   #6 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 32
genemartone is on a distinguished road
Default

Here's a code snip again it needs to be a short sound but this works ok

SystemSoundID theSound;
NSURL *pathToChickenSound;
NSString *pathToSound;

//set up where the sounds is within the app bundle
pathToSound = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"best" ofType:@"wav"] isDirectory:NO];



Call to initialize / load the sound into memory for use
OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)pathToS ound, &theSound);


//play the sound
AudioServicesPlaySystemSound (theSound);


Hope this give a little more assistance..
genemartone is offline   Reply With Quote
Old 01-30-2009, 06:37 AM   #7 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 429
lbendlin is on a distinguished road
Default

Don't forget to destroy the sound object when you are done.
lbendlin is offline   Reply With Quote
Old 02-01-2009, 11:24 PM   #8 (permalink)
nikvpat
 
nikvpat's Avatar
 
Join Date: Jan 2009
Location: India
Age: 25
Posts: 105
nikvpat is on a distinguished road
Default

Hey guys

Thanks for all your help..............

it really helped me searching more....................

thanks a lot!!!!!!!!!!!!!

happy coding
__________________
nikvpat
nikvpat is offline   Reply With Quote
Reply

Bookmarks

Tags
audio file play, sound play

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
6 members and 317 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog, Objective Zero
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:36 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0