private void Save() { AudioSura.AudioSlices = new AudioSlice[listBox.Items.Count]; TimeSpan finish; for (int i = 0; i < listBox.Items.Count; i++) { TempAudioSlice tas = listBox.Items[i] as TempAudioSlice; if (i < listBox.Items.Count - 1) { finish = (listBox.Items[i + 1] as TempAudioSlice).Position; } else { finish = mePlayer.NaturalDuration.TimeSpan; } AudioSura.AudioSlices[i] = new AudioSlice() { SliceID = tas.SliceID, Start = tas.Position, Finish = finish }; } using (var file = File.Create(AudioPath)) { using (CryptoStream cs = new CryptoStream(file, Crypto.AES.CreateEncryptor(), CryptoStreamMode.Write)) { Serializer.Serialize <Model.AudioQuran>(cs, audioQuran); } } QuranConfig.Current.Meta.Qaris[qari.ID].Availability[suraMeta.SuraNo - 1] = true; Engine.SaveMeta(QuranConfig.Current.Meta); }
private void verseByVerseLoad_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog(); if (dlg.ShowDialog() == true) { string audioPath = dlg.FileName.Replace("\\Audio Timing", ""); audioPath = System.IO.Path.ChangeExtension(audioPath, "mp3"); mePlayer.Source = new Uri(audioPath); var lines = System.IO.File.ReadAllLines(dlg.FileName); int lineNo = 0; for (int i = 0; i < listBox.Items.Count - 1; i++) { TempAudioSlice tas = listBox.Items[i + 1] as TempAudioSlice; if (tas.SliceNo == 1) { tas.Position = new TimeSpan(Convert.ToInt64(lines[lineNo++]) * 10000); } } Play(); } }
private void LoadSlices(SuraMeta suraMeta) { Model.Sura sura = null; using (var file = File.OpenRead(QuranConfig.Current.FilePath)) { using (CryptoStream cs = new CryptoStream(file, Crypto.AES.CreateDecryptor(), CryptoStreamMode.Read)) { sura = Serializer.Deserialize <Quran.Model.Quran>(cs).Suras[suraMeta.SuraNo - 1]; } } int index = 0; //if (suraMeta.SuraNo != 9 && suraMeta.SuraNo != 1) //{ // slices.Insert(index, new TempAudioSlice() { SliceID = suraMeta.SuraNo * 1000000 , Slice = "بِسۡمِ ٱللَّهِ ٱلرَّحۡمَٰنِ ٱلرَّحِيمِ", SliceIndex = index, Position = new TimeSpan(0) }); // ++index; //} foreach (var aya in sura.Ayas) { foreach (Slice slice in aya.Slices) { string text = slice.Text; TempAudioSlice tempAudioSlice = new TempAudioSlice(); tempAudioSlice.SliceID = slice.SliceID; tempAudioSlice.Slice = text; tempAudioSlice.SliceIndex = index; tempAudioSlice.Position = new TimeSpan(0); tempAudioSlice.HasMultiSlices = (aya.Slices.Length > 1); slices.Add(tempAudioSlice); ++index; } } listBox.ItemsSource = Slices; listBox.SelectedIndex = 0; }