Bug #858
openPlay Audio sometimes playing the wrong audio in the internal player
0%
Description
If I use the same audio number to play a different piece of audio using F2 for the internal player, I often get the previous sound playing, and sometimes over the top of the next one.
#splashScreen:False
tunes=3
tunenum=1
dim tune$(3)
tune$(1)="One.mp3"
tune$(2)="Two.mp3"
tune$(3)="Three.mp3"
load asset "tunes\"+tune$(tunenum),50
print str$(tunenum),"tunes\"+tune$(tunenum)
play audio 50:audio loop on 50:volume audio 50,90
do
if timer>4
add tunenum,1,1 to tunes
print tunenum
stop audio 50
audio loop off 50
load asset "tunes\"+tune$(tunenum),50
print str$(tunenum),"tunes\"+tune$(tunenum)
play audio 50
audio loop on 50
volume audio 50,90
timer=0
end if
wait vbl
loop
When I test this with short samples I usually get a repeated sample, and doing the same in a game using longer tuners I often get the previous tune playing again but it plays the next one at the same time.
This seems to work correctly in a browser.
Updated by Paul Kitching almost 3 years ago
I think it's doing it in a browser sometimes, too. I haven't had it with the example above using my test mp3s (it was in a game I'm finishing off), but once that's fixed it should fix it when played in a browser. It looks like the player is more likely to do it.
Updated by Paul Kitching almost 3 years ago
I tried using a different asset number for each tune, but when I tried
tunenum=1
play audio 49+tunenum
I get an error saying the message identifier isn't found and audio_not_loaded
Updated by Paul Kitching almost 3 years ago
I've found a workaround.
If you put a wait 0.5 after a load asset so it waits before playing it, it will then work.
Updated by Baptiste Bideaux almost 3 years ago
- Status changed from New to Resolved
- Assignee changed from Francois Lionet to Baptiste Bideaux
The Load Asset command detects if a file already uses the reference given as an argument and does not perform the second loading.
By Example:
Load Asset "asset1.png", 50 // Loading the asset1.png file and stores it under the reference 50.
...
Load Asset "asset2.png", 50 // The load will not collapse because the reference 50 is used by another image.
...
If you want to update an asset already loaded, you should to delete the previous asset :
Load Asset "asset1.png", 50 // Loading the asset1.png file and stores it under the reference 50.
...
Del Asset "image", 50 // Delete of the images bank the asset referenced 50.
Load Asset "asset2.png", 50 // Loading the asset2.png file and stores it under the reference 50.
...