如何录制同时播放AVPlayer和WAV文件的歌曲?

编程入门 行业动态 更新时间:2024-10-24 01:51:06
本文介绍了如何录制同时播放AVPlayer和WAV文件的歌曲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个应用程序,其中我必须同时录制一首歌曲和一个wav文件.我正在播放iPod音乐库中的歌曲,并在视图控制器上放置了一个按钮, WAV文件开始,但是当我开始使用AVAudioRecorder录制时,WAV文件停止工作. 这是我的ipod音乐库的代码:-

I'm developing an App in which i have to record a song and a wav file at a same time.I'm playing song from iPod Music libraries and on a view controller i have placed a button on click of which an wav file starts but when i start recording using AVAudioRecorder,my wav file stop working. This is my ipod music library's code:-

- (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文件的代码:-

and this is my code by which i m playing wav file:-

-(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录制这两个... 请帮忙.谢谢...

I'm recording these two by AVAudioRecorder... Please help.Thanks in advance...

推荐答案

创建音频会话

audioSession.delegate = self; [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil]; [audioSession setActive:YES error:nil];

现在在AVAudioPlayer中播放文件,并同时开始使用AVAudioRecorder录音

Now play your file in AVAudioPlayer and at same time start recording using AVAudioRecorder

更多推荐

如何录制同时播放AVPlayer和WAV文件的歌曲?

本文发布于:2023-07-11 12:13:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   歌曲   AVPlayer   WAV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!