Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jun 25, 2018 at 10:35 AM by martsamma for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by martsamma · Jun 21, 2018 at 01:21 PM · iosaudiobluetooth

iOS app does not play audio from bluetooth headset

Builded Unity app for iOS and Android. In iOS app audio won't be played in bluetooth headset. In android does. Headset itself works perfectly. Same problem with different bluetooth headsets.

Couldn't find any solution. Have anyone had this problem? Any glue why?

Unity 2018.1.5f1 iOS 10 and 11

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by martsamma · Jun 25, 2018 at 10:34 AM

Managed to FIX this problem.


Open the generated project in Xcode. Find and open UnityAppController.mmfile.
And add these lines to UnityAppController.mm:


At the beginning of the file add:

 #import <AVFoundation/AVFoundation.h>

Then find this function in mentioned file:
- (void)startUnity:(UIApplication*)application:

If you don't need to record add in the end of this function these 2 lines:

 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
 [[AVAudioSession sharedInstance] setActive:YES error:nil];

If you need to record add in the end of this function these 2 lines:

 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord 
         withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
 [[AVAudioSession sharedInstance] setActive:YES error:nil];
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dioinecail · Jul 11, 2019 at 09:03 AM 0
Share

Please specify, that you need to add the [[AVAudioSession sharedInstance] setActive:YES error:nil]; part at the end of the same function, right now it sounds like you need to add it to the end of the file, which does not make it work.

At least i and some other developers thought of that i think.

So what exactly you need to do is:

Add #import <AVFoundation/AVFoundation.h> at the beginning of UnityAppController.mmfile (use search inside xcode)

Then add either [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; or [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];

at the end of the - (void)startUnity:(UIApplication*)application function (search startUnity)

depending on if you require audio recording or not and also add [[AVAudioSession sharedInstance] setActive:YES error:nil]; at the end of the SA$$anonymous$$E function

avatar image martsamma Dioinecail · Jul 11, 2019 at 12:13 PM 1
Share

@Dioinecail Thank you! Updated solution comment. Hope that it's more understandable now.

Follow this Question

Answers Answers and Comments

140 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Music Crash and slow down when I unplugged headphone in IOS after I changed System Sample Rate to 44.1kHz / 48kHz 0 Answers

Why will audio files loaded in runtime not play through bluetooth on iOS devices. 0 Answers

Connect to Bluetooth network within App 0 Answers

How to get BlueTooth Keyboard Value in the IOS APPS? 0 Answers

How do I reduce the CPU load spike caused by playing an audio clip? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges