audio session config

#pragma mark -
#pragma mark - audio session config

- (void)setAudioSessionConfig
{
    NSError *error;
    AVAudioSession *session = [AVAudioSession sharedInstance];
    _originalAudioSessionCategory = session.category;
    
    if (![session setCategory:AVAudioSessionCategorySoloAmbient error:&error]) {
        QZLOG_ERROR(@"%@, setCategory failed, error: %@!!!", NSStringFromSelector(_cmd), error);
    }
    if (![session setActive:YES error:&error]) {
        QZLOG_ERROR(@"%@, setActive failed!!!", NSStringFromSelector(_cmd));
    }
}

- (void)resetAudioSessionConfig
{
    if (!(_originalAudioSessionCategory.length > 0)) {
        return;
    }
    
    NSError *error;
    if (![[AVAudioSession sharedInstance] setCategory:_originalAudioSessionCategory error:&error]) {
        QZLOG_ERROR(@"%@, setCategory failed, error: %@!!!", NSStringFromSelector(_cmd), error);
    }
}

posted on 2016-04-21 14:36  封起De日子  阅读(115)  评论(0编辑  收藏  举报

导航