播放mp3文件时如何控制音量? [英] how to contorl the volume when playing mp3 file?

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

问题描述

我使用SndPlaySync播放mp3文件,我的问题是:如何调整音量?waveOutSetVolume似乎只在hwo设置为WAVE_MAPPER时才有效,如果设置为设备句柄,则无法正常工作。我只想更改应用程序的卷,不要影响整个系统。有没有办法做到这一点?谢谢。

I use SndPlaySync to play mp3 file, my question is: how to adjust the volume? waveOutSetVolume seems only work when hwo is set to WAVE_MAPPER, if set to the device handle, it's not working. I want to only change the volume for the application and don't affect the whole system. Is there a way to do that? Thanks.

推荐答案

您可能需要使用Windows Media Player界面。
希望这有助于


You may need to use Windows Media Player interface.
Hope this helps

	HRESULT					lHRes = E_FAIL;
CComPtr<IWMPPlayer> lPlayerPtr;
CComPtr<IWMPSettings> lPlayerSettingsPtr;
LONG lOldVolStatus = 0;
CoInitializeEx(NULL,COINIT_MULTITHREADED);
lHRes = lPlayerPtr.CoCreateInstance(__uuidof(WindowsMediaPlayer));
if(SUCCEEDED(lHRes) && (IWMPPlayer *)NULL != lPlayerPtr)
{
lPlayerPtr->get_settings(&lPlayerSettingsPtr);
if((IWMPSettings *)NULL != lPlayerSettingsPtr)
{
lHRes = lPlayerSettingsPtr->get_volume(&lOldVolStatus);
lHRes = lPlayerSettingsPtr->put_volume(100L);
}
lPlayerPtr.Release();
}
CoUninitialize();





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

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