public void Load() { try { if (Image == null) { Image = Image.FromFile(ImagePath); } } catch { Image = null; Debug.WriteLine("Unable to load image for " + Name); } try { if (Audio == null) { string[] SupportedAudioFileType = { ".mp3", ".wav" }; foreach (string ext in SupportedAudioFileType) { if (File.Exists(AudioPath + ext)) { Audio = new NAudioPlayerWrapper(AudioPath + ext); Audio.Load(); return; } } Debug.WriteLine("Audio not exists " + Name); } } catch { Audio = null; Debug.WriteLine("Unable to load audio for " + Name); } }
private void Initialize() { Cards = new FlashCardCollection(); OptionDialog = new SelectionDialog(); UseThread = true; SpellingModeHintInterval = 5000; SpellingModeHintIntervalInitial = 1000; CodeProfiler.Start("Load Characters"); Debug.WriteLine("Loading characters audio..."); string soundPath = RootPath + "\\System\\Characters\\"; Characters = new Dictionary <char, NAudioPlayerWrapper>(); for (char tChar = 'A'; tChar <= 'Z'; tChar++) { try { string audioFile = soundPath + "Char_" + tChar.ToString() + ".mp3"; if (File.Exists(audioFile)) { NAudioPlayerWrapper charPlayer = new NAudioPlayerWrapper(audioFile); charPlayer.Load(); Characters.Add(tChar, charPlayer); } Debug.WriteLine("WARNING: Audio file for char " + tChar + "not found!"); } catch { Debug.WriteLine("WARNING: Unable to load audio file for char " + tChar); } } CodeProfiler.Stop("Load Characters"); }
private NAudioPlayerWrapper TryLoadSound(string fileName) { try { NAudioPlayerWrapper audio = new NAudioPlayerWrapper(".\\System\\" + fileName); audio.Load(); return(audio); } catch { return(null); } }