This repository has been archived by the owner on Jul 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20d52a7
commit 90b98e1
Showing
12 changed files
with
249 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace Huoyaoyuan.AdmiralRoom.Models | ||
{ | ||
class Status : NotifyBase | ||
{ | ||
public static Status Current { get; } = new Status(); | ||
|
||
private Volume _volume; | ||
public Volume Volume | ||
{ | ||
get | ||
{ | ||
if (_volume == null) _volume = Volume.GetInstance(); | ||
return _volume; | ||
} | ||
} | ||
|
||
#region StatusText | ||
private string _statustext = ""; | ||
public string StatusText | ||
{ | ||
get { return _statustext; } | ||
set | ||
{ | ||
if(_statustext != value) | ||
{ | ||
_statustext = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
#endregion | ||
|
||
#region IsGameLoaded | ||
private bool _isgameloaded; | ||
public bool IsGameLoaded | ||
{ | ||
get { return _isgameloaded; } | ||
set | ||
{ | ||
if (_isgameloaded != value) | ||
{ | ||
_isgameloaded = value; | ||
OnAllPropertyChanged(); | ||
} | ||
} | ||
} | ||
#endregion | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using CoreAudioApi; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Huoyaoyuan.AdmiralRoom.Models | ||
{ | ||
class Volume : NotifyBase | ||
{ | ||
private SimpleAudioVolume simpleaudiovolume; | ||
|
||
#region IsMute | ||
private bool _ismute; | ||
public bool IsMute | ||
{ | ||
get { return _ismute; } | ||
set | ||
{ | ||
if (_ismute != value) | ||
{ | ||
_ismute = value; | ||
simpleaudiovolume.Mute = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
#endregion | ||
|
||
#region Value | ||
private float _value; | ||
/// <summary> | ||
/// 音量。范围为0~1 | ||
/// </summary> | ||
public float Value | ||
{ | ||
get { return _value; } | ||
set | ||
{ | ||
if (_value != value) | ||
{ | ||
_value = value; | ||
simpleaudiovolume.MasterVolume = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
#endregion | ||
|
||
private Volume() { } | ||
public static Volume GetInstance() | ||
{ | ||
var volume = new Volume(); | ||
var processid = Process.GetCurrentProcess().Id; | ||
var device = (new MMDeviceEnumerator()).GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia); | ||
for (int i = 0; i < device.AudioSessionManager.Sessions.Count; i++) | ||
{ | ||
var session = device.AudioSessionManager.Sessions[i]; | ||
if (session.ProcessID == processid) | ||
{ | ||
volume.simpleaudiovolume = session.SimpleAudioVolume; | ||
volume.IsMute = volume.simpleaudiovolume.Mute; | ||
volume.Value = volume.simpleaudiovolume.MasterVolume; | ||
} | ||
} | ||
if (volume.simpleaudiovolume == null) return null; | ||
return volume; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.