Reputation: 431
i am trying to develop a media player using windows media player component in c#.net. this is my code by which i can make play list and add the songs to the playlist and the name of the playlist will be shown in the listbox named "playlistviewbar" and then i have set this playlist to current playlist.
but when i run the project and current plaulist set it ask to play the media that is not match wich player. it shows that it has extension "." and it fails to play the media
can any one help me to resolve this problem and also help me for saving the playlist..
WMPLib.IWMPPlaylist pl;
public WMPLib.IWMPMedia files1,paths1;
string playListName;
private void toolStripButton3_Click(object sender, EventArgs e)
{
if (listnametxt.Text == "")
{
playListName = "Untitled playlist";
}
else
{
playListName = listnametxt.Text;
}
pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist(playListName);
playlistviewbar.Items.Add(playListName);
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] filestring=openFileDialog2.SafeFileNames;
string[] pathstring=openFileDialog2.FileNames;
for (int i = 0; i < filestring.Length; i++)
{
files1 = axWindowsMediaPlayer1.newMedia(filestring[i]);
paths1 = axWindowsMediaPlayer1.newMedia(pathstring[i]);
pl.appendItem(paths1);
axWindowsMediaPlayer1.currentPlaylist =pl;
}
}
}
Upvotes: 2
Views: 6519
Reputation: 761
here is the code which is working for me :
private void button1_Click(object sender, EventArgs e)
{
var pl = axWindowsMediaPlayer1.playlistCollection.newPlaylist("plList");
pl.appendItem(axWindowsMediaPlayer1.newMedia(@"D:\nosazi.wmv"));
pl.appendItem(axWindowsMediaPlayer1.newMedia(@"D:\tasadof.mp4"));
axWindowsMediaPlayer1.currentPlaylist = pl;
axWindowsMediaPlayer1.Ctlcontrols.play();
}
Upvotes: 3