You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I was testing a track by playing it on two SoundInstances for seamless playback looping but for some strange reason, I noticed it gives me an overflow exception with the message "TimeSpan overflowed because the duration is too long." when getting the position of any of the sound instances during the looping process.
To Reproduce
Steps to reproduce the behavior:
You can create a new project out of the SimpleAudio template.
Create a new SyncScript (or AsyncScript, adjusted accordingly).
Add a SoundInstance and play it on Start():
public Sound Sound { get; set; }
private SoundInstance SoundInstance1;
public override void Start()
{
// Initialization of the script.
SoundInstance1 = Sound.CreateInstance();
SoundInstance1.IsLooping = false;
SoundInstance1.Play();
}
During Update(), add a condition to play the track if the position is zero (or really, any calculation that needs the current position of the sound instance).
public override void Update()
{
if (SoundInstance1.Position.Equals(TimeSpan.Zero)) SoundInstance1.Play();
}
Wait for the track to loop back.
In some cases, it loops back just fine, but other times during looping, it throws an overflow exception. Not entirely sure if this is only on my end but I've had it happen somewhat consistently so I figured I'd raise this issue.
Expected behavior
To loop back the track without throwing an exception every time.
Workaround
Granted, I was able to get a workaround going by getting the audio position through a method/local function returning a TimeSpan using a try-catch block but still, pretty odd occurrence.
The text was updated successfully, but these errors were encountered:
I was unable to reproduce this issue using either of the sounds from the audio template. I let loop a number of times to be sure, but worked fine for me on the latest version.
I was unable to reproduce this issue using either of the sounds from the audio template. I let loop a number of times to be sure, but worked fine for me on the latest version.
Interesting.
So I just tried it again in a new project and it worked nicely without any crashes whatsoever but then I reopened the old project that I originally used to test the problem with and it does keep happening.
I looked at both projects and it seems that the determining factor was that the sound file being played has the flag "Stream From Disk" enabled in Game Studio for the old one but the newer one has it disabled, same file and all. (If it helps any, the track being loaded is on an SSD)
Can you confirm if you get the exception with the Start() and Update() posted on the OP with the sound in Game Studio having the "Stream From Disk" flag enabled? It happened to me even with the sound effect from the template.
Just tried it and I can confrim that when using the latest build, and Stream From Disk is enabled, it will give the exception. Interestingly though, when GameStudio is launched from the source code, it does not produce the error (tried in both debug mode and not).
Release Type: Official Release
Version: Latest
Describe the bug
I was testing a track by playing it on two SoundInstances for seamless playback looping but for some strange reason, I noticed it gives me an overflow exception with the message "TimeSpan overflowed because the duration is too long." when getting the position of any of the sound instances during the looping process.
To Reproduce
Steps to reproduce the behavior:
In some cases, it loops back just fine, but other times during looping, it throws an overflow exception. Not entirely sure if this is only on my end but I've had it happen somewhat consistently so I figured I'd raise this issue.
Expected behavior
To loop back the track without throwing an exception every time.
Workaround
Granted, I was able to get a workaround going by getting the audio position through a method/local function returning a TimeSpan using a try-catch block but still, pretty odd occurrence.
The text was updated successfully, but these errors were encountered: