我想在Objective-C中以毫秒为单位的开始时间播放声音。我知道可以这样,但是“currentTime”只需要几秒钟:

currentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
currentPlayer.currentTime = 100;

有没有办法以毫秒为单位设置开始时间?

最佳答案

currentTimeAVAudioPlayer属性是NSTimeInterval,它只是double。换句话说,它是一个浮点值。

这意味着您可以指定秒的分数:

currentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
currentPlayer.currentTime = 100.052;

10-08 18:49