简体   繁体   English

iOS可以同时通过蓝牙和设备扬声器播放两个独立的音频流吗?

[英]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.

相关问题 iOS - 可以录制蓝牙耳机麦克风的音频并播放设备扬声器 - iOS - is possible to record audio from Bluetooth headset mic and play in device speaker iOS 12设备的音频播放器扬声器和麦克风无法同时工作 - iOS 12 device audio player speaker and microphone not working simultaneously 从无线耳机录制音频并通过蓝牙扬声器播放 - Record Audio From wireless Headset and Play it Through Bluetooth speaker 在 iOS Safari 中同时播放两个音频文件 - Play two audio files simultaneously in iOS Safari iOS通过iPhone接收器(电话扬声器)播放音频 - iOS play audio through iPhone receiver (phone speaker) 如何将音频从设备扬声器路由到蓝牙扬声器? - How to route audio from device speaker to bluetooth speaker? HTML5 / JS - 我可以在iOS上同时播放两个或多个音频声音吗? - HTML5 / JS - Can I play two or more audio sounds simultaneously on iOS? 通过上部(电话)扬声器播放音频 - Play audio through upper (phone call) speaker 使用手机录制音频,但通过iOS中的蓝牙耳机播放录制 - Record audio with phone, but play record through bluetooth headset in iOS 在iOS中同时录制和播放音频 - Record and play audio simultaneously in iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM