Ejemplo n.º 1
0
        void Recite()
        {
            switch ((ClickMode)CurrentState.CtlSetting.ClickMode)
            {
            case ClickMode.Recite:
                var    rec      = BLL.quran_data.getReciter(CurrentState.ReciterId);
                string _Prefix  = rec.mediaurl;
                string SurahKey = CurrentState.Surah.ToString().PadLeft(3, '0');
                string AyahKey  = CurrentState.Ayah.ToString().PadLeft(3, '0');
                string MediaUrl = string.Format(_Prefix, SurahKey, AyahKey);
                if (!CurrentState.isPlaying)
                {
                    CurrentState.isPlaying = true;
                }
                else
                {
                    QuranPlayer.Stop();
                }
                string NamaFile  = string.Format("{0}_{1}.mp3", SurahKey, AyahKey);
                string SubFolder = string.Format("reciter_{0}", rec.idx);
                string UrlMedia  = null;
                if (InternetState)
                {
                    UrlMedia = MediaDownloader.DownloadAndPlay(MediaUrl, SubFolder, NamaFile);
                }
                else
                {
                    UrlMedia = MediaDownloader.CheckOfflineMedia(MediaUrl, SubFolder, NamaFile);
                }
                if (!string.IsNullOrEmpty(UrlMedia))
                {
                    QuranPlayer.Source = new Uri(UrlMedia, UriKind.RelativeOrAbsolute);
                    QuranPlayer.Play();
                }
                break;

            case ClickMode.ReadTranslation:
                //only english
                if (CurrentState.LanguageId == 11)
                {
                    BLL.quran_data.AyahData item = (BLL.quran_data.AyahData)CurrentState.CtlAyah.ListData.SelectedItem;
                    speechSynthesizer.SpeakAsync(item.translation);
                }
                break;
            }
        }