Audio.Duration does not work with audio in Sounds folder.

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Grenade Sound Library contains: 135 sounds 50 grenade sounds and 85 surface sounds
  • Hi, I have a global variable that stores the currently playing audio tag's remaining time via Audio.Duration("tag")-Audio.PlaybackTime("tag").

    I use this variable with "wait" to play the next audio upon a certain action, so that the desired audio plays after the current audio is complete.

    When the audio file is in Sounds folder, this does not work as expected and the value goes in negative.

    But if audio is in Music folder, everything works as expected.

    It worked correctly in previous versions.

    Please check: filebin.net/e5nj4uvu15gqgenz

    Tagged:

  • If I just put the audio duration in a Text object, it works correctly - it shows the duration once the audio loads. The playback time can increase past the duration for looping audio, so it looks like a mistake in your calculation.

  • But if audio is in Music folder, it resets after every loop. Shouldn't that be the expected behaviour as the audio tag's length must be taken into account instead of the entire loop when using Audio.Duration("tag")-Audio.PlaybackTime("tag").

  • I think it's a difference in the way the browser reports the playback time depending on the way it is played. Sounds are played with the Web Audio API and music is played with the HTML <audio> element. If these report different playback times for looping audio then so will Construct. I guess you might have to just work around it, either by wrapping the playback time according to the duration, or tracking time since playback yourself.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • A little help might be very useful.

    I just want to determine how much time is left in an audio track when I click a button.

    I will use that value to schedule next play upon current audio completion.

    Sorry, I have very limited coding experience.

    Thanks.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)