Giter Site home page Giter Site logo

zgramming / audiotagger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samurai016/audiotagger

0.0 1.0 0.0 833 KB

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

Home Page: https://pub.dev/packages/audiotagger

License: MIT License

Java 99.36% Swift 0.03% Objective-C 0.01% Dart 0.56% Ruby 0.03% Shell 0.02%

audiotagger's Introduction

audiotagger

build status pub

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

Library actually works only on Android.

Add dependency

dependencies:
  audiotagger: ^2.0.0

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

Table of contents

Basic usage for any operation

Initialize a new instance of the tagger;

final tagger = new Audiotagger();

Reading operations

Read tags as map

You can get a Map of the ID3 tags.

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:Tag schema.

Read tags as Tag object

You can get a Tag object of the ID3 tags.

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 artwork

To get the artwork of the song, use this method.

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

It return a Uint8List of the bytes of the artwork.

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: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 tags for fields name.

Models

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

Map of tags

<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
};

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.

Copyright and license

This library is developed and maintained by Nicolò Rebaioli
🌐 My website
📫 [email protected]

Released under MIT license

Copyright 2019 Nicolò Rebaioli

audiotagger's People

Contributors

mrdong916 avatar samurai016 avatar silverhairs avatar zgramming avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.