Play a WAV audio file (this howto is deprecated)

From CodeCodex

Implementations[edit]

Java[edit]

import com.ms.win32.Winmm;
import com.ms.win32.wins;

public class WavAudio {
  private String wavFile=null;
  public WavAudio(String file) {
    wavFile=file;
    }
  public void stop() {
    Winmm.PlaySound(null,0,
       wins.SND_ASYNC|wins.SND_FILENAME|wins.SND_NOWAIT);
    }
  public void playAsync() {
    stop();
    Winmm.PlaySound(wavFile,0,
      wins.SND_ASYNC|wins.SND_FILENAME|wins.SND_NOWAIT);
    }
  public void playSync() {
    stop();
    Winmm.PlaySound(wavFile,0,
      wins.SND_SYNC|wins.SND_FILENAME|wins.SND_NOWAIT);
    }

  public void loop() {
    // stop();
    Winmm.PlaySound(wavFile,0,
      wins.SND_ASYNC|wins.SND_LOOP|wins.SND_FILENAME|wins.SND_NOWAIT);
    }
     
  public static void main(String args[]) {
    // for demonstration ...
       WavAudio ac = 
        new WavAudio("c:/windows/media/Chord.wav");
    System.out.print("Playing ...");
    ac.playSync();
    System.out.println("Done...");
  }
}

Tcl[edit]

package require snack
snack::sound s -load c:/windows/media/Chord.wav
s play