拒绝音乐 [英] Turn down music

查看:68
本文介绍了拒绝音乐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我正在使用.net C#开发3CX电话系统的附加软件。我还需要将我的工作与Skype Webportal连接。 

I'm developing in .net C# an addition software for 3CX phone system. I also need to connect my work with Skype Webportal. 

这里的问题是我需要开发一个动作,当3CX电话系统在计算机中振铃时,它会关闭音乐和其他声音。与Skype for Business类似。

The issue here is that I need to develop an action who turn down music and another sounds when 3CX phone system rings in the computer. Similar as Skype for Business is able to do.

但问题是我不想拒绝音频完整,因为用户需要听到来电者的声音。我唯一想做的就是确定某人是否正在使用网络电台,播客,Spotify等软件,然后将其转为
,将整个音量降低到计算机中。所以声音只会通过3CX,而不是其他软件。 

But the problem is I don't want to turn down complete in the audio because the user needs to hear the caller. The only thing that I want to do is to determine if someone is using software like web radio, podcast, Spotify etc. and turn that down instead of turn the whole volume down in the computer. So the sound will only come through 3CX, not another software. 

是否有基类能够做到这一点,或者有人可以告诉我有关此问题的解决方法吗?

Is there a base class who is able to do that or can anyone advise me about workaround in this issue?

SigurðurHAlfhildars

Sigurður H Alfhildars

推荐答案

嗨Sandri81,

Hi Sandri81,

请使用Windows API尝试以下方法。

Please try the following method by using windows API.

[DllImport("winmm.dll")]
private static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

[DllImport("winmm.dll")]
private static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);

/// <summary>
/// Returns volume from 0 to 10
/// </summary>
/// <returns>Volume from 0 to 10</returns>
public static int GetVolume()
{
  uint CurrVol = 0;
  waveOutGetVolume(IntPtr.Zero, out CurrVol);
  ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
  int volume = CalcVol / (ushort.MaxValue / 10);
  return volume;
}

/// <summary>
/// Sets volume from 0 to 10
/// </summary>
/// <param name="volume">Volume from 0 to 10</param>
public static void SetVolume(int volume)
{
  int NewVolume = ((ushort.MaxValue / 10) * volume);
  uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
  waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);
}

祝你好运,

张龙


这篇关于拒绝音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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