Active Forums => QB64 Discussion => Topic started by: Dav on October 21, 2021, 10:41:04 am
Title: How to detect if PLAY "MB" is done playing a song?
Post by: Dav on October 21, 2021, 10:41:04 am
I'm starting to make some background tunes to loop/play for my puzzle games using the PLAY "MB.." command. Was wondering if there is a way to detect when a PLAY command is finished playing the tune so I can replay it or load another song. I suppose I could time how long a tune plays, and set up a timer to restart it, but was wondering is there's a built-in way to detect the finish that I don't know about. Thanks!
- Dav
Title: Re: How to detect if PLAY "MB" is done playing a song?
Post by: bplus on October 21, 2021, 12:04:56 pm
Might be _sndplay function?, check Wiki. I know you can put a sound in a loop so it starts right back up after finishing one cycle.
Ha! pretty close, see _SndPlaying Function :)
I luv it when you can guess what a keyword might be.
Title: Re: How to detect if PLAY "MB" is done playing a song?
Post by: bplus on October 21, 2021, 12:22:54 pm
Oh the old Play command, sorry.
Can you record Play sounds to file to use _SndPlay?
Or do something like we do with images, record the sound in separate "destination" then play the destination stored in memory. Perhaps with memory handles.
Just need to load a Play string$ into a memory handle.
Title: Re: How to detect if PLAY "MB" is done playing a song?
Post by: Pete on October 21, 2021, 01:03:13 pm
Old school, but perhaps not what you are looking for...
In QuickBASIC, that runs properly. PLAY(0) is (was) a function to store the number of notes left in the buffer. In QuickBASIC, the program starts, and halfway through the scale, if prints "Half finished!" The after the scale completes, it prints "Finished." In QB64 v1.0 and V2.0, the PLAY(0) function is not supported, so the screen printing completes immediately.
I'm a bit surprised Rob never implemented this function.
@Dav Sorry, I thought I had something for you there, but not unless you want to code your app in QuickBASIC.
Pete
Title: Re: How to detect if PLAY "MB" is done playing a song?
Post by: Dav on October 21, 2021, 08:02:02 pm
Well thanks anyhow @Pete for the suggestion. I may just go with sound files after all.
- Dav
Title: Re: How to detect if PLAY "MB" is done playing a song?
Post by: Pete on October 21, 2021, 10:25:26 pm