【问题标题】:How to read Beats-per-minute tag of mp3 file in windows store apps C#?如何在 Windows 商店应用程序 C# 中读取 mp3 文件的 Beats-per-minute 标签?
【发布时间】:2023-03-17 11:54:02
【问题描述】:

我正在尝试像这样读取嵌入在 mp3 文件中的 bpm:

我尝试过使用

Windows.Storage.FileProperties.MusicProperties

但它只包含标题、歌手等。 它无法读取我之前显示的 bpm。

我正在调查https://taglib.github.io/ 他们似乎也没有这样的功能。 有什么解决方法吗?

【问题讨论】:

  • MusicProperties.RetrievePropertiesAsync 返回一个字典。尝试询问“TBPM”,即每分钟心跳的 ID3 标签。

标签: c# windows-store-apps mp3 id3-tag


【解决方案1】:

当您将音乐文件加载到 StorageFile 中后,您需要在代码中进行类似的调用,如下所示:

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

这将为您提供以Dictionary<string, object> 公开的所有系统属性的列表。

然后您可以按如下方式获取 BPM 值:

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

您可以在此处找到可用文件属性的完整列表:https://msdn.microsoft.com/en-us/library/windows/desktop/dd561977(v=vs.85).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-11
    • 1970-01-01
    相关资源
    最近更新 更多