How to read Beats-per-minute tag of mp3 file in windows store apps C#?
Asked Answered
D

1

3

i am trying to read bpm embedded in mp3 file like this one :

bpm tag im trying to read

i have tried using

Windows.Storage.FileProperties.MusicProperties

but it only contains title, singer, etc. it can't read the bpm i showed before.

im looking into https://taglib.github.io/ they seems not having such function too. is there any workaround to this?

Dovetailed answered 8/5, 2016 at 14:47 Comment(1)
MusicProperties.RetrievePropertiesAsync returns a dictionary. Try asking for "TBPM", the ID3 tag for beats per minute.Shapiro
M
2

When you've loaded your music file into a StorageFile, you'll want to place a similar call in your code like this:

var fileProps = await file.Properties.RetrievePropertiesAsync(null);

This will get you a list of all the system properties exposed as a Dictionary<string, object>.

You can then get the BPM value as follows:

if (fileProps.ContainsKey("System.Music.BeatsPerMinute"))
{
    var bpmObj = fileProps["System.Music.BeatsPerMinute"];
    if (bpmObj != null)
    {
        var bpm = bpmObj.ToString();
    }
}

You can find a complete list of available file properties here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd561977(v=vs.85).aspx

Minority answered 8/5, 2016 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.