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 08-24-2008, 12:42 PM   #1 (permalink)
GabeJacobs
Registered Member
 
Join Date: Aug 2008
Posts: 50
GabeJacobs is on a distinguished road
Exclamation Help Please, Playing A Short Sound Tutorial Not Working

I've looked at the "Playing A Short Sound" tutorial many times, making sure all my code is correct. My code compiles, but I hear no sound. I think something may have changed with the new SDK..

anyways, here is my code, please help.

MainView.H

Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@class SoundEffect;

@interface MainView : UIView {
    IBOutlet UIImageView *thunderImage;
	SoundEffect *soundEffect;
}

@end
MainView.M

Code:
#import "MainView.h"
#import "SoundEffect.h"

@implementation MainView 

-(void) awakeFromNib {


	NSBundle *mainBundle = [NSBundle mainBundle];
	soundEffect = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle pathForResource:@"cat" ofType:@"wav"]];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

	[soundEffect play];
}
SoundEffect.H

Code:
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>


@interface SoundEffect : NSObject {
	SystemSoundID soundID;
}
- (id) initWithContentsOfFile:(NSString *)path; 
-(void)play;

@end
SoundEffect.M

Code:
#import "SoundEffect.h"


@implementation SoundEffect

- (id) initWithContentsOfFile:(NSString *)path;
{
	self = [super init];
	if (self != nil) {
		NSURL *filePath = [NSURL fileURLWithPath: path isDirectory:NO];
		
		AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
		}
		return self;
}

		
-(void)play { 
			
			AudioServicesPlaySystemSound(soundID); 
		}
		
		
		
		@end
Any help would be greatly appreciated. Thank you

Last edited by GabeJacobs; 08-24-2008 at 12:50 PM.
GabeJacobs is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,418
Threads: 94,016
Posts: 402,536
Top Poster: BrianSlick (7,978)
Welcome to our newest member, deepobjectsol
Powered by vBadvanced CMPS v3.1.0

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