//
//  PlaySound.m
//
//  Created by AIG-Soft on 2011/04/09.
//  Copyright 2011 AIG-Soft. All rights reserved.
//
//  フレームワークにAudioToolbox.framaworkの追加が必要

#import "PlaySound.h"

@implementation PlaySound

// 音声データの読み込み
-(id)initWithSound:(CFStringRef)fname ext:(CFStringRef)ext
{
	nslog(@"音声データの読み込み");
	soundURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),fname,ext,NULL);
	if (soundURL==NULL) {
		nslog(@"ファイル付が見つかりません:%@.%@",fname,ext);
		return(nil);
	}
	AudioServicesCreateSystemSoundID(soundURL, &soundID);
	CFRelease (soundURL);
	//
	return (self);
}

-(void)play
{
	AudioServicesPlaySystemSound(soundID);
}

-(void)dealloc
{
	AudioServicesDisposeSystemSoundID(soundID);
}

@end
