Reputation: 2383
How can I give the playing song path of any player?
using System;
using System.Windows.Forms;
using WMPLib;
namespace EliteMusic
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
WindowsMediaPlayerClass player=new WindowsMediaPlayerClass();
MessageBox.Show(player.currentMedia.name);
}
}
}
I get this error :
Object reference not set to an instance of an object.
Upvotes: 0
Views: 392
Reputation: 19800
This is because currentMedia is not set (null). You have to specify a path first to play with the WindowsMediaPlayerClass.
Upvotes: 1