void CreateAudioPlayerInstances() { BgmAudio = new NAudioWrapper(); NarrationAudio = new NAudioWrapper(); SeAudio = new NAudioWrapper(); BgmAudio.IsToShowMessageBoxOfExceptions = false; NarrationAudio.IsToShowMessageBoxOfExceptions = false; SeAudio.IsToShowMessageBoxOfExceptions = false; }
void CheckIfAllSoundFilesExistOrNot() { if (ApplicationCommonSettings.IsDebugging == false) { return; } var hasAllFiles = true; try { var audioPlayer = new NAudioWrapper(); var messages = new NarrationInformationList(); var props = messages.GetType().GetProperties(); foreach (var prop in props) { var msg = (NarrationInformation)prop.GetValue(messages); var filePath = CurrentResources.SoundFilesFolderPath + msg.OggAudioFileName; var hr = audioPlayer.StartAsync(filePath); if (hr == false) { hasAllFiles = false; break; } } audioPlayer.Stop(); } catch (Exception ex) { hasAllFiles = false; MessageBox.Show(ex.Message); } if (hasAllFiles == false) { throw new Exception("Application could not find one or more sound files, or application could not play the sound file on the current sound device."); } }