PLAYWAVE

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

Description

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.

Syntax

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.

Hints

Place useful hints about this keyword here

Example

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]"
    wait

[doPlayA]
    playwave "example.wav" , asynch
    wait

[doPlayB]
    playwave "example.wav" , synch
    wait

[doPlayC]
    playwave "example.wav" , loop
    wait

[doPlayD]
    playwave ""
    wait

[quit]
    close #main
    end

Useful Procedures

' Place a useful function or sub using this keyword here