Skip to content

Commit

Permalink
Add Export Audio Option
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Nov 9, 2023
1 parent a59caf6 commit 530d8cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dev/Views/QuranTabViewItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
Icon="Volume"
Tag="Play"
Text="قرائت" />
<MenuFlyoutItem x:Name="mnuExportAudio"
Click="menuFlyout_Click"
Icon="Save"
Tag="Export"
Text="استخراج فایل صوتی" />
<MenuFlyoutSeparator />

<MenuFlyoutItem x:Name="mnuAddNote"
Expand Down
25 changes: 25 additions & 0 deletions dev/Views/QuranTabViewItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ private void menuFlyout_Click(object sender, RoutedEventArgs e)
case "Play":
PlayPlayer();
break;
case "Export":
ExportAudio();
break;
case "CopyTranslation":
dataPackage.SetText(selectedItem.TranslationText);
Clipboard.SetContent(dataPackage);
Expand All @@ -619,6 +622,28 @@ private void menuFlyout_Click(object sender, RoutedEventArgs e)
}
}

private async void ExportAudio()
{
var selectedItem = GetListViewSelectedItem();

if (Settings.QuranAudio == null || quranListView.SelectedIndex == -1 || selectedItem == null)
{
return;
}
var extensions = new Dictionary<string, IList<string>>();
extensions.Add("MP3 Audio",new List<string> { ".mp3" });
var storageFile = await ApplicationHelper.PickSaveFileAsync(App.currentWindow, extensions, $"{Chapter.Name}-{selectedItem.Audio}-{Settings.QuranAudio.Name}");
if (storageFile != null)
{
var dirPath = Path.Combine(Settings.AudiosPath, Settings.QuranAudio.DirName);
var fileFullPath = $@"{dirPath}\{selectedItem.Audio}.mp3";
if (File.Exists(fileFullPath))
{
File.Copy(fileFullPath, storageFile.Path, true);
}
}
}

private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
var command = sender as AppBarButton;
Expand Down

0 comments on commit 530d8cf

Please sign in to comment.