How to change a sound playing start time in objective-c?
I would like to play a sound in Objective-C with a millisecond start time. I know it is possible this way but "currentTime" only takes seconds:
currentPlayer = 开发者_如何学JAVA[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
currentPlayer.currentTime = 100;
Is there a way to set the start time with milliseconds?
The currentTime
property of AVAudioPlayer
is an NSTimeInterval
, which is just a double
. In other words it's a floating-point value.
This means you can specify fractions of seconds:
currentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
currentPlayer.currentTime = 100.052;
精彩评论