Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Bug Ios native app audio get muted on switching other engine games to unity games from 2nd times

Discussion in 'iOS and tvOS' started by rajstudypad, May 10, 2023.

  1. rajstudypad

    rajstudypad

    Joined:
    Jul 18, 2019
    Posts:
    1
    my native ios app contains cocos 2d, cocos creator and unity games . so when i open and close cocos game then open unity game , audio is working fine but when open cocos game again then unity game this time audio. get muted . I have to close the app and restart again to get audio back .

    am using unity 20019.3 for my project , there is an issue in my unity game when our device is connected with bluetooth headphone , instead of audio coming from headphone it comes from device speaker so to fix that issue have added this code in UnityAppController.mm startUnity method .

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
    withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];

    after adding this code , when i switch between cocos games to unity games audio get muted in both cases(with and without bluetooth headphone). not able to find the issue , so anyone can help for this issue .

    thanks in advance