我正在尝试在我的应用程序中播放 mp3,经过大量研究,我仍然无法弄清楚如何进行相对路径,甚至无法使用绝对路径播放音乐。这就是我所拥有的:
//set music
NSError *error;
if (songChosen == 0)
{
soundPath = @"/Users/aeubanks/Desktop/XCode Stuff/Apps/Game-Storyboard/Game-Storyboard/Amalgamation.mp3";
}
else if (songChosen == 1)
{
soundPath = @"/Users/aeubanks/Desktop/XCode Stuff/Apps/Game-Storyboard/Game-Storyboard/BUTTERFLY.mp3";
}
audio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:&error];
if([[NSFileManager defaultManager] fileExistsAtPath:soundPath] == NO)
{
NSLog(@"No File");
}
else
{
NSLog(@"Yes File");
}
if(error != nil)
{
NSLog(@"%@", error);
}
[audio prepareToPlay];
NSLog 说明了这一点(做好准备):
2012-08-04 15:52:02.415 游戏故事板[8430:10703] 是文件
2012-08-04 15:52:02.473 游戏故事板[8430:12303] 加载/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/) 时出错库/扩展/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn,262):找不到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-08-04 15:52:02.486 Game-Storyboard[8430:12303] 加载/System时出错/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262):未找到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-08-04 15:52:02.525 Game-Storyboard[8430:12303] 加载 /System 时出错/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262):未找到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ /System/Library/Frameworks/Security.framework/Versions/A/Security 中的 System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 2012-08-04 15:52:02.546 Game-Storyboard[8430:12303] 加载 /System 时出错/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262):未找到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-08-04 15:52:02.570 Game-Storyboard[8430:12303] 加载/System时出错/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262):未找到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ /System/Library/Frameworks/Security.framework/Versions/A/Security 中的 System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 2012-08-04 15:52:02.582 Game-Storyboard[8430:12303] 加载 /System 时出错/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262):未找到符号:__CFObjCIsCollectable 引用自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/ /System/Library/Frameworks/Security.framework/Versions/A/Security 中的 System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
我还尝试将 soundPath 设置为 @"BUTTERFLY.mp3"/@"Amalgamation.mp3" 以及 @"Game-Storyboard/BUTTERFLY.mp3"/@"Game-Storyboard/Amalgamation.mp3",我得到了这个:
2012-08-04 15:58:55.763 游戏故事板[8470:10703] 无文件
2012-08-04 15:58:55.767 Game-Storyboard[8470:10703] 错误域 = NSOSStatusErrorDomain 代码 =-43 “操作无法完成。(OSStatus 错误 -43。)”
我不知道这一切意味着什么,所以我希望能得到一些帮助来解决这个问题。