Directives error trying to play .mp3 files in c #


Currently I want to play audio files in mp3 and I already have fragments of the code that theoretically should work.

Current Code:

using WMPLib; ------ Error

    public void timerson() {
        MessageBox.Show("Cada cierto tiempo segundos");
        WindowsMediaPlayer myplayer = new WindowsMediaPlayer(); --- Error
        myplayer.URL = @"C:\Users\david\Music\Cancion.mp3";;

Only the following error marks me:


Missing a using directive or an assembly reference

asked by David 30.04.2017 в 16:58

1 answer


WMPLib comes from the COM component of Windows Media Player, you have to add a reference to the COM wmp.dll library in c: \ Windows \ System32 to make your program work, in case you do not have it on your computer.

You need to add the reference to Windows Media Player , with this you must recognize the namespace WPLib. You can find this reference in the category COM when adding references.

You must do it as in the following image:

answered by 30.04.2017 / 17:34