/// <summary> /// Sounds.Notify2 => "Notify 2" /// </summary> public static string getSoundNameFromSound(SoundsEnum sound) { Dbg.assert(sound != SoundsEnum.None, "Wrong sound: " + sound.ToString()); Dbg.assert(soundsToString.ContainsKey(sound), "Wrong sound: " + sound.ToString()); return(soundsToString[sound]); }
public void Play(SoundsEnum soundEnum) { var soundStream = GetSoundStream(soundEnum); if (soundStream == null) { throw new ArgumentNullException("soundStream"); } var player = new SoundPlayer(soundStream); player.LoadAsync(); player.Play(); player.Dispose(); }
private Stream GetSoundStream(SoundsEnum soundEnum) { string resourceName = soundEnum switch { SoundsEnum.Default => defaultSoundName, SoundsEnum.BeepOne => "Sounds.beep-06.wav", SoundsEnum.CartoonBirds => "Sounds.cartoon-birds-2_daniel-simion.wav", SoundsEnum.CommonFart => "Sounds.Fart-Common-Everyday-Fart_Mike-Koenig.wav", SoundsEnum.DixieHorn => "Sounds.dixie-horn_daniel-simion.wav", SoundsEnum.HornHonk => "Sounds.Horn Honk-SoundBible.com-1162546405", SoundsEnum.SosMorseCode => "Sounds.sos-morse-code_daniel-simion.wav", SoundsEnum.Yes => "Sounds.yes-2.wav", SoundsEnum.Yummy => "Sounds.yummy.wav", _ => defaultSoundName, }; return(ResourceHelper.GetResourceStream(resourceName)); }
static void Main(string[] args) { SoundsEnum animal_miao = SoundsEnum.Miao; SoundsEnum animal_wong = SoundsEnum.Wong; //get description string desc_animal_miao = Utility.EnumExt.GetAttributeFromEnum <DescriptionAttribute>(animal_miao).Description; string desc_animal_wong = Utility.EnumExt.GetAttributeFromEnum <DescriptionAttribute>(animal_wong).Description;; Console.WriteLine(desc_animal_miao); Console.WriteLine(desc_animal_wong); //get color description string customColorDesc_animal_miao = Utility.EnumExt.GetAttributeFromEnum <AnimalColorAttribute>(animal_miao).ToString(); string customColorDesc_animal_wong = Utility.EnumExt.GetAttributeFromEnum <AnimalColorAttribute>(animal_wong).ToString(); Console.WriteLine(customColorDesc_animal_miao); Console.WriteLine(customColorDesc_animal_wong); //get size string customSizeDesc_animal_miao = Utility.EnumExt.GetAttributeFromEnum <AnimalSizeAttribute>(animal_miao).ToString(); string customSizeDesc_animal_wong = Utility.EnumExt.GetAttributeFromEnum <AnimalSizeAttribute>(animal_wong).ToString(); Console.WriteLine(customSizeDesc_animal_miao); Console.WriteLine(customSizeDesc_animal_wong); //get value Console.WriteLine((int)Utility.EnumExt.GetValueFromCustomDescription <AnimalSizeAttribute, SoundsEnum>(customSizeDesc_animal_miao)); Console.WriteLine((int)Utility.EnumExt.GetValueFromCustomDescription <AnimalSizeAttribute, SoundsEnum>(customSizeDesc_animal_wong)); //description Console.WriteLine((int)Utility.EnumExt.GetValueFromCustomDescription <DescriptionAttribute, SoundsEnum>("Cat")); Console.WriteLine("Done"); Console.Read(); }
public static void PlaySound(SoundsEnum sound) { JsInterop.InteropSound.PlaySound(sound); }
public static Task <bool> InitialiseSound(SoundsEnum id, string path, bool loop = false) { return(JSRuntime.Current.InvokeAsync <bool>( "JsFunctions.initialiseSound", new { id, path, loop })); }
public static Task <bool> PlaySound(SoundsEnum id) { return(JSRuntime.Current.InvokeAsync <bool>( "JsFunctions.playSound", id)); }