Skip to content

Feature: Display "Play all" button on toolbar when selecting multiple media files. #11365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,11 @@ public Task InstallFont()
return Task.CompletedTask;
}

public async Task PlayAll()
{
await NavigationHelpers.OpenSelectedItems(associatedInstance);
}

#endregion Command Implementation
}
}
3 changes: 3 additions & 0 deletions src/Files.App/Interacts/BaseLayoutCommandsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private void InitializeCommands()
RotateImageLeftCommand = new AsyncRelayCommand(CommandsModel.RotateImageLeft);
RotateImageRightCommand = new AsyncRelayCommand(CommandsModel.RotateImageRight);
InstallFontCommand = new AsyncRelayCommand(CommandsModel.InstallFont);
PlayAllCommand = new AsyncRelayCommand(CommandsModel.PlayAll);
}

#endregion Command Initialization
Expand Down Expand Up @@ -197,6 +198,8 @@ private void InitializeCommands()

public ICommand InstallFontCommand { get; private set; }

public ICommand PlayAllCommand { get; private set; }

#endregion Commands

#region IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,7 @@ public interface IBaseLayoutCommandImplementationModel : IDisposable
Task RotateImageRight();

Task InstallFont();

Task PlayAll();
}
}
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2955,4 +2955,7 @@
<data name="ShowHiddenItems" xml:space="preserve">
<value>Show hidden items</value>
</data>
<data name="PlayAll" xml:space="preserve">
<value>Play all</value>
</data>
</root>
12 changes: 11 additions & 1 deletion src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,17 @@
<local:ColoredIcon BaseLayerGlyph="&#xF041;" OverlayLayerGlyph="&#xF042;" />
</AppBarButton.Content>
</AppBarButton>
<AppBarButton
x:Name="PlayAllMediaButton"
x:Load="{x:Bind ViewModel.IsMultipleMediaFilesSelected, Mode=OneWay, FallbackValue=False}"
Command="{x:Bind ViewModel.PlayAllCommand, Mode=OneWay}"
Label="{helpers:ResourceString Name=PlayAll}"
LabelPosition="Default"
ToolTipService.ToolTip="{helpers:ResourceString Name=PlayAll}">
<AppBarButton.Icon>
<FontIcon Glyph="&#xE768;" />
</AppBarButton.Icon>
</AppBarButton>
</CommandBar.PrimaryCommands>
</CommandBar>
<CommandBar
Expand Down Expand Up @@ -570,7 +581,6 @@
<Flyout contract8Present:ShouldConstrainToRootBounds="False" Placement="Bottom">
<StackPanel Spacing="12">
<TextBlock FontWeight="Medium" Text="{helpers:ResourceString Name=NavToolbarLayout/Text}" />

<Grid ColumnSpacing="8" RowSpacing="8">
<Grid.RowDefinitions>
<RowDefinition MinHeight="30" />
Expand Down
4 changes: 4 additions & 0 deletions src/Files.App/ViewModels/ToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ private void SearchRegion_Escaped(object? sender, ISearchBox searchBox)

public ICommand? UpdateCommand { get; set; }

public ICommand? PlayAllCommand { get; set; }

public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem pathItem, IShellPage shellPage)
{
var nextPathItemTitle = PathComponents[PathComponents.IndexOf(pathItem) + 1].Title;
Expand Down Expand Up @@ -1288,6 +1290,7 @@ public List<ListedItem> SelectedItems
OnPropertyChanged(nameof(IsImage));
OnPropertyChanged(nameof(IsMultipleImageSelected));
OnPropertyChanged(nameof(IsFont));
OnPropertyChanged(nameof(IsMultipleMediaFilesSelected));
OnPropertyChanged(nameof(HasAdditionalAction));
OnPropertyChanged(nameof(CanEmptyRecycleBin));
OnPropertyChanged(nameof(CanRestoreRecycleBin));
Expand All @@ -1313,6 +1316,7 @@ public List<ListedItem> SelectedItems
public bool IsMultipleImageSelected => SelectedItems is not null && SelectedItems.Count > 1 && SelectedItems.All(x => FileExtensionHelpers.IsImageFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin;
public bool IsInfFile => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsInfFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin;
public bool IsFont => SelectedItems is not null && SelectedItems.Any() && SelectedItems.All(x => FileExtensionHelpers.IsFontFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin;
public bool IsMultipleMediaFilesSelected => SelectedItems is not null && SelectedItems.Count > 1 && SelectedItems.All(x => FileExtensionHelpers.IsMediaFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin;

public string ExtractToText
=> IsSelectionArchivesOnly ? SelectedItems.Count > 1 ? string.Format("ExtractToChildFolder".GetLocalizedResource(), $"*{Path.DirectorySeparatorChar}") : string.Format("ExtractToChildFolder".GetLocalizedResource() + "\\", Path.GetFileNameWithoutExtension(selectedItems.First().Name)) : "ExtractToChildFolder".GetLocalizedResource();
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Views/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ protected void InitToolbarCommands()
ToolbarViewModel.RotateImageRightCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.RotateImageRightCommand.Execute(null), () => SlimContentPage?.CommandsViewModel.RotateImageRightCommand.CanExecute(null) == true);
ToolbarViewModel.InstallFontCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.InstallFontCommand.Execute(null));
ToolbarViewModel.UpdateCommand = new AsyncRelayCommand(async () => await updateSettingsService.DownloadUpdates());
ToolbarViewModel.PlayAllCommand = new RelayCommand(() => SlimContentPage?.CommandsViewModel.PlayAllCommand.Execute(null));
}

protected async Task<BaseLayout> GetContentOrNullAsync()
Expand Down
11 changes: 11 additions & 0 deletions src/Files.Backend/Helpers/FileExtensionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,16 @@ public static bool IsMsiFile(string? filePathToCheck)
/// <remarks>Vhd disk file types are; vhd, vhdx</remarks>
public static bool IsVhdFile(string? fileExtensionToCheck)
=> HasExtension(fileExtensionToCheck, ".vhd", ".vhdx");

/// <summary>
/// Check if the file extension is a media (audio/video) file.
/// </summary>
/// <param name="filePathToCheck">The file extension to check.</param>
/// <returns><c>true</c> if the filePathToCheck is a media file;
/// otherwise <c>false</c>.</returns>
public static bool IsMediaFile(string? filePathToCheck)
=> HasExtension(filePathToCheck, ".mp4", ".m4v", ".mp4v", ".3g2", ".3gp2", ".3gp", ".3gpp",
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".ogg", ".avi", ".wmv", ".mov", ".qt");

}
}