我正在连接 2 个音频文件。然后我通过 AVAudioPlayer 播放该音频文件。连接的文件播放完美。但是,当我想获取 audioPlayer 的持续时间时,它会显示错误的持续时间,即 2 秒。但我连接的音频文件的实际持续时间是 7 秒。问题出在哪里?提前感谢您的帮助。
-(void)playAudio{
part1 = [NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Mumu night its getting dark" ofType: @"mp3"]];
part2 = [NSMutableData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Mumu night did you study" ofType: @"mp3"]];
[part1 appendData: part2];
audioPlayer=[[AVAudioPlayer alloc] initWithData:part1 error:NULL];
audioPlayer.delegate = self;
[audioPlayer play];
duration = (int)audioPlayer.duration;
NSLog(@"audio duration: %d", duration);
}