AVAudioSessionPortOverrideSpeaker and avaudiosessioncategoryoptiondefadefatospeaker, avaudiosession

Source: Internet
Author: User

AVAudioSessionPortOverrideSpeaker and avaudiosessioncategoryoptiondefadefatospeaker, avaudiosession

This article partially translates the official descriptions of these two attributes. Link:

Https://developer.apple.com/library/ios/qa/qa1754/_index.html


The origin of the problem, in iOS, when playing a sound, the need to output to the speaker. Difference between two attribute settings

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

The overrideOutputAudioPort method is used to set the AVAudioSessionPortOverride attribute, which is shorter than avaudiosessioncategoryoptiondefadefatospeaker.

E. g

Method 1

[Session overrideOutputAudioPort: AVAudioSessionPortOverrideSpeaker error: & error];

Method 2

[Session setCategory: avaudiosessioncategoryplayandrecordwitexceptions: avaudiosessioncategoryoptiondefadefatospeakererror: & error];


Method 1: After the settings are completed, if the headset is inserted at this time, unplug it. The playing sound is output from the receiver rather than back to the speaker.

Method 2. After setting, always output to the speaker, instead of other receivers, if there is no headset. (Simply put, if there is a Bluetooth speaker, even if there is no sound output to the Bluetooth speaker, plug in the headset, there will be sound output to the headset .)

Here is a very important part. Both attributes are used only.AVAudioSessionCategoryPlayAndRecord

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.