如何在C播放MP3文件? [英] How to play MP3 files in C?

查看:243
本文介绍了如何在C播放MP3文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找发挥C的MP3文件,最简单的方法我在找无论是图书馆,我可能只是呼吁文件名功能,或将只运行和退出的可执行文件。请建议。

I'm looking for the easiest way to play a MP3 file in C. I am looking for either a library, in which I could just call the function on the filename, or an executable that will just run and quit. Please suggest.

推荐答案

使用 FMOD (跨平台),这应该是像这样简单:

Using FMOD (cross platform), this should be as simple as this:

#include <conio.h>
#include "inc/fmod.h"

FSOUND_SAMPLE* handle;

int main ()
{
   // init FMOD sound system
   FSOUND_Init (44100, 32, 0);

   // load and play mp3
   handle=FSOUND_Sample_Load (0,"my.mp3",0, 0, 0);
   FSOUND_PlaySound (0,handle);

   // wait until the users hits a key to end the app
   while (!_kbhit())
   {
   }

   // clean up
   FSOUND_Sample_Free (handle);
   FSOUND_Close();
}

作为一个方面说明,我建议你使用C ++对C

As a side note, I'd suggest you using C++ over C.

这篇关于如何在C播放MP3文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆