Skip to content

AudioSessionGetProperty 已被废弃,ios14以上每次打电话结束都会崩溃 #176

@dosedo

Description

@dosedo

AudioSessionGetProperty 已被废弃,ios14以上每次打电话结束都会崩溃

崩溃的原因就是取不到 interruptionType的值

  • (void)_handleAudioSessionInterruptionWithState:(UInt32)state
    {
    if (state == kAudioSessionBeginInterruption) {
    [_renderer setInterrupted:YES];
    [_renderer stop];
    [self _sendEvent:event_interruption_begin];
    }
    else if (state == kAudioSessionEndInterruption) {
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdeprecated"
    AudioSessionInterruptionType interruptionType = kAudioSessionInterruptionType_ShouldNotResume;
    UInt32 interruptionTypeSize = sizeof(interruptionType);
    OSStatus status;
    status = AudioSessionGetProperty(kAudioSessionProperty_InterruptionType,
    &interruptionTypeSize,
    &interruptionType);
    NSAssert(status == noErr, @"failed to get interruption type");
    #pragma clang diagnostic pop

    [self _sendEvent:event_interruption_end
    userData:(void *)(uintptr_t)interruptionType];
    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions