我正在开发支持iOS的
Android应用程序.我想录制音频&在Android和iOS设备中播放它.我正在使用以下设置在Android中录制音频
MediaRecorder audioRecorder = new MediaRecorder(); audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); audioRecorder.setAudioSamplingRate(44100); audioRecorder.setAudioChannels(1); audioRecorder.setAudioEncodingBitRate(12800); audioRecorder.setOutputFile(<recordedSoundFilePath>); audioRecorder.prepare(); audioRecorder.start();
在iOS端,设置如下
//audioRecorder is object of AVAudioRecorder NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] initWithCapacity:10]; NSNumber *formatObject; formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC ]; [recordSettings setObject:formatObject forKey: AVFormatIDKey]; [recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey]; [recordSettings setObject:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; [recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey]; [recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey]; NSURL *soundFileURL = [NSURL fileURLWithPath:[self soundFilePath]]; NSError *error = nil; audioRecorder = [[ AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error]; if ([audioRecorder prepareToRecord] == YES){ [audioRecorder record]; }else { int errorCode = CFSwapInt32HostToBig ([error code]); NSLog(@"Error: %@ [%4.4s])",[error localizedDescription],(char*)&errorCode); }
我可以录制音频&它在Android设备中正常播放.
现在问题是我可以在Android设备上播放iOS录制的音频,但iOS设备无法播放Android设备上录制的音频.它返回OSStatus错误1937337955.我搜索了这个错误,但我找不到任何东西.
谁能告诉我代码中出了什么问题?
任何形式的帮助都非常感谢.提前致谢.