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

View Single Post
Old 10-09-2010, 11:56 AM   #3 (permalink)
redon
Hot Cocoa Touch
 
redon's Avatar
 
Join Date: Oct 2009
Location: Florida
Posts: 193
redon is on a distinguished road
Default

Quote:
Originally Posted by edcousins View Post
Hi guys,

I'm just starting to get into iPhone development myself, and have a quick question that I hope someone can help me out with.

I have the code below that plays a sound when the connected button is pressed:

Code:
- (IBAction)playsound1 {
	NSString *path = [[NSBundle mainBundle] pathForResource:@"FILENAME" ofType:@"mp3"];
	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	theAudio.delegate = self;
	[theAudio play];
}
What I want to do is add some code to this so that if another button is pressed, it stops the above sound, while the other sound starts.

Can anyone help me out with this?

Thanks in advance
Code:
[theAudio stop];
[theAudio release];
__________________
http://www.bugspray.me/
Search GetFit! on the App Store.
redon is offline   Reply With Quote
 

» Advertisements
» Online Users: 438
15 members and 423 guests
antonwilliams, Chickenrig, dobry, Domele, EvilElf, Gaz, hrushikeshaddon, iconomania, ipodphone, jaychoupham, linkmx, raymng, santicarlo, Techknol, TunaNugget
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,589
Threads: 94,083
Posts: 402,776
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Techknol
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:54 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.