Skip to content
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

Feature: Added bitrate info for audio files in properties windows #11051

Merged
merged 13 commits into from
Jan 29, 2023
6 changes: 4 additions & 2 deletions src/Files.App/ViewModels/Properties/BaseProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public abstract class BaseProperties
public async void GetOtherProperties(IStorageItemExtraProperties properties)
{
string dateAccessedProperty = "System.DateAccessed";
List<string> propertiesName = new List<string>();
propertiesName.Add(dateAccessedProperty);
List<string> propertiesName = new()
{
dateAccessedProperty
};
IDictionary<string, object> extraProperties = await properties.RetrievePropertiesAsync(propertiesName);

// Cannot get date and owner in MTP devices
Expand Down
10 changes: 9 additions & 1 deletion src/Files.App/ViewModels/Properties/FileProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ public async void GetSystemFileProperties()

list.Find(x => x.ID == "address").Value = await GetAddressFromCoordinatesAsync((double?)list.Find(x => x.Property == "System.GPS.LatitudeDecimal").Value,
(double?)list.Find(x => x.Property == "System.GPS.LongitudeDecimal").Value);
// Find Encoding Bitrate property and convert it to kbps
var encodingBitrate = list.Find(x => x.Property == "System.Audio.EncodingBitrate");
if (encodingBitrate is not null)
{
var sizes = new string[] { "Bps", "KBps", "MBps", "GBps" };
var order = (int)Math.Floor(Math.Log((uint)encodingBitrate.Value, 1024));
var readableSpeed = (uint)encodingBitrate.Value / Math.Pow(1024, order);
encodingBitrate.Value = $"{readableSpeed:0.##} {sizes[order]}";
}

var query = list
.Where(fileProp => !(fileProp.Value is null && fileProp.IsReadOnly))
Expand All @@ -168,7 +177,6 @@ public async void GetSystemFileProperties()
ViewModel.PropertySections = new ObservableCollection<FilePropertySection>(query);
ViewModel.FileProperties = new ObservableCollection<FileProperty>(list.Where(i => i.Value is not null));
}

yaira2 marked this conversation as resolved.
Show resolved Hide resolved
public static async Task<string> GetAddressFromCoordinatesAsync(double? Lat, double? Lon)
{
if (!Lat.HasValue || !Lon.HasValue)
Expand Down