在WinForm应用程序播放MP3文件

编程入门 行业动态 更新时间:2024-10-27 04:25:29
本文介绍了在WinForm应用程序播放MP3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开发一个的WinForm 应用程序。我想,当用户点击一个按钮来播放MP3文件。

I am developing a WinForm application. I want to play a MP3 file when the user clicks a button.

通过MP3文件位于其中执行应用程序的计算机的文件系统中。结果​​,我用Google搜索了一会儿,我发现关于 System.Media.SoundPlayer 类的信息。但我已阅读了声音播放类只能用于以.wav格式的播放文件。

The MP3 file is located in the file system of the computer where the application is executed. I have Googled for a while and I have found information about the System.Media.SoundPlayer class. But I have read that the SoundPlayer class can only be used to play files in .wav format.

什么类可用于mp3格式播放文件?

What classes can be used to play files in .mp3 format ?

任何帮助将大大AP preciated。

Any help will be greatly appreciated.

推荐答案

下面的链接,给出了一个非常好的教程,有关从窗口播放MP3文件形成用C#:

The link below, gives a very good tutorial, about playing mp3 files from a windows form with c#:

www.daniweb/software-development/csharp/threads/292695/playing-mp3-in-c

这个链接将带你到一个主题,包含有关如何播放MP3歌曲,使用Windows窗体了很多信息。它还包含了许多其他项目,努力实现同样的事情:

This link will lead you to a topic, which contains a lot information about how to play an mp3 song, using Windows forms. It also contains a lot of other projects, trying to achieve the same thing:

social.msdn.microsoft/forums/en-US/csharpgeneral/thread/3dbfb9a3-4e14-41d1-afbb-1790420706fe

例如使用code为.MP3:

For example use this code for .mp3:

WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = "My MP3 file.mp3"; wplayer.Controls.Play();

那么只有把wplayer.Controls.Play();在Button_Click事件。

Then only put the wplayer.Controls.Play(); in the Button_Click event.

例如使用code为.WAV:

For example use this code for .wav:

System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = "Sound.wav"; player.Play();

把player.Play();在Button_Click事件,它将工作。

Put the player.Play(); in the Button_Click event, and it will work.

更多推荐

在WinForm应用程序播放MP3文件

本文发布于:2023-11-23 15:37:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621976.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   文件   WinForm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!