通过wmplib在C#中播放MP3的体积变化 [英] change volume of mp3 playing via wmplib in c#
本文介绍了通过wmplib在C#中播放MP3的体积变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是它在某种程度上可以改变通过wmplib播放MP3文件的音量?更改程序本身将是确定的,以及音量。
Is it somehow possible to change the volume of a mp3-file that is playing via wmplib? Changing the volume of the program itself would be ok as well.
是否有任何解决方案,这样做吗?
Are there any solutions to do this?
推荐答案
我们的想法是送的 WM_APPCOMMAND消息(见这个答案)。
The idea is to send WM_APPCOMMAND message (also see this answer).
有关使用WPF的 WindowInteropHelper 以获得处理
窗口的>:
For WPF use WindowInteropHelper to get the Handle
of the Window
:
class MainWindow : Window
{
...
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
private const int APPCOMMAND_VOLUME_UP = 10 * 65536;
private const int APPCOMMAND_VOLUME_DOWN = 9 * 65536;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
private void VolumeUp()
{
// APPCOMMAND_VOLUME_UP or APPCOMMAND_VOLUME_DOWN
var windowInteropHelper = new WindowInteropHelper(this);
SendMessageW(windowInteropHelper.Handle, (IntPtr)WM_APPCOMMAND, windowInteropHelper.Handle, (IntPtr)APPCOMMAND_VOLUME_UP);
}
}
有关Windows窗体的 Control.Handle物业的:
For Windows Forms use Control.Handle Property:
class MainForm : Form
{
...
private void VolumeUp()
{
SendMessageW(Handle, (IntPtr)WM_APPCOMMAND, Handle, (IntPtr)APPCOMMAND_VOLUME_UP);
}
}
这篇关于通过wmplib在C#中播放MP3的体积变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文