iOS 7更新后,TPAACAudioConverter中断

时间:2013-09-19 08:30:05

标签: iphone ios xcode ios7 aac

一旦我将iPhone更新到iOS 7,我就会遇到使用TPAACAudioConverter的问题。

错误给出“设置会话类别结果560557673 21696E69 ini!” 错误给出“初始化音频会话结果1768843636 696E6974 tini”

我该如何解决?有时候它有效。

-(void)convertToLowBWM4A
{
    [self.statusLine setText:@"Converting to 8Khz Audio..."];
    if ( ![TPAACAudioConverter AACConverterAvailable] ) {
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Converting audio", @"")
                                     message:NSLocalizedString(@"Couldn't convert audio: Not supported on this device", @"")
                                    delegate:nil
                           cancelButtonTitle:nil
                           otherButtonTitles:NSLocalizedString(@"OK", @""), nil] show];
        return;
    }

//    // Initialise audio session, and register an interruption listener, important for AAC conversion
//    if ( !checkResult(AudioSessionInitialize(NULL, NULL, interruptionListener, (__bridge void *)(self)), "initialise audio session"))
//        {
//        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Converting audio", @"")
//                                     message:NSLocalizedString(@"Couldn't initialise audio session!", @"")
//                                    delegate:nil
//                           cancelButtonTitle:nil
//                           otherButtonTitles:NSLocalizedString(@"OK", @""), nil] show];
//        return;
//    }


    // Set up an audio session compatible with AAC conversion.  Note that AAC conversion is incompatible with any session that provides mixing with other device audio.
    UInt32 audioCategory = kAudioSessionCategory_MediaPlayback;
    if ( !checkResult(AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory), "setup session category") ) {
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Converting audio", @"")
                                     message:NSLocalizedString(@"Couldn't setup audio category!", @"")
                                    delegate:nil
                           cancelButtonTitle:nil
                           otherButtonTitles:NSLocalizedString(@"OK", @""), nil] show];
        return;
    }

    NSString *filenameStr = [NSString stringWithFormat:@"audio%@.m4a",[self.saveSongID lastObject]];

    NSString *convertedFilenameStr = [NSString stringWithFormat:@"converted%@",filenameStr];
    [self.convertedSongName addObject:convertedFilenameStr];
    NSLog(@"filenameStr %@",filenameStr);
    NSLog(@"convertedFilenameStr %@",convertedFilenameStr);
    audioConverter = [[TPAACAudioConverter alloc] initWithDelegate:self
                                                             source:[[self.docFolders objectAtIndex:0]stringByAppendingPathComponent:filenameStr]
                                                        destination:[[self.docFolders objectAtIndex:0] stringByAppendingPathComponent:convertedFilenameStr]];
   [audioConverter start];
}

欢呼声

DES

1 个答案:

答案 0 :(得分:0)

我最终使用AVAssetWriter和AVAssetReader来完成这项工作