I think you have to reffrence Windows Media Player within your program in order to play .mp3's (as well as .wmv, .asx, and any other files the WMP plays). Below is a excert of a program I wrote that plays music and videos using the WMP:
This portion of the program allows the user to open a file that has either a .mp3, .wmv, or any extension and play it in a Windows Media Player like window within the parent form.
I used this code, as it looks straight forward, but i was told the userFile does not exist in current context. I dont understand why, as i believe it is defined here : userFile = openFileDialog1.FileName; //userFile = file user chose
I think you have to reffrence Windows Media Player within your program in order to play .mp3's (as well as .wmv, .asx, and any other files the WMP plays). Below is a excert of a program I wrote that plays music and videos using the WMP:
This portion of the program allows the user to open a file that has either a .mp3, .wmv, or any extension and play it in a Windows Media Player like window within the parent form.
c# and mp3
eam0n
I used this code, as it looks straight forward, but i was told the userFile does not exist in current context. I dont understand why, as i believe it is defined here : userFile = openFileDialog1.FileName; //userFile = file user chose
any reason aas to why its tellin me this
Marian Pascalau
http://msdn.microsoft.com/windowsmedia/downloads/default.aspx
Then you can play mp3 inside of your app on this way:
(First you need to add Interop.WMPLib.dll refernce)
WMPLib.WindowsMediaPlayer winmp = new WMPLib.WindowsMediaPlayer();
wmp.URL = "song_path";
wmp.controls.play();
Enggtp
i have seen the network property but that doesnt have these properties.
thanks
Asim
The Aqua
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Video (.wmv)|*.wmv|Music (.mp3)|*.mp3|ALL Files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.ShowDialog(); //Open File dialog box
userFile = openFileDialog1.FileName; //userFile = file user chose
axWindowsMediaPlayer1.URL = userFile; //WMP plays file user chose
}
This portion of the program allows the user to open a file that has either a .mp3, .wmv, or any extension and play it in a Windows Media Player like window within the parent form.