Search This Blog

Thursday, March 18, 2010

Sound iPhone


#import

@interface CSSound : NSObject {

}
+(void)playSound:(NSString *)soundName;
@end



#import "CSSound.h"
#import

@implementation CSSound
+(void)playSound:(NSString *)soundName{
SystemSoundID mySSID;
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:soundName];

OSStatus error = AudioServicesCreateSystemSoundID( (CFURLRef)[NSURL fileURLWithPath:path], &mySSID);

if(error == kAudioServicesNoError){
//DLog(@"successfully contructed sound %@", soundName);
AudioServicesPlaySystemSound(mySSID);
}else{
DLog(@"error playing sound %@", soundName);
}
}
@end

No comments:

Post a Comment