我是 iphone 编程新手。任何人都可以告诉我,下面的代码是用于播放录制的声音,但它不能在设备中播放声音。任何人都可以告诉我这段代码有什么错误。
if(soundID)
{
AudioServicesDisposeSystemSoundID(soundID);
}
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:audiopath isDirectory:NO];
NSLog(@"%@",filePath);
//Use audio sevices to create the sound
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
//Use audio services to play the sound
AudioServicesPlaySystemSound(soundID);
在上面的代码中,音频路径是语音录制的路径。实际上在数据库路径中是这样存储的
/Users/User/Library/Application Support/iPhone Simulator/5.0/Applications/C974262E-7658-45EE-8E8C-290B780E7C3E/Documents/2012-12-18 13:50:56 +0000.caf
在此之后,我正在检索路径显示如下:
file://localhost/Users/User/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/C974262E-7658-45EE-8E8C-290B780E7C3E/Documents/2012-12-18%2013:50:56%20+0000.caf
这段代码有什么错误?请告诉我。