Skip to content

Instantly share code, notes, and snippets.

@money4honey
Created August 6, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save money4honey/ebd1ebd78c8103b74846 to your computer and use it in GitHub Desktop.
Save money4honey/ebd1ebd78c8103b74846 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace myClasses
{
public class PlayWav
{
static System.Media.SoundPlayer player = new System.Media.SoundPlayer();
public static void Play(string path) {
if (path.Contains(".wav")) {
if (File.Exists(path)) {
player.SoundLocation = path;
player.Play();
}
}
}
public static void PlayLoop(string path) {
if (path.Contains(".wav")) {
if (File.Exists(path)) {
player.SoundLocation = path;
player.PlayLooping();
}
}
}
public static void Stop() {
player.Stop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment