最简单的方法从Visual c播放mp3 ++ [英] Simplest way to play mp3 from Visual C++
问题描述
几年前,我写了一些util的库周围DSHOW / DSOUND让我在Windows C ++应用程序播放MP3。现在仍然是正常的方式做到这一点在C ++ / MFC应用程序,或者是说已被归入一般的Windows API DirectX的面积?
A few years back, I wrote some util library around DShow/DSound to let me play MP3s in a Windows C++ application. Is that still the normal way to do it in a C++/MFC app, or is that an area of DirectX that has been subsumed into the general Windows APIs?
的动机很简单,我们使用标准的Windows PlaySound方法为WAV文件,并希望能够使用一个同样简单的API来播放MP3,无论是Windows还是我们写来包装更复杂的功能的东西提供。
The motivation is simply we use the standard Windows PlaySound method for WAVs, and would like to be able to play MP3s using a similarly simple API, either provided by Windows or something we write to wrap more complex functionality.
编辑:这是一个大的,商业的,封闭源代码的项目。我们只希望简单的玩的东西,付出了很多的库不会飞。
this is for a large, commercial, closed-source project. And we only want to play things simply, paying a lot for a library won't fly.
推荐答案
您可以使用DirectShow的,但它不是DirectX的一部分了,或依赖于第三方库类似的低音,闪存模块,的 mpg123的甚至 libwmp3 。
You can either use DirectShow but it's not part of DirectX anymore or rely on a third-party library like Bass, FMod, mpg123 or even libwmp3.
如果您不想再使用的DirectShow(?但为什么变化,如果你现有的code一直工作),你可以使用的 MCI :
If you don't want to use DirectShow anymore (but why change if your existing code keeps working?), you can use MCI:
mciSendString("open la_chenille.mp3 type mpegvideo alias song1", NULL, 0, 0);
mciSendString("play song1", NULL, 0, 0);
mciSendString("close song1", NULL, 0, 0);
这篇关于最简单的方法从Visual c播放mp3 ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!