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

你说的曾经没有我的故事 提交于 2019-12-23 17:35:04

问题


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

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?


回答1:


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



来源:https://stackoverflow.com/questions/37101093/how-to-read-beats-per-minute-tag-of-mp3-file-in-windows-store-apps-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!