Skip to content

Commit 688a8a2

Browse files
authored
Feature: Added bitrate info for audio files in properties windows (#11051)
1 parent 1dcfce8 commit 688a8a2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Files.App/ViewModels/Properties/BaseProperties.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ public abstract class BaseProperties
3333
public async void GetOtherProperties(IStorageItemExtraProperties properties)
3434
{
3535
string dateAccessedProperty = "System.DateAccessed";
36-
List<string> propertiesName = new List<string>();
37-
propertiesName.Add(dateAccessedProperty);
36+
List<string> propertiesName = new()
37+
{
38+
dateAccessedProperty
39+
};
3840
IDictionary<string, object> extraProperties = await properties.RetrievePropertiesAsync(propertiesName);
3941

4042
// Cannot get date and owner in MTP devices

src/Files.App/ViewModels/Properties/FileProperties.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ public async void GetSystemFileProperties()
158158

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

162171
var query = list
163172
.Where(fileProp => !(fileProp.Value is null && fileProp.IsReadOnly))
@@ -326,4 +335,4 @@ private async void ViewModel_PropertyChanged(object sender, System.ComponentMode
326335
}
327336
}
328337

329-
}
338+
}

0 commit comments

Comments
 (0)