This is the code i needed, it`s not fully functional as i wanted but is an approach to the right direction.It can play music, then detect if the sounds is played to the end and stop it.
The problem was that i never stoped the sound from playing and dbpro just tried to do it from the point where the sound ends.
I think that because even there is no sound produced the play music comand shows that it`s playing when conditions are met.
sync on:sync rate 60
backdrop on
load music "Media/Sounds/scream.mp3",2
do
text 0,0,"music exist 2= "+str$(music exist(2))
text 0,20,"music playing 2= "+str$(music playing(2))
if mouseclick()=1 and press = 0
press = 1
play music 2
endif
if mouseclick()=0 then press = 0
if music playing(2)=0 then stop music 2
sync
loop
@Todd Riggins
Thank you for sharing this Todd.I have to ask you when you load a lot of sounds is there any performance punches?You didn`t mentioned what happens when the sounds/musics are done playing?I doubt that dbpro realease them automaticly so there can be expected speed drops or not?
EDIT: I manage to do it myself, how stupid to ask for help when i knew the answer...
There is the code:
sync on:sync rate 60
backdrop on
dim music(9) as integer
do
for x = 0 to 9
text 0,0+x*20,"musics("+str$(x)+") = "+str$(music(x))
next x
if mouseclick()=1 and press = 0
press = 1
play_music()
endif
if mouseclick()=0 then press = 0
delete_music()
sync
loop
function play_music()
FreeMusicID = find free music()
load music "Media/Sounds/scream.mp3",FreeMusicID
if FreeMusicID => music(9)
music(9) = FreeMusicID
reverse sort array music()
endif
for play = 0 to 9
if music(play) > 0
play music music(play)
endif
next play
endfunction
function delete_music()
for play = 0 to 9
if music(play)>0
if music exist(music(play)) = 1
if music playing (music(play)) = 0
delete music music(play)
music(play) = 0
endif
endif
endif
next play
endfunction
When statements for playing are met, begin search for free music id, i used matrix1`s plugin for this.Then there is a check made against an array for storing the music id, then again with matrix1 sort comand the array is sorted, then all sounds stored in the array are played.
Next step is to unload the music with delete_music function.It checks the id`s stored in our array then if the sound is playing or not.If not this means it`s have been played allready, because in the same time of making it we begin playing it, "music playing() = 0" means only that.Next we delete the sound to clear it from memory and then clear it`s place/id in the array.
This goes immediately to Code Snippets
Thanks to all and thanks to myself for not being lazy!
Where there is a will, there is a way.
I often edit my posts, that`s who i am