Get sound time

Get sound time

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
otyugh
Posts: 43
Joined: 26 Oct 2014, 18:31

Get sound time

Post by otyugh »

Hey there,
is there a portable way in spring to get the time duration of an audio file ? I'm doing some "climax" sound widget, and I get very upset hardcoding the timings :p
Last edited by otyugh on 13 Aug 2015, 15:30, edited 1 time in total.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Sound and spring

Post by gajop »

otyugh wrote:Hey there,
is there a portable way in spring to get the time duration of an audio file ? I'm doing some "climax" sound widget, and I get very upset hardcoding the timings :p
Spring.GetSoundStreamTime() could work
otyugh
Posts: 43
Joined: 26 Oct 2014, 18:31

Re: Sound and spring

Post by otyugh »

Sounds neat indeed. Dunno how I did not see it.

Seems that it only repport the time the sound was played and not its duration.

( ) -> number playedTime, number totalTime

I get number playedTime, but how to get the second one ?
hokomoko
Spring Developer
Posts: 593
Joined: 02 Jun 2014, 00:46

Re: Sound and spring

Post by hokomoko »

local playedTime, totalTime = Spring.GetSoundStreamTime()
otyugh
Posts: 43
Joined: 26 Oct 2014, 18:31

Re: Sound and spring

Post by otyugh »

This is what I was looking for. Thx.
Post Reply

Return to “Lua Scripts”