AudiosessionSetActive
IOS audiosession 会话控制声音播放
今天遇到一个问题:
当我外部想要关闭声音播放的时候 audiosessionsetActive(false)
居然报错了,但是作用起了 AVAudioSessionErrorCodeIsBusy: 560030580
有人说是重复操作,确认了下并没有
看到简书上有人说这个问题,属正常
http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed19fa950d100b92235c438014648c83493e8ed45f93130a1c187ba1a674751a02d2c6786752fe1e5ffeb56b32610c73f38cc9f8199aedc97538895775275dc71a4f8f0eaebb1165817dd04de8df48baeca72592de89928f131281&p=b46fc64ad4af02ff57ee94797f079c&newp=882a9645d18218f404a2c7710f4b94231610db2151dcd701298ffe0cc4241a1a1a3aecbf23221204d8cf786304aa425ceaf43d723d0034f1f689df08d2ecce7e6ed17c683f&user=baidu&fm=sc&query=AVAudioSessionErrorCodeIsBusy&qid=b5e7ae130000b06c&p1=2
注意:
如果一个活动音频会话的优先级高于当前音频会话(如电话呼叫),并且两个音频会话都不允许混音,则激活音频会话将失败。
取消激活正在运行音频对象的音频会话,将停止正在运行的运行对象并取消激活会话,error 返回 AVAudioSessionErrorCodeIsBusy
错误。(虽然报错,但是活动状态扔被更改成功为未激活)。
附上 audioSESSION常见错误码:
{
AVAudioSessionErrorCodeNone = 0,
AVAudioSessionErrorCodeMediaServicesFailed = 'msrv', /* 0x6D737276, 1836282486 */
AVAudioSessionErrorCodeIsBusy = '!act', /* 0x21616374, 560030580 */
AVAudioSessionErrorCodeIncompatibleCategory = '!cat', /* 0x21636174, 560161140 */
AVAudioSessionErrorCodeCannotInterruptOthers = '!int', /* 0x21696E74, 560557684 */
AVAudioSessionErrorCodeMissingEntitlement = 'ent?', /* 0x656E743F, 1701737535 */
AVAudioSessionErrorCodeSiriIsRecording = 'siri', /* 0x73697269, 1936290409 */
AVAudioSessionErrorCodeCannotStartPlaying = '!pla', /* 0x21706C61, 561015905 */
AVAudioSessionErrorCodeCannotStartRecording = '!rec', /* 0x21726563, 561145187 */
AVAudioSessionErrorCodeBadParam = -50,
AVAudioSessionErrorInsufficientPriority = '!pri', /* 0x21707269, 561017449 */
AVAudioSessionErrorCodeResourceNotAvailable = '!res', /* 0x21726573, 561145203 */
AVAudioSessionErrorCodeUnspecified = 'what' /* 0x77686174, 2003329396 */
} NS_AVAILABLE_IOS(7_0);
苹果官方有写:
————————————————————————————————————————————————————————————————————————————
setActive:withOptions:error:
Activates or deactivates your app’s audio session using the specified options.
SDKs
- iOS 6.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- AVFoundation
On This Page
Declaration
- (BOOL)setActive:(BOOL)active
withOptions:(AVAudioSessionSetActiveOptions)options
error:(NSError * _Nullable *)outError;
Parameters
active
-
Specify
YES
to activate your app’s audio session, orNO
to deactivate it. options
-
An integer bit mask containing one or more constants from the
AVAudioSessionSetActiveOptions
enumeration. outError
-
On input, a pointer to an error object. If an error occurs, the pointer is set to an
NSError
object that describes the error. If you do not want error information, pass innil
.
Return Value
YES
if the session’s active state was changed successfully, or NO
if it was not.
Discussion
If another active audio session has higher priority than yours (for example, a phone call), and neither audio session allows mixing, attempting to activate your audio session fails. Deactivating an audio session that has running audio objects will stop the running audio objects, deactivate the session, and a AVAudioSessionErrorCodeIsBusy
error will be returned.
Note
When deactivating a session, the return value is falseExpression
but the active state will change to deactivate.
Topics
Data Types
AVAudioSessionSetActiveOptions
A flag that provides additional information about your app’s audio intentions upon session deactivation.
See Also
Activating the Audio Session
- setActive:error:
Activates or deactivates your app’s audio session.
- activateWithOptions:completionHandler:
Asynchronously activates an audio session on watchOS.
AudiosessionSetActive的更多相关文章
- 一篇对iOS音频比较完善的文章
转自:http://www.cnblogs.com/iOS-mt/p/4268532.html 感谢作者:梦想通 前言 从事音乐相关的app开发也已经有一段时日了,在这过程中app的播放器几经修改我也 ...
- [ios]app后台运行
参考:http://www.douban.com/note/375127736/ 1 使用开源代码MMPDeepSleepPreventer将文件加入工程,包括音频文件.可以在源文件中加入单例,便于使 ...
- iOS编程修改系统音量
iOS的AVFoundation框架提供了基本的音视频播放工具,我们基本上可以靠其中提供的类完成绝大部分的音视频播放任务.但是在音频播放的输出音量的处理上,苹果的策略比较保守.尽管AVPlayer和A ...
- iOS调节系统音量
目录[-] 使用MPVolumeView 编程实现系统音量调节2 通过MPVolumeSlider的实例来操作系统音量 有问题!我不喜欢系统弹出音量提示 还有问题,我修改了系统音量但是不是通过我的UI ...
- IOS 音频播放
iOS音频播放 (一):概述 前言 从事音乐相关的app开发也已经有一段时日了,在这过程中app的播放器几经修改我也因此对于iOS下的音频播放实现有了一定的研究.写这个系列的博客目的一方面希望能够抛砖 ...
- iOS音频播放(二):AudioSession
(本文转自码农人生) 前言 在实施前一篇中所述的7个步骤步之前还必须面对一个麻烦的问题,AudioSession. AudioSession简介 AudioSession这个玩意的主要功能包括以下 ...
- iOS 监听声音按键
有时在项目中需要监听用户是否按下了物理声音键,然后来做某些操作,如:你自定义了一个照相功能,希望用户按下声音按键时也能进行拍照,苹果自带的照相机就有这种功能. 监听物理声音键是否按下的方法有很多中,我 ...
- DOUAudioStreamer 中kqueue的应用
DOUAudioStreamer是一个基于Core Audio的流式音频播放器,其中的DOUAudioEventLoop通过kqueue来控制音频的各种状态. kqueue简介(详情请看官方manua ...
- iOS录音后播放声音小,AudioSessionInitialize failed,AudioQueueStart failed (-50)
方法1: UInt32 audioRoute = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty(kAudioSess ...
随机推荐
- JavaStudy——Java之自动拆箱与自动装箱
java基本类型介绍 java中,基本数据类型一共有8种,详细信息如下表: 类型 大小 范围 默认值 byte 8 -128 - 127 0 short 16 -32768 - 32768 0 int ...
- Centos7更改yum源
每次都要百度一番,还不如自己做个记录,简单粗暴,哈哈哈哈 cd /etc/yum.repos.d mv CentOS-Base.repo CentOS-Base.repo.old wget http: ...
- Spring生态研习【二】:SpEL(Spring Expression Language)
1. SpEL功能简介 它是spring生态里面的一个功能强大的描述语言,支在在运行期间对象图里面的数据查询和数据操作.语法和标准的EL一样,但是支持一些额外的功能特性,最显著的就是方法调用以及基本字 ...
- 用a标签实现submit提交按钮的效果
今天做了一个小项目练手,要求点击a标签后实现post提交的效果,看到这个的时候心理还是有一丝丝懵逼的,不过在朕的十秒钟思考之后有了头绪... 首先表单 <form action="te ...
- Laravel 5 中使用 Laravel Excel 实现 Excel/CSV 文件导入导出功能
1.简介 Laravel Excel 在 Laravel 5 中集成 PHPOffice 套件中的 PHPExcel,从而方便我们以优雅的.富有表现力的代码实现Excel/CSV文件的导入和导出. 该 ...
- sqlserver存储过程sp_send_dbmail邮件(html)实际应用
前段时间因工作需求,特地学习了下sp_send_dbmail的使用,发现网上的示例对我这样的菜鸟太不友好/(ㄒoㄒ)/~~,好不容易完工来和大家分享一下,不谈理论,只管实践! 如下是实际需求: -- ...
- 前端-JavaScript1-6——JavaScript之变量类型的转换
6.1 string → number 先来学习一个语句,这个语句和alert差不多,也是弹窗,弹的是输入框: 1 prompt("请输入你的电话","139&qu ...
- kafka命令大全
kafka命令大全 http://orchome.com/454
- HTML翻转菜单练习
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- BZOJ 3097: Hash Killer I
3097: Hash Killer I Time Limit: 5 Sec Memory Limit: 128 MBSec Special Judge[Submit][Status][Discus ...