我们如何在c ++中播放音频文件?检索音频文件的简单代码应该是什么? [英] how can we play audio files in c++? what should be the simple code to retrieve audio file ?

查看:131
本文介绍了我们如何在c ++中播放音频文件?检索音频文件的简单代码应该是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何用c ++播放音频文件?

how can we play audio files in c++? what should be the simple code to retrieve audio file and play it on the execution of the program?

推荐答案

在windows.h中使用此API函数是什么?
Use this API Function in windows.h:

PlaySound("filename.wav", NULL, SND_ASYNC);



我记得,您可能遇到文件大小超过1mb的问题.自从我进行非托管编码已经过去了几年,所以这可能不再是一个问题...

如果您想播放MP3文件,则google是您的朋友.如果在搜索词组中添加"codeproject",则可能会发现很多文章,它们描述了如何播放所需的声音文件.



As I recall, you may have issues with files larger than 1mb. It''s been a few years since I did unmanaged coding though, so this may no longer be an issue...

If you meant that you want to play MP3 files, google is your friend. If you add "codeproject" to your search phrase, you''ll probably find a lot of article shere that describe how to play the desired sound file.


http://lmgtfy.com/?q=playing+audio+files+with+c%2B%2B [^ ]
希望对您有所帮助.
http://lmgtfy.com/?q=playing+audio+files+with+c%2B%2B[^]
I hope this helps.


如果您只想播放.wav文件,请使用

PlaySound("filename.wav",NULL,SND_ASYNC);但是您需要将winmm.lib添加到您的项目中

否则,使用DriectX Audio可以在codeproject.com中获得足够的教程和源代码
If you want only play .wav files then use

PlaySound("filename.wav", NULL, SND_ASYNC); but you need to add winmm.lib to your project

otherwise use DriectX Audio you have enough tutorial and source code in codeproject.com


这篇关于我们如何在c ++中播放音频文件?检索音频文件的简单代码应该是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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