1
Audio / Re: Music not playing even though its loaded.
« Last post by Me-Myself-And-I on April 24, 2024, 06:08:16 pm »Quote
Why this would have an impact on the music playing or not playing, I don't know, since those are separate modules without any overlaps.I too thought that was very strange.
Quote
You shouldn't use any SFML resources globally, in general avoid globals as much as possible.
Initialization and destruction order at a global scope aren't guaranteed, so you can run into issues where some expected internal SFML global isn't initialize or already destructed, leading to crashes. As for globals in general, they make it very hard to impossible to track the state and code flow at any given moment.
The solution is for me to make a better habit of not declaring SFML elements globally. Thankyou for your help.
Quote
I tried the same code (both global and local window) and music played fine in both cases. Although I'm using SFML 3 so maybe it doesn't have the issue.
I even tried playing the music without a window and it worked. (I replaced the while open loop with a Sleep(10000)).
But I see some bits of the audio system have changed since SFML 2.5 with how the global audio device is handled.
Yes, its likely that this problem was fixed in sfml 3. I use 2.4.0 so it might be more likely for this error to occur in this version when the window is declared globally.