Skip to content

Commit

Permalink
Feature: Added bitrate info for audio files in properties windows (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
hecksmosis authored Jan 29, 2023
1 parent 1dcfce8 commit 688a8a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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
11 changes: 10 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 Down Expand Up @@ -326,4 +335,4 @@ private async void ViewModel_PropertyChanged(object sender, System.ComponentMode
}
}

}
}

0 comments on commit 688a8a2

Please sign in to comment.