2011년 7월 20일 수요일

wave파일을 효과음으로 내는 허접한 클래스


#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>

@interface SPSoundEffect : NSObject {
    
}
-(void) playWithWavFileName:(NSString *)fileName;

@end




#import "SPSoundEffect.h"


@implementation SPSoundEffect


- (void)playWithWavFileName:(NSString *)fileName
{
    NSString *fpath = [[NSBundlemainBundle] pathForResource:fileName ofType:@"wav"];
    SystemSoundID ssound;
    
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURLfileURLWithPath:fpath], &ssound);
    AudioServicesPlaySystemSound(ssound);
}

@end

댓글 없음: