Frage

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.

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top