Wolfsbane Posted November 21, 2018 Share Posted November 21, 2018 Hi Team, Bit of a lazy question: How would I get the length(time) of a Sound item? I think this should be available (duration??) but I can't seem to find it in the code. (The idea would be I could play the sound, then set a timer using the sound's length) Quote Link to comment Share on other sites More sharing options...
enpu Posted November 21, 2018 Share Posted November 21, 2018 There is private property _buffer in Sound class which is instance of AudioBuffer (https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer). You could use that to access the duration of a sound, but i just added new duration property to Sound class so it's easier to access. var sound = new game.Sound('sound.m4a'); console.log(sound.duration); Wolfsbane and khleug35 2 Quote Link to comment Share on other sites More sharing options...
Wolfsbane Posted November 21, 2018 Author Share Posted November 21, 2018 @enpu Fantastic. Thansk! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.