Skip to content

Commit 530d8cf

Browse files
committed
Add Export Audio Option
1 parent a59caf6 commit 530d8cf

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

dev/Views/QuranTabViewItem.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@
193193
Icon="Volume"
194194
Tag="Play"
195195
Text="قرائت" />
196+
<MenuFlyoutItem x:Name="mnuExportAudio"
197+
Click="menuFlyout_Click"
198+
Icon="Save"
199+
Tag="Export"
200+
Text="استخراج فایل صوتی" />
196201
<MenuFlyoutSeparator />
197202

198203
<MenuFlyoutItem x:Name="mnuAddNote"

dev/Views/QuranTabViewItem.xaml.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ private void menuFlyout_Click(object sender, RoutedEventArgs e)
607607
case "Play":
608608
PlayPlayer();
609609
break;
610+
case "Export":
611+
ExportAudio();
612+
break;
610613
case "CopyTranslation":
611614
dataPackage.SetText(selectedItem.TranslationText);
612615
Clipboard.SetContent(dataPackage);
@@ -619,6 +622,28 @@ private void menuFlyout_Click(object sender, RoutedEventArgs e)
619622
}
620623
}
621624

625+
private async void ExportAudio()
626+
{
627+
var selectedItem = GetListViewSelectedItem();
628+
629+
if (Settings.QuranAudio == null || quranListView.SelectedIndex == -1 || selectedItem == null)
630+
{
631+
return;
632+
}
633+
var extensions = new Dictionary<string, IList<string>>();
634+
extensions.Add("MP3 Audio",new List<string> { ".mp3" });
635+
var storageFile = await ApplicationHelper.PickSaveFileAsync(App.currentWindow, extensions, $"{Chapter.Name}-{selectedItem.Audio}-{Settings.QuranAudio.Name}");
636+
if (storageFile != null)
637+
{
638+
var dirPath = Path.Combine(Settings.AudiosPath, Settings.QuranAudio.DirName);
639+
var fileFullPath = $@"{dirPath}\{selectedItem.Audio}.mp3";
640+
if (File.Exists(fileFullPath))
641+
{
642+
File.Copy(fileFullPath, storageFile.Path, true);
643+
}
644+
}
645+
}
646+
622647
private void AppBarButton_Click(object sender, RoutedEventArgs e)
623648
{
624649
var command = sender as AppBarButton;

0 commit comments

Comments
 (0)