Ayub
Ayub

Reputation: 2383

How can I give the playing song path of any player?

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

Answers (1)

RvdK
RvdK

Reputation: 19800

This is because currentMedia is not set (null). You have to specify a path first to play with the WindowsMediaPlayerClass.

Upvotes: 1

Related Questions