Project

General

Profile

Bug #858

Play Audio sometimes playing the wrong audio in the internal player

Added by Paul Kitching over 2 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Target version:
Start date:
10/30/2021
Due date:
% Done:

0%

Estimated time:
Affected version:

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.

#1

Updated by Paul Kitching over 2 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.

#2

Updated by Paul Kitching over 2 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

#3

Updated by Paul Kitching over 2 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.

#4

Updated by Baptiste Bideaux over 2 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.
...

Also available in: Atom PDF