/// <summary> /// Writes an individual event to the data file /// </summary> public void WriteEvent(MMazeEvent e, string sound_file_name = "") { if (_writer != null) { string event_name = MMazeEventNamesConverter.ConvertToDescription(e.EventType); //Change the event name to the sound file name if this is a sound event if (e.EventType == MMazeEventNames.SoundCue) { event_name = sound_file_name; } string output_text = e.EventTime.ToFileTime().ToString() + "\t" + event_name; _writer.WriteLine(output_text); } }
private void PlaySound() { //Reset the flag to play a sound _playSoundFlag = false; lock (sound_list_lock) { SoundList_TimeSinceSessionStart.Add(Convert.ToInt32(timer.Elapsed.TotalSeconds)); } //Play the sound if (CurrentStage.SoundFiles.Count > 0) { //Get the sound file name var sound_file_name = CurrentStage.SoundFiles[0].Item1; var sound_file_path = MMazeConfiguration.GetInstance().SoundPath_Base; var fully_qualified_path = sound_file_path + sound_file_name; //Write an event to the file indicating we are playing a sound at this time MMazeEvent sound_event = new MMazeEvent(DateTime.Now, MMazeEventNames.SoundCue); _session_file_writer.WriteEvent(sound_event, sound_file_name); FileInfo finfo = new FileInfo(fully_qualified_path); if (finfo.Exists) { //Set the variable in the model indicating that the sound is playing IsSoundPlaying = true; //Load the sound into memory //SoundPlayer k = new SoundPlayer(finfo.FullName); //Play the sound (asynchronously) //k.Play(); //Play the sound PlaySoundAsync(finfo.FullName); } } //Restart timer 1 StartTimer1(); }