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 02-01-2011, 12:42 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 33
Oyousif is on a distinguished road
Default Pressing a Button and having an audio file play.

I was hoping if anyone knew the way to press a button and a audio file played? And help would be excellent.
Oyousif is offline   Reply With Quote
Old 02-01-2011, 01:00 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 35
mdiak47 is on a distinguished road
Default

Yes...there is a way to do this. Create an AVAudioPlayer Object.
Code:
#import <AVFoundation/AVAudioPlayer.h>

@interface Example : UIViewController <AVAudioPlayerDelegate>
Code:
NSString *path10 = [[NSBundle mainBundle] pathForResource: @"..." ofType:@"wav"];
NSURL *file10 = [[NSURL alloc] initFileURLWithPath:path10];
	
AVAudioPlayer *p10 = [[AVAudioPlayer alloc] initWithContentsOfURL:file10 error:nil];
	
[file10 release];
	
self.player10 = p10; 
[p10 release];
	
[player10 prepareToPlay];
[player10 setDelegate:self];
Code:
- (IBAction)playSoundAction11 
{
	[self.player10 play];
}
mdiak47 is offline   Reply With Quote
Old 02-01-2011, 01:28 PM   #3 (permalink)
Registered Member
 
georgescott's Avatar
 
Join Date: Jan 2011
Location: Califorina
Posts: 33
georgescott is on a distinguished road
Default Ok but...

So I was looking for this and I am a beginner at objective C so help me out please.

I don't really get this. Are we supposed to make a new Objective C Class. then import it into the original header file.

Im sooo confused.

Can you please further explain it to me. Or if there is a tutorial online for this it would be much appreciated.
georgescott is offline   Reply With Quote
Old 02-01-2011, 06:07 PM   #4 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 35
mdiak47 is on a distinguished road
Default

It would help to learn Objective-C first...Go to the Apple website and search for documentation on the subject. After you read and understand that, you will understand what is going on there.
mdiak47 is offline   Reply With Quote
Old 02-02-2011, 12:36 PM   #5 (permalink)
Registered Member
 
georgescott's Avatar
 
Join Date: Jan 2011
Location: Califorina
Posts: 33
georgescott is on a distinguished road
Default

I'm using lynda.com to learn objective c.
and im have a blog at georgewscott.wordpress.com
georgescott is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, button

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: 362
14 members and 348 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

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