如何使用taglib-sharp? [英] How do I use taglib-sharp?

查看:196
本文介绍了如何使用taglib-sharp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用这个库时遇到了很多麻烦(显然是因为我是新手).我正在使用Microsoft Visual Studio 2015.

I'm having a bunch of troubles with this library (obviously because I'm a newbie). I'm using Microsoft Visual Studio 2015.

首先,我完全不知道如何将这个库添加到我的项目中.我也没有找到任何对Google有帮助的信息.

First of all I have absolutely no idea on how to add this library to my project. I didn't find anything helpful on Google, either.

第二,我发现了两个不同的库-taglib-sharp-mastertaglib-sharp-2.1.0.0-windows.我应该使用哪一个?

And second, I've found two different libraries - taglib-sharp-master and taglib-sharp-2.1.0.0-windows. Which one should I use?

推荐答案

要使taglib-sharp在项目中正常工作,您需要做一些事情.

There are a few things you'll want to do in order to get taglib-sharp working in your project.

首先,您需要坚持特定的项目类型.接下来,您将为该项目安装合适的库版本.接下来,您可以根据需要使用该库.我还将提供一个入门的最小示例,并提供一些示例的链接,您可能会从中找到帮助.

Firstly, you need to stick to a particular project type. Next, you are to install the suitable library version for that project. Next, you can use the library as you wish to. I shall also provide a minimal example to get you started and a link to a bunch of examples which you might find of help.

您的问题中存在一些歧义,因为您同时用.如果您想使用在您的项目,那么最好的选择是使用taglib库. 注意:不是清晰"版本.

There's some ambiguity in your question as you have tagged it with both c++ and c#. If you want to use c++ in your project, then your best bet is to use the taglib library. Note: Not the 'sharp' version.

但是,几乎整个问题及其标题都提到了taglib-sharp.鉴于此,我假设您使用的是用于您的项目.因此,您的项目是.NET C#项目.您可以避免选择项目类型的麻烦.任何项目类型(WinFormsWPFConsole Application都可以正常工作,因为taglib-sharp只是屏幕外的库.

However, almost the entire question and its title speaks of taglib-sharp. Given that, I shall presume that you are using c# for your project. Accordingly, your project is a .NET C# project. You can obviate the quandary over selecting the project type. Any of the project types (WinForms, WPF, Console Application will work just fine as taglib-sharp is just an off-screen library.

而且,仅供参考,taglib-sharp-master和taglib-sharp-2.1.0.0-windows本质上是相同的东西.前者可能是最新版本,因为后者指定了确切的版本2.1.0.0.但同样,2.1.0.0一直是taglib-sharp的最新版本.因此,无论使用哪种,都应该没事.

And also, FYI, both taglib-sharp-master and taglib-sharp-2.1.0.0-windows are essentially the same stuff. The former is probably the latest version since the latter specifies a definite version 2.1.0.0. But again, 2.1.0.0 has long been the latest version of taglib-sharp. So, use either, and you should be fine.

接下来,您必须将TagLib-Sharp安装到您的项目中.有几种方法可以做到这一点:

Next up, you must install TagLib-Sharp to your project. There are a few ways to do so:

  • 通过Nuget安装它
  • 添加对二进制文件的引用

通过Nuget安装:

这可能是在Visual Studio中安装任何库/组件的推荐方法.转到Nuget软件包管理器控制台.在那里,输入:

This is probably the recommended way of installing any library/component in Visual Studio. Head over to the Nuget Package Manager Console. Once there, type in:

Install-Package taglib

Nuget软件包链接: Taglib-Sharp .

Nuget Package link: Taglib-Sharp.

,然后按 ENTER .

有关Nuget Package Manager Console,如何打开和使用它的更多信息,请访问

For more information on the Nuget Package Manager Console, how to open it and use it, visit this link.

您也可以在Nuget软件包管理器(GUI)的帮助下添加它.打开软件包管理器并搜索"taglib-sharp".安装显示在搜索结果中的相应软件包.

You can also add it with the help of the Nuget Package Manager (GUI). Open the Package Manager and search for "taglib-sharp". Install the appropriate package that shows in the search results.

有关Nuget Package Manager,如何打开和使用它的更多信息,请访问此链接.

For more information on the Nuget Package Manager, how to open and use it, visit this link.

下载二进制文件并直接添加对它的引用:

您可以下载taglib-sharp二进制文件的最新版本

You can download the latest version of the taglib-sharp binaries here. The download is a .zip archive. Unzip the file.

在解压缩的文件夹中,转到\Libraries.在这里找到taglib-sharp.dll文件.记下文件的位置.

In the unzipped folder, head over to \Libraries. There, find the taglib-sharp.dll file. Keep a note of where the file is located.

接下来,在Visual Studio中,转到 Project>添加参考.

Next, in Visual Studio, go to Project > Add Reference.

在那里,在左侧面板中,选择浏览.现在,在对话框按钮部分中,单击浏览,然后找到从.zip存档中提取的.dll文件.确保选中它旁边的CheckBox:

There, in the left panel, select Browse. Now in the dialog buttons section, click browse and locate the .dll file you extracted from the .zip archive. Make sure the CheckBox next to it is checked:

单击确定".

现在您都可以使用TagLib-Sharp.

使用该库的最小示例是打开文件并编辑其Title属性并检索Year属性:

The minimal example of using the library would be opening a file and editing its Title property and retrieving the Year property:

var file = TagLib.File.Create("<yourFile.mp3>"); // Change file path accordingly.

file.Tag.Title = "My Own Song";

var year = file.Tag.Year;

// Save Changes:
file.Save();

您还可以在此处找到类似的示例,以开始使用.

You can also find a similar example here to get your started.

更多示例:

  • Set Bitmap as cover art for MP3
  • https://github.com/mono/taglib-sharp/tree/master/examples
  • https://www.codeproject.com/messages/3009089/extracting-id3-albumart-with-taglib-sharp.aspx

如果您还有其他疑问,请随时在下面的评论中提问.而且,如果问题值得一个单独的话题,请正确说出它的意思,然后在Stack Overflow本身上询问.

If you have further queries, feel free to ask in the comments below. And also, if the question deserves a separate thread, word it properly and ask it here on Stack Overflow itself.

希望这个答案会有所帮助. :)

Hope this answer helps. :)

这篇关于如何使用taglib-sharp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆