如何在Windows应用商店C#中读取mp3文件的每分钟节拍标记? [英] How to read Beats-per-minute tag of mp3 file in windows store apps C#?
问题描述
我正在尝试读取像这样的mp3文件中嵌入的bpm:
i am trying to read bpm embedded in mp3 file like this one :
我尝试使用
Windows.Storage.FileProperties.MusicProperties
,但仅包含标题,歌手等. 它无法读取我之前显示的bpm.
but it only contains title, singer, etc. it can't read the bpm i showed before.
我正在调查 https://taglib.github.io/他们似乎也没有这种功能. 有什么解决方法吗?
im looking into https://taglib.github.io/ they seems not having such function too. is there any workaround to this?
推荐答案
将音乐文件加载到StorageFile后,您需要在代码中进行类似的调用,如下所示:
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);
这将为您提供所有显示为Dictionary<string, object>
的系统属性的列表.
This will get you a list of all the system properties exposed as a Dictionary<string, object>
.
然后您可以按以下方式获取BPM值:
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
这篇关于如何在Windows应用商店C#中读取mp3文件的每分钟节拍标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!