编辑本地媒体文件元数据信息

Edit local media file metadata information

我设法从远程源下载了音频文件,我想更改它的元数据,例如作者、标题、专辑。

我将它保存在本地以便于访问和编辑,但我找不到任何东西来编辑它的元数据。

我试过: Android.Media.MediaMetadataEditor 但错误非常简单:

This class is obsoleted in this android platform

我正在为 android Pie 使用最新的 SDK (28) 和 API。并且还声明 on android developer documentation

This class was deprecated in API level 21. Use MediaMetadata instead together with MediaSession.

我真的搜索了一些示例,但没有找到任何有用的东西,大多数情况都是播放列表。

我不明白 MediaSession 如何以任何方式替换 MediaMetadataEditor,因为 MediaSession

Allows interaction with media controllers, volume keys, media buttons, and transport controls.

A MediaSession should be created when an app wants to publish media playback information or handle media keys

相反 MediaMetadata 似乎是我需要的,因为

Contains metadata about an item, such as the title, artist, etc. And its Builder class is promising.

我确信只要阅读那些页面我就应该能够理解如何去做,但是经过数小时的尝试,我似乎没有足够的经验从该文档中学习。

有例子可以理解吗?

谢谢

我在 android 图书馆外找到了解决方案。

taglib-sharp 似乎在 android 项目上工作,它可以通过 nuget 包安装,名称是 TagLibSharp

真的好用:

TagLib.File my_file = TagLib.File.Create(path_to_my_file);
string[] performers = new string[1]{"My Performer"}

my_file.Tag.Title = "The real title";
my_file.Tag.Performers = performers;

my_file.Save();

简单。