如何在后台录制视频并保持音乐播放? [英] How to record video and maintain music playing in the background?

查看:401
本文介绍了如何在后台录制视频并保持音乐播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这是重复的,但是我找不到类似的问题.我有一个使用AVFoundation制作的自定义摄像机/录像机,我想知道如何在录制视频的同时保持其他应用程序的音频运行,因为现在它会停止音频(甚至不暂停它),然后录制视频

Sorry if this is a duplicate, but I couldn't find a question similar to this. I have a custom camera/recorder that I made with AVFoundation and I was wondering how to keep the audio running from other apps while recording a video because right now it stops the audio (doesn't even pause it) and then records the video

如果我的想法正确,是否可以通过添加类似于以下内容的方法来解决此问题:

If I am thinking correctly, could this be solved by adding something similar to this:

 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];

推荐答案

This fixed it.


[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
                                 withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers
                                       error:nil];

这篇关于如何在后台录制视频并保持音乐播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆