【发布时间】:2012-04-09 10:47:05
【问题描述】:
我正在开发一个应用程序,我必须在其中同时录制歌曲和 wav 文件。我正在播放 iPod 音乐库中的歌曲,并且在视图控制器上我放置了一个单击按钮wav 文件启动,但是当我开始使用 AVAudioRecorder 录制时,我的 wav 文件停止工作。 这是我的 ipod 音乐库的代码:-
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) collection
{
MPMediaItem *item = [[collection items] objectAtIndex:0];
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
[self dismissModalViewControllerAnimated: YES];
// Play the item using AVPlayer
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:url];
player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
[player play];
}
这是我用来播放 wav 文件的代码:-
-(void)playAudio:(NSString *)path
{
SystemSoundID soundIDWav;
NSString *sound = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] resourcePath], @"/wavFile.wav"];
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundIDWav);
AudioServicesPlaySystemSound(soundIDWav);
}
我正在通过 AVAudioRecorder 录制这两个... 请帮忙。在此先感谢...
【问题讨论】:
标签: iphone objective-c avaudioplayer avplayer avaudiorecorder