我是iphone编程新手,我写了一个小动画程序。我使用了音频工具箱框架的声音,它是工作的。但是当我改变声音文件的时候。(从资源和文件夹中删除exfile,并添加具有相同名称、相同路径的其他文件)
但是换了之后声音就不起作用了。
我也用ex - file重新修改了声音文件,但是ex文件也不能工作。
(两者都是.wav类型)如果你愿意,我可以在这里写代码。
感谢您的帮助。
发布于 2011-10-12 16:19:25
你有没有试过重写代码?您也可以尝试使用AVFoundation框架。
.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface AudioPlayerViewController : UIViewController {
AVAudioPlayer *audioPlayer;
}
@end.m
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if (audioPlayer == nil)
NSLog([error description]);
else
[audioPlayer play];
}https://stackoverflow.com/questions/4626281
复制相似问题