Xcode - OpenAL - 获取播放声音的当前时间
大家好,我想知道是否有人可以指出正确的方向,在我的 openAL 单例类中创建一个返回声音当前时间的函数。
有什么想法吗?谢谢!
(“播放声音时”的当前时间)
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')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您好,您能详细说明一下声音的当前时间是什么意思吗?
您的意思是播放声音的实际时间是多少还是音频剪辑的实际时间长度是多长?请具体说明。
如果您的意思是声音播放的实际时间,那么您可以使用
<块引用>
CFAbsoluteTimeGetCurrent()
获取自 2001 年 1 月 1 日 00:00:00 GMT 以来以秒数表示的当前时间(作为双精度值,因此会出现小数秒)。
所以基本上你会得到的是调用函数时的当前时间。
如果您想知道应用程序中何时发生事件,则可以使用
<块引用>
-[UIEvent 时间戳]
属性将是声音播放时间的最准确表示。
要放置您决定选择的任何一个函数(如果它实际上是您正在谈论的内容),然后您像这样返回它:
然后您可以调用这个函数并像这样
一次性存储时间。然后,您可以使用此变量将其打印到控制台或您喜欢的任何内容。
希望这有帮助。请再次说明您所说的声音当前时间的含义。
PK
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
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
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:
And then you can call this function and store the time like so
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