我有能力在我的应用程序中听mp3歌曲。我正在使用AVPLAYER 这是一些代码
player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:filePath]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playingItemDidEnd) name:AVPlayerItemDidPlayToEndTimeNotification object:player];
[player play];
timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(checkTime) userInfo:nil repeats:YES];
因此,当我使用ios 5.0时,我在调试中有这个 加载错误/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 预期在:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation 在/System/Library/Frameworks/Security.framework/Versions/A/Security中 2012-02-27 15:21:27.717 LifesMusic [4161:10703]加载/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:dlopen(/ System / Library /扩展/ AudioIPCDriver.kext / Contents / Resources / AudioIPCPlugIn.bundle / Contents / MacOS / AudioIPCPlugIn,262):找不到符号:_ _CFObjCIsCollectable 参考自:/System/Library/Frameworks/Security.framework/Versions/A/Security 预期在:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security
但它仍然有效。但在IOS 4.3中它根本不起作用。有人可以帮我解决这个问题吗?感谢
答案 0 :(得分:0)
首先:你应该阅读苹果文件Multimedia Programming Guide并了解你在做什么......
还要确保将AV Foundation
框架链接到项目,正确导入并且控制器“侦听”AVAudioPlayerDelegate。
在您的控制器中.h-file:
@property (nonatomic, retain) AVAudioPlayer *player;
在您的控制器.m文件中
@synthesize player;
在“播放”歌曲的方法中
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"song" ofType: @"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
[fileURL release];
self.player = newPlayer;
[newPlayer release];
[player setDelegate: self];
[player prepareToPlay];
[player play];
委派重复歌曲的方法:
- (void) audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)completed {
if (completed == YES) {
[player play];
}
}
答案 1 :(得分:0)
当我尝试在iOS 4.3上播放mp3文件时,我也收到了同样的错误(OSStatus错误1685348671)。
后来我发现这是mp3声音问题,这使得它与在iOS 4.3中播放不兼容。所以,我使用iTunes Player将现有的mp3声音转换为新版本。现在它工作正常,更好。
步骤:
在iTunes中打开您当前的mp3声音 选择它并点击“高级”菜单>> “创建MP3版” 它将创建当前音频的副本。为您的应用使用新创建的mp3文件。
它帮助了我。我希望它也可以帮助别人。一切顺利!