views:

44

answers:

1

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 = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
currentPlayer.currentTime = 100;  

Is there a way to set the start time with milliseconds?

A: 

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; 
Rob Keniger
Thank you. I was mistaken becauseof the Apple documentation: "The playback point, in seconds, within the timeline of the sound associated with the audio player."
Erwan