Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Playing one tune after the other one's finished

Author
Message
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Aug 2005 16:35
i want music to play one after the other, i have a way of doing it, though i thought there would be an easier way. my idea was to egt the length of the tune, then increase a variable and once it gets to the length of the tune, stop that tune, and start the next one etc... but is there a better way? thanks

Your signature has been erased by a mod because it's larger than 600x120...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Aug 2005 16:44
Yup, I made a neat little MP3 player as my first DB project and it was quite straightforward - it just sits in a folder of mp3's playing them in a random sequence.

Look into the MUSIC PLAYING(music) command, and just monitor it in your main loop, when it returns a 0 it's time to load up and start the next track. Remember to PLAY MUSIC and not LOOP MUSIC though, otherwise it'd never stop playing.


Van-B

Put those fiery biscuits away!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Aug 2005 17:00 Edited at: 4th Aug 2005 17:06
oh man! i cant believe i forgot about the MUSIC PLAYING command

i tried MUSIC STOPPED command and it sucked! thanks alot van


edit:
damn! i did it, and it works, but it plays so sloooowww in the main loop

Your signature has been erased by a mod because it's larger than 600x120...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 4th Aug 2005 18:13 Edited at: 4th Aug 2005 18:13
Strange - really your .mp3 should play fine, perhaps the SOUND PLAYING check is running really fast in your main loop and causing a delay that is emalgamating the problem.

Perhaps try something like this:

Play music 1
Do
If rnd(100)=1
If music playing(1)=1 then play music 2
endif
sync
Loop


That would only check the music playing about once a second instead of constantly, so it should'nt affect playback very much at all. Perhaps post the code from your main loop, so we can check for anything not obvious that might cause the problem.


Van-B

Put those fiery biscuits away!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Aug 2005 18:51
i think you ment "if music playing(1)=0".. and yes it works! wooho!! thanks

Your signature has been erased by a mod because it's larger than 600x120...
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Aug 2005 18:51


You can do some good stuff with these commands, SOUND PLAYING() works well when called every loop. I had a game with all the background music made up of 4 second loops. It meant that you could change to the end of level track within 4 seconds, seamlessly.

Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 4th Aug 2005 21:15
I think this is right:
load ... 1
load ... 2

do
if sound/music playing(1)=0
if sound playing(2)=0 then play sound 2
endif
loop

[href][/href]
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Aug 2005 21:36
well van b's one worked fine, so no need to reply to this thread anymore

Your signature has been erased by a mod because it's larger than 600x120...

Login to post a reply

Server time is: 2025-05-22 17:33:23
Your offset time is: 2025-05-22 17:33:23