Play a WAV audio file (this howto is deprecated)

From CodeCodex

Revision as of 15:04, 20 February 2011 by 79.91.219.32 (Talk)

Implementations

Java

<highlightsyntax language="java122"> 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...");
 }

} </highlightsyntax>

Tcl

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