Пример #1
0
        /// <summary>
        /// Plays or pauses the audio, depending on the VLC player's current state.
        /// </summary>
        private void playAudio()
        {
            using (MPAiModel DBModel = MPAiModel.InitializeDBModel())
            {
                Word    wd  = wordsList[currentRecordingIndex];
                Speaker spk = UserManagement.CurrentUser.Speaker;  // Get the speaker from user settings.
                Console.WriteLine(UserManagement.CurrentUser.Speaker.Name + " " + VoiceType.getDisplayNameFromVoiceType(UserManagement.CurrentUser.Voice));
                Recording rd = DBModel.Recording.Local.Where(x => x.WordId == wd.WordId && x.SpeakerId == spk.SpeakerId).SingleOrDefault();

                if (rd != null)
                {
                    ICollection <SingleFile> audios = rd.Audios;
                    if (audios == null || audios.Count == 0)
                    {
                        throw new Exception("No audio recording!");
                    }
                    SingleFile sf = audios.PickNext();
                    filePath = Path.Combine(sf.Address, sf.Name);

                    asyncPlay();
                    playButton.ImageIndex = 3;
                }
                else
                {
                    MPAiMessageBoxFactory.Show(invalidRecordingString);
                }
            }
        }
Пример #2
0
        public static bool IsFileNameCorrect(string fileName)
        {
            string[] parts = fileName.Split('-');

            MPAiModel DBModel = MPAiModel.InitializeDBModel();

            if (parts.Length < 4)
            {
                Console.WriteLine("Not enough Dashes");
                return(false);
            }

            if (!DBModel.IsSpeakerString(parts[0]))
            {
                Console.WriteLine("Speaker invalid");

                return(false);
            }

            if (!DBModel.IsCategoryString(parts[1]))
            {
                return(false);
            }

            if (!DBModel.IsWordString(parts[2]))
            {
                return(false);
            }
            return(true);
        }