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, 01:04 PM   #3 (permalink)
11111111
New Member
 
Join Date: Aug 2008
Posts: 3
11111111 is on a distinguished road
Default

Quote:
Originally Posted by GabeJacobs View Post
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

make sure that u only tab once within braces (statements in your method)
see highlighted red
11111111 is offline   Reply With Quote
 

» Advertisements
» Online Users: 679
20 members and 659 guests
13dario13, ADY, AlanR917, Alex40, burntsoap, carlandrews, dcool, doffing81, Droverson, estherkt98, matador1978, MysticLine, ncc1701e, pierresinne, ryantcb, SamorodovAlex, SLIC, Thompson22, vpros, Xaphann
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,419
Threads: 94,016
Posts: 402,536
Top Poster: BrianSlick (7,978)
Welcome to our newest member, estherkt98
Powered by vBadvanced CMPS v3.1.0

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