public static void Play( string waveFile, PlayDevices playDevice = PlayDevices.Both, bool isSync = false, float?volume = null) { if (!volume.HasValue) { volume = Settings.Default.WaveVolume / 100.0f; } switch (playDevice) { case PlayDevices.Both: if (Settings.Default.EnabledSubDevice && !string.IsNullOrEmpty(Settings.Default.SubDeviceID)) { SoundPlayerWrapper.PlayCore( waveFile, volume.Value, Settings.Default.Player, Settings.Default.SubDeviceID, isSync); } SoundPlayerWrapper.PlayCore( waveFile, volume.Value, Settings.Default.Player, Settings.Default.MainDeviceID, isSync); break; case PlayDevices.Main: SoundPlayerWrapper.PlayCore( waveFile, volume.Value, Settings.Default.Player, Settings.Default.MainDeviceID, isSync); break; case PlayDevices.Sub: if (Settings.Default.EnabledSubDevice && !string.IsNullOrEmpty(Settings.Default.SubDeviceID)) { SoundPlayerWrapper.PlayCore( waveFile, volume.Value, Settings.Default.Player, Settings.Default.SubDeviceID, isSync); } break; } }
public static void Play( string waveFile, PlayDevices playDevice = PlayDevices.Both) { var volume = Settings.Default.WaveVolume / 100f; switch (playDevice) { case PlayDevices.Both: if (Settings.Default.EnabledSubDevice) { SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.SubDeviceID); } SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.MainDeviceID); break; case PlayDevices.Main: SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.MainDeviceID); break; case PlayDevices.Sub: if (Settings.Default.EnabledSubDevice) { SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.SubDeviceID); } break; } }
/// <summary> /// 無声音を発声してデバイスを初期化する /// </summary> public static async void Init() { try { var wave = Path.Combine( DirectoryHelper.FindSubDirectory(@"resources\wav"), "mute.wav"); if (!File.Exists(wave)) { return; } BufferedWavePlayer.Instance?.Dispose(); var volume = Settings.Default.WaveVolume / 100f; if (Settings.Default.EnabledSubDevice && !string.IsNullOrEmpty(Settings.Default.SubDeviceID) && Settings.Default.SubDeviceID != PlayDevice.DiscordDeviceID) { await Task.Run(() => SoundPlayerWrapper.PlayCore( wave, volume, Settings.Default.Player, Settings.Default.SubDeviceID, false)); } if (!string.IsNullOrEmpty(Settings.Default.MainDeviceID) && Settings.Default.MainDeviceID != PlayDevice.DiscordDeviceID) { await Task.Run(() => SoundPlayerWrapper.PlayCore( wave, volume, Settings.Default.Player, Settings.Default.MainDeviceID, false)); } } catch (Exception ex) { Logger.Error(ex, "Playback stream initialize faild. Play mute.wav."); } }
public static void Play( string waveFile) { var volume = Settings.Default.WaveVolume / 100f; if (Settings.Default.EnabledSubDevice) { SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.SubDeviceID); } SoundPlayerWrapper.PlayCore( waveFile, volume, Settings.Default.Player, Settings.Default.MainDeviceID); }