public AudioRequest(int reciterId, QuranAyah verse, RepeatInfo repeat, int currentRepeatIteration, AudioDownloadAmount audioDownloadAmount) { if (verse == null) throw new ArgumentNullException("verse"); if (verse == null || verse.Surah < 1 || verse.Surah > 114) throw new ArgumentException("verse"); this.Reciter = AudioUtils.GetReciterById(reciterId); this.AudioDownloadAmount = audioDownloadAmount; this.FromAyah = verse; this.CurrentAyah = verse; this.ToAyah = AudioUtils.GetLastAyahToPlay(verse, audioDownloadAmount); if (repeat != null) { this.RepeatInfo = repeat; } else { this.RepeatInfo = new RepeatInfo(); } this.repeatManager = new RepeatManager(this.RepeatInfo, verse, currentRepeatIteration); }
public QuranAyah(QuranAyah ayah) { Surah = ayah.Surah; Ayah = ayah.Ayah; Text = ayah.Text; Translation = ayah.Translation; }
public QuranAyah Clone() { QuranAyah ayah = new QuranAyah(); ayah.Ayah = this.Ayah; ayah.Surah = this.Surah; ayah.Text = this.Text; ayah.Translation = this.Translation; return(ayah); }
private static QuranAyah GetLastAyahFromAyahCount(QuranAyah firstAyah, int count) { var currentAyah = firstAyah; for (int i = 1; i < count; i++) { currentAyah = QuranUtils.GetNextAyah(currentAyah, false); } return(currentAyah); }
public RepeatManager(RepeatInfo info, QuranAyah firstAyah, int currentIteration) { if (firstAyah == null) { throw new ArgumentNullException("firstAyah"); } RepeatInfo = info ?? new RepeatInfo(); Counter = currentIteration; FirstAyah = firstAyah; GenerateLastAyah(); }
private void GenerateLastAyah() { if (RepeatInfo.RepeatAmount == RepeatAmount.None) { LastAyah = FirstAyah; } else if (RepeatInfo.RepeatAmount == RepeatAmount.OneAyah) { LastAyah = GetLastAyahFromAyahCount(FirstAyah, 1); } else if (RepeatInfo.RepeatAmount == RepeatAmount.ThreeAyah) { LastAyah = GetLastAyahFromAyahCount(FirstAyah, 3); } else if (RepeatInfo.RepeatAmount == RepeatAmount.FiveAyah) { LastAyah = GetLastAyahFromAyahCount(FirstAyah, 5); } else if (RepeatInfo.RepeatAmount == RepeatAmount.TenAyah) { LastAyah = GetLastAyahFromAyahCount(FirstAyah, 10); } else if (RepeatInfo.RepeatAmount == RepeatAmount.Page) { int page = QuranUtils.GetPageFromAyah(FirstAyah); int[] pageBounds = QuranUtils.GetPageBounds(page); FirstAyah = new QuranAyah(pageBounds[0], pageBounds[1]); LastAyah = new QuranAyah(pageBounds[2], pageBounds[3]); } else if (RepeatInfo.RepeatAmount == RepeatAmount.Surah) { int surah = FirstAyah.Surah; int lastAyah = QuranUtils.GetSurahNumberOfAyah(surah); FirstAyah = new QuranAyah(surah, 1); LastAyah = new QuranAyah(surah, lastAyah); } else if (RepeatInfo.RepeatAmount == RepeatAmount.Rub) { var rub = QuranUtils.GetRub3FromAyah(FirstAyah.Surah, FirstAyah.Ayah); FirstAyah = QuranUtils.GetRub3FirstAyah(rub); LastAyah = QuranUtils.GetRub3LastAyah(rub); } else if (RepeatInfo.RepeatAmount == RepeatAmount.Juz) { var juz = QuranUtils.GetJuzFromAyah(FirstAyah.Surah, FirstAyah.Ayah); FirstAyah = QuranUtils.GetJuzFirstAyah(juz); LastAyah = QuranUtils.GetJuzLastAyah(juz); } }
public QuranAudioTrack(int reciterId, QuranAyah verse, ScreenInfo qsi) { if (verse == null) { throw new ArgumentNullException(nameof(verse)); } if (verse == null || verse.Surah < 1 || verse.Surah > 114) { throw new ArgumentException("Invalid Surah number.", nameof(verse)); } this.ReciterId = reciterId; this.Surah = verse.Surah; this.Ayah = verse.Ayah; this.ScreenInfo = qsi; }
public void UpdateQuranAyah(QuranAyah ayah) { Surah = ayah.Surah; Ayah = ayah.Ayah; }
public QuranAyahEventArgs(QuranAyah ayah) { QuranAyah = ayah; }
/// <summary> /// AudioRequest from a formatted string /// </summary> /// <param name="formattedString">[local|streaming]://reciterId?amount=AudioDownloadAmount&currentAyah=1:2&fromAyah=1:2&to=2:1&repeat=xxx;currentRepeat=2</param> public AudioRequest(string formattedString) { if (string.IsNullOrEmpty(formattedString)) throw new ArgumentNullException("formattedString"); try { Uri patternAsUri = new Uri(formattedString); if (patternAsUri.Scheme.Equals("local", StringComparison.OrdinalIgnoreCase)) IsStreaming = false; else if (patternAsUri.Scheme.Equals("streaming", StringComparison.OrdinalIgnoreCase)) IsStreaming = true; else throw new ArgumentException("scheme"); this.Reciter = AudioUtils.GetReciterById(int.Parse(patternAsUri.Host)); var splitQueryString = patternAsUri.Query.Split(new char[] { '?', '&' }); int currentRepeatIteration = 0; foreach (var part in splitQueryString) { var splitPart = part.Split('='); if (splitPart[0].Equals("amount", StringComparison.OrdinalIgnoreCase)) { this.AudioDownloadAmount = (AudioDownloadAmount) Enum.Parse(typeof (AudioDownloadAmount), splitPart[1]); } else if (splitPart[0].Equals("currentAyah", StringComparison.OrdinalIgnoreCase)) { this.CurrentAyah = QuranAyah.FromString(splitPart[1]); } else if (splitPart[0].Equals("fromAyah", StringComparison.OrdinalIgnoreCase)) { this.FromAyah = QuranAyah.FromString(splitPart[1]); } else if (splitPart[0].Equals("toAyah", StringComparison.OrdinalIgnoreCase)) { this.ToAyah = QuranAyah.FromString(splitPart[1]); } else if (splitPart[0].Equals("repeat", StringComparison.OrdinalIgnoreCase)) { this.RepeatInfo = RepeatInfo.FromString(splitPart[1]); } else if (splitPart[0].Equals("currentRepeat", StringComparison.OrdinalIgnoreCase)) { int.TryParse(splitPart[1], out currentRepeatIteration); } } if (this.CurrentAyah == null) this.CurrentAyah = this.FromAyah; this.repeatManager = new RepeatManager(this.RepeatInfo, this.FromAyah, currentRepeatIteration); } catch { throw new ArgumentException("formattedString"); } }