开发者

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; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜