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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 05-24-2009, 12:37 AM   #26 (permalink)
deansx
Objective-C Code Monkey
 
deansx's Avatar
 
Join Date: May 2009
Location: Mountain View, CA
Posts: 127
Default

.m file

Code:

#import "StopSoundViewController.h"

@implementation StopSoundViewController




// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	theAudio = nil;
}

- (IBAction) soundButtonPressed:(UIButton *)button {
	NSLog(@"SoundButton Pressed");
	if (theAudio == nil) {
		// Set up the player.
		NSLog(@"Set up theAudio");
		NSString *path = [[NSBundle mainBundle] pathForResource:@"boom" ofType:@"wav"];
		theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
		theAudio.delegate = self;
		[theAudio play];
	}
	else if ([theAudio isPlaying]) {
		// there's no point in stopping it, if it's not playing...
		NSLog(@"Stopping theAudio");
		[theAudio stop];
	}
	else {
		NSLog(@"Starting theAudio, again");
		[theAudio play];
	}
	
}

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
	NSLog(@"Player Finished Playing");
}

/* if an error occurs while decoding it will be reported to the delegate. */
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error {
	NSLog(@"Error Decode...");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
	// I know that I haven't done this.  This is just a sample.
}

@end
deansx is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,852
Threads: 89,216
Posts: 380,666
Top Poster: BrianSlick (7,129)
Welcome to our newest member, syrreintyia1
Powered by vBadvanced CMPS v3.1.0

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