[英]Can iOS play two independent audio streams through bluetooth and device speaker simultaneously?
I'm looking into the feasibility of an app that needs to play certain sounds though a connected bluetooth speaker in addition to another set of sounds through the device's internal speaker. 我正在研究一个应用程序的可行性,除了通过设备内部扬声器发出的另一组声音之外,还需要通过连接的蓝牙扬声器播放某些声音。 Looking at AVFoundation it appears there's only one AVAudioSession singleton per app and therefor the internal speaker and external bluetooth speaker can only be used in a mutually exclusive fashion. 看看AVFoundation,每个应用程序只有一个AVAudioSession单例,因此内部扬声器和外部蓝牙扬声器只能以互斥的方式使用。
The sounds I need to play are all under 5 seconds long and no synchronization between the bluetooth output and device speaker is required. 我需要播放的声音都不到5秒钟,并且蓝牙输出和设备扬声器之间不需要同步。
Is it possible to accomplish this with iOS? 是否可以通过iOS实现这一目标? If so, which APIs should I be looking at? 如果是这样,我应该关注哪些API?
You can look at AVAudioSessionCategoryMultiRoute
. 你可以看看AVAudioSessionCategoryMultiRoute
。
From the docs: 来自文档:
Use this category to customize the usage of available audio accessories and built-in audio hardware. 使用此类别可自定义可用音频配件和内置音频硬件的使用情况。 For example, this category provides an application with the ability to use an available USB output and headphone output simultaneously for separate, distinct streams of audio data. 例如,此类别为应用程序提供了同时使用可用USB输出和耳机输出以分离不同的音频数据流的能力。 Use of this category by an application requires a more detailed knowledge of, and interaction with, the capabilities of the available audio routes. 应用程序使用此类别需要更详细地了解可用音频路由的功能并与之交互。
Here is a similar question: How to Play two audio files together in iOS However, when it comes to audio streams through bluetooth and device speaker, I would say no. 这是一个类似的问题: 如何在iOS中一起播放两个音频文件然而,当谈到通过蓝牙和设备扬声器的音频流时,我会说不。 I don't think you can do that. 我认为你不能这样做。 Hope you'll find this helpful. 希望你会发现这很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.