我是 iphone programin 的新手,我写了一个小动画程序。我使用 audiotoolbox 框架来播放声音,它正在工作。但是当我更改声音文件时。(从资源和文件夹中删除exfile并添加另一个同名,相同路径的文件)
但改变声音后不起作用。
我还用 ex-file 更改了声音文件。但即使 ex 文件也不起作用。
(两者都是 .wav 类型)如果你想我可以在这里写代码。
谢谢你的帮助。
我是 iphone programin 的新手,我写了一个小动画程序。我使用 audiotoolbox 框架来播放声音,它正在工作。但是当我更改声音文件时。(从资源和文件夹中删除exfile并添加另一个同名,相同路径的文件)
但改变声音后不起作用。
我还用 ex-file 更改了声音文件。但即使 ex 文件也不起作用。
(两者都是 .wav 类型)如果你想我可以在这里写代码。
谢谢你的帮助。
您是否尝试过重写代码?您也可以尝试改用 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];
}