Hey everyone, I was wondering if someone could point me in the right direction to creating a function in my openAL singleton class that returns 开发者_如何转开发the current time of the sound.
Any Ideas? Thanks!
(Current time 'while the sound is playing')
Hi can you elaborate in what you mean by the current time of the sound?
do you mean what the actually time is when the sound is played or how long the actual length of time is of the audio clip? please specify.
If you mean when the actual time the sound was played then you can use
CFAbsoluteTimeGetCurrent()
to get the current time expressed as the number of seconds (as a double value, so fractional seconds will be there) since January 1, 2001 00:00:00 GMT. so basically what you will get is the current time the moment the function is called.
if you would like to know when an event occurred within your application then you can use the
-[UIEvent timestamp]
property which will be the most accurate representation of when the sound played.
To put either of those functions which ever you decide to choose (if its actually what you are talking about) then you return it like so:
(double)returnTime{
double *timeValue = CFAbsoluteTimeGetCurrent();
return timeValue;
}
And then you can call this function and store the time like so
double *storeValue = [self returnTime];
in one go. You can then use this variable to print it to the console or what ever you like.
Hope this helps. Again please specify what you meant by the current time of the sound.
Pk
精彩评论