如何使用 NAudio 播放 mp4 歌曲

发布于 2024-12-07 22:50:02 字数 73 浏览 2 评论 0原文

我们可以使用 NAudio 播放 mp4 歌曲吗? 请提供一些播放 mp4 歌曲的代码 我需要 c# 代码来帮助我播放 mp4 歌曲

Can we play mp4 songs using NAudio?
Please provide some code to play mp4 songs
I need a c# code that will help me play mp4 songs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帅冕 2024-12-14 22:50:02

您可以使用NAudio播放.mp4文件,官方页面中有一个演示。

下载演示应用程序并查找“媒体基础演示”。演示的 C# 代码可以在 NAudio 的源代码中找到。

实现位于 WasapiOutGuiThread 类中:

WasapiOutGuiThread  : IWavePlayer

You can play .mp4 files using NAudio, there is a demo in the official page.

Donwload the Demo-Apps and look for the "Media Foundation Demo". The C# code of the demo can be found at the Source Code of NAudio.

The implementation is in the WasapiOutGuiThread class:

WasapiOutGuiThread  : IWavePlayer
逐鹿 2024-12-14 22:50:02

更新: NAudio 现在可以使用 MediaFoundationReader 播放 MP4 文件(假设您安装了适当的编解码器)。这适用于 Windows Vista 及更高版本,如果您运行的是 Windows Server,则可能需要安装“桌面体验”。

替代方法是查看 WPF Media Element 是否可以播放它,或者使用 Windows Media Player ActiveX 控件(在可以播放 MP4 的操作系统上)。

Update: NAudio can now play MP4 files using the MediaFoundationReader assuming you have the appropriate codecs installed. This works on Windows Vista and above, and if you are running Windows Server you may need to have the "Desktop Experience" installed.

Alternative approaches would be to see if the WPF Media Element can play it, or using the Windows Media Player ActiveX control (on an OS that can play MP4s).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文