English 中文(简体)
C# Play MP3 from Resources with MCI or WMP control?
原标题:

I have a MP3 file in my Resources of Visual C#. I m trying to find out if there is a way I can play this MP3 in a Windows Media Player control or with MCI, I m not particular. I m fairly new to C#. Thanks!

问题回答

This page shows you how in just a few lines of code:

http://www.crowsprogramming.com/archives/58

Hope this helps.

Edit: Be sure to copy the .mp3 to your bin before you run it.

And here is the source code. Be sure to add a reference to wmp.dll in your project.

WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer();
wmp.URL = "test.mp3";
wmp.controls.play();

this is a component for playing MP3 with C# on Windows Forms (it includes a demo app).

http://www.codeplex.com/keniamm/

hope this helps





相关问题
how to use DynamicResource in the code behind?

I d like to be able to set a property to a dynamic resource programmatically. myControl.Property = this.Resource[key] is not a valid response, since if the resource with the key key is replaced, ...

PHP - Foreach loops and ressources

I m using a foreach loop to process a large set of items, unfortunately it s using alot of memory. (probably because It s doing a copy of the array). Apparently there is a way to save some memory with ...

C# Play MP3 from Resources with MCI or WMP control?

I have a MP3 file in my Resources of Visual C#. I m trying to find out if there is a way I can play this MP3 in a Windows Media Player control or with MCI, I m not particular. I m fairly new to C#. ...

Convert files of any types to a file with c strings

Please suggest a small command-line utility (for Windows) to convert files from particular directory to a valid c file. Maybe it can be done just with batch commands? The resulting file should look ...

How to sort ResourceSet in C#

I have a resource file named filetypes.resx. Some how I figured out to bind the resource values to dropdownlist, but I don t know how to sort the values of ResourceSet. Here is what I did so far, ...

热门标签