パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.2.1

audiotagger

MP3 ファイルの ID3 タグを読み書きするためのライブラリです。データを Map オブジェクトまたは Tag オブジェクトとして取得できます。

30日間ダウンロード
183
いいね数
47
Pub ポイント
70

パッケージをインストール

flutter pub add audiotagger

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Audiotaggerは、MP3ファイル内のID3タグの読み取りと書き込みを可能にするFlutter/Dartパッケージです。タイトル、アーティスト、アルバムなどのメタデータにアクセスでき、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

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト