From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC


This command will play a sound file (wav). The playing mode is optional. if the external file is missing the default Windows alert will be played (defined in your Windows sound scheme).
Only one wave file will play at a time, subsequent playing will override the previous sound.


1. playwave "example.wav", async ' will play without stopping your code being executed.
2. playwave "example.wav", asynch ' same as above.
3. playwave "example.wav", sync ' will play and your program will wait until the wave playing finishes.
4. playwave "example.wav", synch ' same as above.
5. playwave "example.wav" ' same as above.
6. playwave "example.wav", loop ' will play the file over and over.
7. playwave "" ' will stop playing or will stop any sound file.


Place useful hints about this keyword here


This example uses the WAV sound file from this article. Save it to a folder of your choice and run this code from the same folder.

'If the example.wav is missing, the default Windows beep will play instead.
    button #main.b1 "PlayWave /asynch",[doPlayA],ul,10,10
    button #main.b2 "PlayWave /synch",[doPlayB],ul,10,50
    button #main.b3 "PlayWave Start Loop",[doPlayC],ul,10,90
    button #main.b3 "Stop!",[doPlayD],ul,10,140

    open "Just BASIC - Playwave" for window_nf as #main
    #main "trapclose [quit]"

    playwave "example.wav" , asynch

    playwave "example.wav" , synch

    playwave "example.wav" , loop

    playwave ""

    close #main

Useful Procedures

' Place a useful function or sub using this keyword here