Tôi đang làm việc trên ứng dụng Android cũng hỗ trợ iOS. Tôi muốn ghi lại âm thanh & phát trong Android cũng như trong các thiết bị iOS. Tôi đang ghi âm trong android sử dụng cài đặt sauKhông thể phát tệp âm thanh đã ghi từ android trong iOS 5+
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();
Trên iOS bên, cài đặt như sau
//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);
}
Tôi có thể ghi lại âm thanh & nó được chơi một cách chính xác trong các thiết bị Android. Bây giờ vấn đề là tôi có thể phát âm thanh đã ghi từ iOS trong thiết bị Android, nhưng thiết bị iOS không thể phát âm thanh được ghi trên thiết bị Android. Nó trả về OSStatus error 1937337955
. Tôi đã tìm kiếm về lỗi này, nhưng tôi không thể tìm thấy bất cứ điều gì.
Ai có thể cho tôi biết điều gì sai trong mã của tôi?
Mọi loại trợ giúp đều được đánh giá cao. Cảm ơn trước.
PrvN: được giải quyết chưa? – muthukumar
@PrvN: đã được giải quyết chưa? Tôi cũng có cùng một vấn đề. – Jacky