简体   繁体   中英

Adding Windows Media Player to c# program

I'm looking to start using windows media player in my c# application. My first problem was locating wmp.dll in my Windows 7 install, which was not in \\windows\\system32\\ but rather in C:\\Windows\\winsxs\\amd64_microsoft-windows-mediaplayer-core_31bf3856ad364e35_6.1.7601.17514_none_698fc88e65b943d6

So I have added this as an assembly in SharpDevelop, and expected to be able to use this, via 'using WMPLib;' at the start of my code. This namespace name cannot be found.

Does anyone know what is going on here aside from my lack of insight?

Update:

I added references to PresentationCore and WindowsBase, and tried to use System.Windows.Media.MediaPlayer:

            WMP_EATEN_PILL = new System.Windows.Media.MediaPlayer();
            WMP_EATEN_PILL.Open(new System.Uri(@"D:\Programming\SFX\EATEN_PILL\Hit_43_s.wav"));
            WMP_EATEN_PILL.Play();

This doesn't play a sound. The path is correct (and I think I don't need to escape the back-slashes right?) so I'm not sure what is happening here.

Is there anything obviously wrong here?

尝试将其添加到引用中,右键单击您的项目,单击“添加引用”,然后添加选择Windows Media Player,然后单击“确定”按钮。

You need to use double backslash on your path.

Try this:

var WMP_EATEN_PILL = new System.Windows.Media.MediaPlayer();
WMP_EATEN_PILL.Open(new System.Uri(@"D:\\Programming\\SFX\\EATEN_PILL\\Hit_43_s.wav"));
WMP_EATEN_PILL.Play();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM