mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
修复 CoreAudioAPI
This commit is contained in:
parent
61080ac8e3
commit
74d2ff9e89
@ -477,7 +477,7 @@ namespace VPet_Simulator.Windows
|
|||||||
public float AudioPlayingVolume()
|
public float AudioPlayingVolume()
|
||||||
{
|
{
|
||||||
if (AudioPlayingVolumeOK == null)
|
if (AudioPlayingVolumeOK == null)
|
||||||
{
|
{//第一调用检查是否支持
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float vol = 0;
|
float vol = 0;
|
||||||
@ -499,13 +499,20 @@ namespace VPet_Simulator.Windows
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
using (var enumerator = new MMDeviceEnumerator())
|
try
|
||||||
{
|
{//后续容错可能是偶发性
|
||||||
using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia)))
|
using (var enumerator = new MMDeviceEnumerator())
|
||||||
{
|
{
|
||||||
return meter.GetPeakValue();
|
using (var meter = AudioMeterInformation.FromDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia)))
|
||||||
|
{
|
||||||
|
return meter.GetPeakValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 音乐检测器
|
/// 音乐检测器
|
||||||
|
Loading…
Reference in New Issue
Block a user