A fix for AudioSessionInitialize Deprecated?

前端 未结 5 1071
半阙折子戏
半阙折子戏 2021-02-05 07:31

Apple did not post any alternative code for this on the Apple Developer site.

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 08:16

    1. for this code

    AudioSessionInitialize( NULL, NULL, interruptionCallback, self );
    

    replace with

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

    2. fro this code

    UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
    AudioSessionSetProperty(
            kAudioSessionProperty_AudioCategory,
            sizeof(sessionCategory),
            &sessionCategory
            );
    

    replace with

    UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
    [[AVAudioSession sharedInstance]
         setCategory:sessionCategory error:nil];
    

提交回复
热议问题