Search Unity

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