搜尋套件、儲存庫與 APP 分類

套件詳情v2.2.1

audiotagger

用於讀取和寫入 MP3 檔案中的 ID3 標籤的程式庫。您可以將資料以 Map 物件或 Tag 物件的形式取得。

近 30 天下載
220
喜歡數
47
Pub 分數
70

安裝套件

flutter pub add audiotagger

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Audiotagger 是一個 Flutter/Dart 套件,可讀取和寫入 MP3 檔案中的 ID3 標籤。它提供對標題、藝術家、專輯等元資料的存取,以 Map 物件或結構化 Tag 物件的形式回傳資料。適合音訊管理應用,支援基本標籤操作,無需外部依賴。此套件輕量且專注於核心功能,適合需要在音樂應用中進行簡單 ID3 標籤處理的開發者。

適用情境

  • 編輯 MP3 元數據
  • 讀取歌曲資訊
  • 批次標籤更新
  • 音樂應用開發
  • 從音頻文件中提取元數據

主要特色

  • 讀取和寫入ID3標籤
  • 支援地圖和標籤物件輸出
  • 輕量且簡單的 API
  • 無外部依賴
  • 跨平台相容性

適合對象

  • Flutter 開發人員使用音訊檔案
  • 需要MP3元數據管理的應用
  • 簡單的標籤編輯工具
  • 音頻庫整合
  • 桌面與移動音頻應用

使用建議

  • 僅限ID3標籤(不包括其他格式)
  • 不支援進階標籤類型
  • 需要平台特定的檔案存取
  • 不支援其他音訊格式
  • 需要手動處理檔案操作的錯誤

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

audiotagger

build status pub

This library allow you to read and write ID3 tags to MP3 files.
Based on JAudiotagger library.

Library actually works only on Android.

Add dependency

dependencies:
  audiotagger: ^2.2.1

Audiotagger need access to read and write storage.
To do this you can use Permission Handler library.

Table of contents

Basic usage

Initialize a new instance of the tagger;

final tagger = new Audiotagger();

Reading operations

Read tags as Tag object

Obtain ID3 tags of the file as a Tag object.

void getTags() async {
    final String filePath = "/storage/emulated/0/file.mp3";
    final Tag tag = await tagger.readTags(
        path: filePath
    );
}

This method does not read the artwork of the song. To do this, use the readArtwork method.

The Tag object has this schema: Tag schema.

Read tags as map

Obtain ID3 tags of the file as a Map.

void getTagsAsMap() async {
    final String filePath = "/storage/emulated/0/file.mp3";
    final Map map = await tagger.readTagsAsMap(
        path: filePath
    );
}

This method does not read the artwork of the song. To do this, use the readArtwork method.

The map has this schema: Map of Tag schema.

Read artwork

Obtain the artwork of the song as a Uint8List.

void getArtwork() async {
    final String filePath = "/storage/emulated/0/file.mp3";
    final Uint8List bytes = await tagger.readArtwork(
        path: filePath
    );
}
Read audio file as AudioFile object

Obtain informations about the MP3 file as a Tag object.

void getAudioFile() async {
    final String filePath = "/storage/emulated/0/file.mp3";
    final AudioFile audioFile = await tagger.readAudioFile(
        path: filePath
    );
}

The AudioFile object has this schema: AudioFile schema.

Read audio file as map

Obtain informations about the MP3 file as a Map.

void getAudioFileAsMap() async {
    final String filePath = "/storage/emulated/0/file.mp3";
    final Map map = await tagger.readAudioFileAsMap(
        path: filePath
    );
}

The map has this schema: Map of AudioFile schema.

Writing operations

Write tags from map

You can write the ID3 tags from a Map.
To reset a field, pass an empty string ("").
If the value is null, the field will be ignored and it will not be written.

void setTagsFromMap() async {
    final path = "storage/emulated/0/Music/test.mp3";
    final tags = <String, String>{
        "title": "Title of the song",
        "artist": "A fake artist",
        "album": "",    //This field will be reset
        "genre": null,  //This field will not be written
    };

    final result = await tagger.writeTagsFromMap(
        path: path,
        tags: tags
    );
}

The map has this schema: Map of Tag schema.

Write tags from Tag object

You can write the ID3 tags from a Tag object.
To reset a field, pass an empty string ("").
If the value is null, the field will be ignored and it will not be written.

void setTags() async {
    final path = "storage/emulated/0/Music/test.mp3";
    final tag = Tag(
        title: "Title of the song",
        artist: "A fake artist",
        album: "",    //This field will be reset
        genre: null,  //This field will not be written
    );

    final result = await tagger.writeTags(
        path: path,
        tag: tag,
    );
}

The Tag object has this schema: Tag schema.

Write single tag field

You can write a single tag field by specifying the field name.
To reset the field, pass an empty string ("").
If the value is null, the field will be ignored and it will not be written. \

void setTags() async {
    final path = "storage/emulated/0/Music/test.mp3";

    final result = await tagger.writeTag(
        path: path,
        tagField: "title",
        value: "Title of the song"
    );
}

Refer to Map of Tag schema for fields name.

Models

These are the schemes of the Map and classes asked and returned by Audiotagger.

Tag class
String? title;
String? artist;
String? genre;
String? trackNumber;
String? trackTotal;
String? discNumber;
String? discTotal;
String? lyrics;
String? comment;
String? album;
String? albumArtist;
String? year;
String? artwork; // It represents the file path of the song artwork.
Map of Tag
<String, String>{
    "title": value,
    "artist": value,
    "genre": value,
    "trackNumber": value,
    "trackTotal": value,
    "discNumber": value,
    "discTotal": value,
    "lyrics": value,
    "comment": value,
    "album": value,
    "albumArtist": value,
    "year": value,
    "artwork": value, // Null if obtained from readTags or readTagsAsMap
};
AudioFile class
int? length;
int? bitRate;
String? channels;
String? encodingType;
String? format;
int? sampleRate;
bool? isVariableBitRate;
Map of AudioFile
<String, dynamic?>{
    "length": length,
    "bitRate": bitRate,
    "channels": channels,
    "encodingType": encodingType,
    "format": format,
    "sampleRate": sampleRate,
    "isVariableBitRate": isVariableBitRate,
};

Copyright and license

This library is developed and maintained by Nicolò Rebaioli
:globe_with_meridians: My website
:mailbox: [niko.reba@gmail.com](mailto:niko.reba@gmail.com)

Released under MIT license

Copyright 2021 Nicolò Rebaioli

所屬分類

原始碼儲存庫

使用此套件的專案