Current version of Xojo, Windows 10 latest version.
If I play a piece of music, it seems to stop as soon as I play a sound effect on the same screen. Is there a way to have two sounds going at once? (I want the music to be in the background of the window).
[quote=415528:@StphaneMons]I think that using high-level commands allows you to play only one sound.
If you want to play multiple sounds at once, you would need to use a specific system library[/quote]
What would be a good method of doing this with the least dependencies? (Windows)
It looks like I was supposed to receive an email on this case, and I might have missed it. I created examples in the “I Wish I Knew How To… Implement Declares with Xojo on Windows” and have examples on how to do this with examples in Chapter 16. Maybe Xojo can implement declares to fix this bug?
[quote=415540:@Eugene Dakin]This is a bug in Xojo Windows that was reported back in November of 2016. I was creating a Windows Desktop game and background theme music and a sound effect could not be played at the same time.
I have an app that plays up to four tones in Windows at the same time. It does so by loading four different “sound” files and playing them. Below is a snippet of the code that plays the tones:
//set volume for files
pySoundFile0.Volume = pyToneLevel(0)
pySoundFile1.Volume = pyToneLevel(1)
pySoundFile2.Volume = pyToneLevel(2)
pySoundFile3.Volume = pyToneLevel(3)
//play files for timer duration
pySoundFile_x is a Sound object (http://documentation.xojo.com/api/os/sound.html)
I last compiled this application for Windows on 2015 so I can’t say if anything broke in Xojo since then. Volume in Windows is not implemented correctly (feedback://showreport/?report_id=39028), but that is another story.
Hmm, this project made me discover something: it works fine if I use an .mp3 for the music and .wav format for the sound effect, even stock Xojo without this project. Then the music doesn’t stop when the sound starts. Does Xojo have a channel for each format? Is this by design?
@Derek DiBenedetto ; did you try using the MoviePlayer? I tried 2017r2.1 with the Sound object and it certainly looks like Xojo had a regression in Windows as it worked in 2014 and 2015 (as Eugene mentioned). This is not surprising and I wouldn’t hold my breath on a fix. But using the MoviePlayer worked fine in 2017r2.1
Looks like (based on my Feedback case) that its a limitation of Windows ‘DirectSound’ implementation; two .mp3s can’t play at once. Two .wavs can play or a .mp3 and a .wav together, but not two .mp3s. Odd, but its fairly simple to work around, I suppose.