rockstat 0 Newbie Poster

Hello Everyone

I am new to this forum and hope I can get some help and vice-versa.

I am doing this little project for my self in C Sharp and it involves WMP.

I have provided my code at the bottom and appreciate any help I can get.

I am trying to play a media file and it keeps coming up with the error: "The file you are attempting to play has an extension (.) that does not match the file format."

Is there a line that I am missing or forgetting to add/initialize something?

THanks.

namespace Form1
{
    public partial class Main : Form
    {
        WindowsMediaPlayer Player;
        public Main()
        {
            InitializeComponent();
            Player = new WindowsMediaPlayer();
         }

        private void Browsebutton_Click(object sender, EventArgs e)
        {
            Stream myStream;
            OpenFileDialog browseDialog = new OpenFileDialog();

            browseDialog.InitialDirectory = "c:\\";
            browseDialog.Filter = "mp3 files (*.mp3)|*.mp3|wav files (*.wav)|*.wav|wmv files (*.wmv)|*.wmv";
            browseDialog.FilterIndex = 1;
            browseDialog.RestoreDirectory = true;

            if (browseDialog.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = browseDialog.OpenFile()) != null)
                {
                    FilenametextBox.Text = browseDialog.FileName;
                    myStream.Close();
                }
            }

        }

        private void Playbutton_Click(object sender, EventArgs e)
        {
            Player.URL = browseDialog.FileName;
            Player.controls.play();
        }

        private void Stopbutton_Click(object sender, EventArgs e)
        {
            Player.controls.stop();
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.