PLAY (function)
Jump to navigation
Jump to search
The PLAY function returns the number of remaining seconds in the background music queue.
Syntax
- remaining# = PLAY(voice&)
Parameters
- remaining# is the number of seconds left to play in the background music queue.
- voice& can be any numeric expression. It indicates for which tone voice channel the number of seconds remaining is to be returned. If voice& is not in [0-3], the queue for voice 0 is returned.
- See also the important version dependent notes in the Availability section.
Description
- This function may be used to detect, if the background music queue is still playing.
- When there is nothing left to play, then this function returns zero.
Availability
- In QB64 and early QB64-PE, this was just implemented as stub function which always returned zero.
- Since QB64-PE v3.1.0 the function is fully implemented, but unlike QuickBASIC, in QB64-PE this function does not return the number of notes left, but the number of audio samples.
- Since QB64-PE v3.8.0, if voice& is a number other than zero, then the function will return the amount of time (seconds) left to play.
- Multi-voice support was introduced in QB64-PE v4.0.0.
- Since QB64-PE v4.0.0, the function will return the amount of time (seconds) left to play for the tone voice channel specified.
Examples
OPTION _EXPLICIT CONST MML = "mbv15l16t155o2mnb4p8msbbmnb4p8msbbb8g#8e8g#8b8g#8b8o3e8o2b8g#8e8g#8b8g#8b8o3e8o2mnb4p8msbbmnb4" + _ "p8msbbmnb4p8msbbmnb4p8msbbb8bbb8b8b8bbb8b8b8bbb8b8b8bbb8b8mlb2b2b8p8p4p4p8mso1bbb8bbb8bbo2e8f#8g#8o1bb" + _ "b8bbo2e8g#g#f#8d#8o1b8bbb8bbb8bbo2e8f#8g#8eg#mlb4bmsag#f#e8g#8e8o3bbb8bbb8bbo4e8f#8" + _ "g#8o3bbb8bbo4e8g#g#f#8d#8o3b8bbb8bbb8bbo4e8f#8g#8mleg#b4bag#f#mse8g#8e8o3g#g#g#8g#g#g#8g#g#" + _ "g#8o4c#8o3g#8o4c#8o3g#8o4c#8o3g#8f#8e8d#8c#8g#g#g#8g#g#g#8g#g#g#8o4c#8o3g#8o4c#8" + _ "o3g#8o4c#8o3b8a#8b8a#8b8g#g#g#8g#g#g#8g#g#g#8o4c#8o3g#8o4c#8o3g#8o4c#8o3g#8f#8" + _ "e8d#8c#8g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o4ao3bo4ao3bp16mlg#o4g#o3mng#p16mld#o4d#o3mnd#p16" + _ "mleo4eo3mnep16mlao4ao3mnap16mlg#o4g#o3mng#p16mld#o4d#o3mnd#p16mleo4eo3mnep16" + _ "mlao4ao3mnao4go3go4go3go4go3go4go3go4msg8e8c8e8o4mng#o3g#o4g#o3g#o4g#o3g#o4g#o3g#o4msg#8e8o3b8o4e8mng#o3g#o4g#o3g#o4g#" + _ "o3g#o4g#o3g#o4msg#8f8c#8f8mna#o3a#o4a#o3a#o4a#o3a#o4a#o3a#o4msa#8g8e8g8b8p16mna#p16ap16g#p16f#p16ep16" + _ "d#p16c#p16o3bp16a#p16ap16g#p16f#p16ep16d#p16f#mlef#g#mnamlg#abmno4c#o3mlbo4c#d#mnemld#ef#mng#ao3bo4ao3bo4a" + _ "o3bo4ao3bo4ao3bo4ao3bo4ao3bo4ao3bmlef#g#mnamlg#abmno4c#o3mlb" + _ "o4c#d#mnemld#ef#mng#ao3bo4ao3bo4ao3bo4ao3bo4ao3bo4ao3bo4a" + _ "o3bo4ao3bp16mlg#o4g#o3mng#p16mld#o4d#o3mnd#p16mleo4eo3mnep16mlao4ao3mnap16" + _ "mlg#o4g#o3mng#p16mld#o4d#o3mnd#p16mleo4eo3mnep16mlao4ao3mnao4go3go4go3go4g" + _ "o3go4go3go4g8e8c8e8g#o3g#o4g#o3g#o4g#o3g#o4g#o3g#o4g#8e8o3b8o4e8g#o3g#o4g#o3g#o4g#o3g#o4g#o3g#o4msg#8mnf8c#8" + _ "f8a#o3a#o4a#o3a#o4a#o3a#o4a#o3a#o4a#8g8e8g8b8p16a#p16ap16g#p16f#p16ep16d#p16c#p16o3bp16a#p16" + _ "ap16g#p16f#p16ep16d#p16fmled#ed#mne8bbb8bbb8bbo4e8f#8g#8o3bbb8bbb8bbo4g#8a8b8p8e8f#8g#8p8o3g#8" + _ "a8b8p8p2o2bco3c#dd#eff#gg#aa#bco4c#d#ed#f#d#ed#f#d#ed#f#d#ed#f#d#ed#f#d#ed#f#d#ed#f#d#e" + _ "d#f#d#e8eo3eo4eo3eo4eo3eo4e8o3bo2bo3bo2bo3bo2bo3b8g#o2g#o3g#o2g#o3g#o2g#o3g8eo2eo3eo2eo3eo2eo3e8eee8" + _ "e8e8o2bbb8b8b8g#g#g#8g#8g#8eee8e8e8o1b8o2e8o1b8o2g#8e8b8g#8o3e8o2b8o3e8o2b8o3g#8e8b8g#8o4e4" + _ "p8eee8e8e8e8e4p8p16ee4p8p16o2ee2" LOCATE 12, 28 PRINT "The William Tell Overture." PLAY MML DIM secondsLeft AS LONG DO LOCATE 13, 32 secondsLeft = PLAY(0) PRINT USING "(### seconds left)"; secondsLeft; _LIMIT 30 LOOP WHILE secondsLeft _ANDALSO _KEYHIT <> 27 END |
See also