zoukankan      html  css  js  c++  java
  • Differences between AVAudioSessionPortOverrideSpeaker and AVAudioSessionCategoryOptionDefaultToSpeaker

    https://developer.apple.com/library/archive/qa/qa1754/_index.html#//apple_ref/doc/uid/DTS40011281

    Q:  Can you explain the difference between calling the AVAudioSession method overrideOutputAudioPort: with the value AVAudioSessionPortOverrideSpeaker and using the category option AVAudioSessionCategoryOptionDefaultToSpeaker with setCategory:withOptions:error:

    A: The difference is that setting the AVAudioSessionPortOverride by calling overrideOutputAudioPort: is more transient than using the category option AVAudioSessionCategoryOptionDefaultToSpeaker.

    Important: The use of both AVAudioSessionPortOverrideSpeaker and AVAudioSessionCategoryOptionDefaultToSpeaker are only applicable to the AVAudioSessionCategoryPlayAndRecord category.

    Calling overrideOutputAudioPort: and setting the AVAudioSessionPortOverride to AVAudioSessionPortOverrideSpeaker is a way of temporarily overriding the output to play to the speaker. Any route change or interruption will cause the audio to be routed back to its normal route, following the last-in wins rule. Think of using overrideOutputAudioPort: in terms of what you might use to implement a Speakerphone button where you want to be able to toggle between the speaker (AVAudioSessionPortOverrideSpeaker) and the normal output route (AVAudioSessionPortOverrideNone).

    Note: This property is intended to allow 3rd party applications to mimic the behavior of a Speakerphone button and therefore may change the input route as well as output route. For example, setting the AVAudioSessionPortOverride to AVAudioSessionPortOverrideSpeaker while a headset is plugged in will cause the route to change to built-in mic / built-in speaker.

    The preferred way to implement Speakerphone functionality is to use MPVolumeView's Route button.

    In contrast, AVAudioSessionCategoryOptionDefaultToSpeaker modifies the routing behavior of the AVAudioSessionCategoryPlayAndRecord category so that audio will always route to the speaker rather than receiver if no other accessory such as headphones are in use.

    When using AVAudioSessionCategoryOptionDefaultToSpeaker, user gestures will be honored. For example, plugging in a headset will cause the route to change to headset mic/headphones and unplugging the headset will cause the route to change to built-in mic/speaker (as opposed to built-in mic/receiver) when this override has been set.

    In the case of using a USB input-only accessory, audio input would come from the accessory and output would route to headphones (if attached) or speaker if headphones are not plugged in. The use case is simply to route audio to speaker instead of receiver in cases where the audio would normally go to the receiver. This option is a modifier for the category.

    Route changes and interruptions will not reset this override. Only changing the AVAudioSession category will cause this option to be reset.


  • 相关阅读:
    要改变静态文本框的值,必须设置静态文本框控件的样式中(Notify通知)勾选
    MFC对话框中的编辑控件的7种操作方式
    孙鑫C++视频教程 rmvb格式 全20CD完整版
    Windows server2008 下 PowerShell对.NET3.5静默安装
    MFC关机函数
    PDI-KETTLE-2:KETTLE安装,环境变量配置,开发准备
    KETTLE常见问题记录第一篇【安装,资源库,数据库】
    日常问题解决记录一:远程桌面进程如果关闭了怎么呼出?
    KETTLE调度第二篇:把Jenkins调度Web启动设置为后台执行
    PDI-KETTLE-1:使用KETTLE如何设计一个作业-以数据库迁移为例
  • 原文地址:https://www.cnblogs.com/8335IT/p/14110827.html
Copyright © 2011-2022 走看看