I wrote this code to make my wav playing when I click my button. There is no bugg(s). But its doesnt play. I dont understand why? Very strange. Any help please:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
namespace Playing_sounds
{
public partial class Form1 : Form
{
private SoundPlayer _soundPlayer;
public Form1()
{
InitializeComponent();
_soundPlayer = new SoundPlayer("Bass Line.wav");
}
private void duelStateButton_CheckedChanged(object sender, EventArgs e)
{
if (duelStateButton.Checked)
{
duelStateButton.Text = "Stop";
_soundPlayer.Play();
}
else
{
duelStateButton.Text = "Play";
_soundPlayer.Stop();
}
}
}
}
Selva GanapathyPosted Dec 15, 2014, 3:54 AM
Hi Israel,
Your code shippet is right but I suspect it will trouble to load the file, Please check your application using relative path as below as "../../"
_soundPlayer = new SoundPlayer("../../tamil.wav"); instead of _soundPlayer = new SoundPlayer("tamil.wav");
Regards,
Selva Ganapathy K