Skip to content

The wav c# player stops playing the song after 4/5 seconds

G?a???? ?a?

Asked Jul 28, 2014, 11:34 PM EDT1 answer
Share
LinkedInX
i have made a simple wav player in c# and here is my code
TypeScript
 *******************************************
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 WindowsFormsApplication1
{

    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();

        }

        private void next_Click(object sender, EventArgs e)
        {

        }

        private void nnext_Click(object sender, EventArgs e)
        {

        }

        private void playpause_Click(object sender, EventArgs e)
        {
            try
            {
                string sptbvs = sptb.Text;
                SoundPlayer my_wave_file = new SoundPlayer(sptbvs);
                my_wave_file.PlaySync();
            }
            catch (InvalidCastException)
            {
                MessageBox.Show("Error 502 :invalid Path.");
            }
        }

        private void sptb_TextChanged(object sender, EventArgs e)
        {
            string sptbvs = sptb.Text;
        }

        private void before_Click(object sender, EventArgs e)
        {

        }

        private void bbefore_Click(object sender, EventArgs e)
        {

        }


    }
}
*********************************************
but when i click the play/pause button the song starts properly and after some seconds (usualy 4) it stops playing the song 
 why is this happening
please help

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    any error it throws? which control are you using for the player
    0