【发布时间】:2012-11-22 11:46:25
【问题描述】:
我创建了处理声音的类。但我有问题停止声音?我无法将变量从 playSound 发送到 stopSound AudioServicesDisposeSystemSoundID(soundID)。 如何处理?我真的不想实例化它还是我不得不实例化它?
@implementation SoundPlayer
+(void)playSound:(NSString *)filename ofType:(NSString *)extension {
SystemSoundID soundID;
NSString *soundFile = [[NSBundle mainBundle] pathForResource:filename ofType:extension];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID);
AudioServicesPlaySystemSound(soundID); // error - soundID is undeclared
}
+(void)stopSound
{
AudioServicesDisposeSystemSoundID(soundID);
}
@end
【问题讨论】:
标签: iphone xcode static-methods