[英]AudioServicesCreateSystemSoundID not playing mp3 files
谁能回答如何使用AudioServicesCreateSystemSoundID()
播放mp3文件? 我尝试了但没有工作。
我已使用以下代码片段播放mp3
NSURL *soundURL = [[NSBundle mainBundle] URLForResource:fileName withExtension:extension];
soundFileURLRef = (CFURLRef) [soundURL retain];
// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID ( soundFileURLRef,&soundFileObject);
使用此示例时,我遇到了同样的问题。 也许您的声音样本很大/很长。
NSString *path = [[NSBundle mainBundle] pathForResource:@"tap" ofType:@"aif"];
NSURL *url = [NSURL fileURLWithPath:path];AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &mBeep);
AudioServicesPlaySystemSound(mBeep);
由于音频文件太长,因此无法正常工作。 我尝试了苹果示例http://developer.apple.com/library/ios/#samplecode/SysSound/Introduction/Intro.html “ tap.aif”中的声音,但效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.