mp3editor 0.0.1 copy "mp3editor: ^0.0.1" to clipboard
mp3editor: ^0.0.1 copied to clipboard

outdated

Plugin for editing mp3 tags

mp3editor #

A Flutter plugin for reading and writing mp3 file tags.

Usage #

First get the filepath from an mp3 file saved on the device. If you have the mp3 file in your flutter assets, you can save it to the device like so:

writeToFile(Future<void> writeToFile(ByteData data, String path) {
  final buffer = data.buffer;
  return new File(path).writeAsBytes(
    buffer.asUint8List(data.offsetInBytes, data.lengthInBytes)
  );
}

Future<void> getFilepath() async {
    String dir = (await getApplicationDocumentsDirectory()).path;
    if (!(File(dir + "/track.mp3").existsSync())) {
      var bytes = await rootBundle.load("mp3samples/track.mp3");
      await writeToFile(bytes, dir + "/track.mp3");
    }
    filepath = dir + "/track.mp3";
}

To read specific tags:

Future<String> title = Mp3editor.getTitle(filepath);
Future<String> artist = Mp3editor.getArtist(filepath);
Future<String> trackNumber = Mp3editor.getTrackNumber(filepath);
Future<String> album = Mp3editor.getAlbum(filepath);
Future<String> year = Mp3editor.getYear(filepath);
Future<String> genre = Mp3editor.getGenre(filepath);
Future<String> comment = Mp3editor.getComment(filepath);

Method will return null if tag is empty.

To write tags, you will need overwrite all the existing tags in the file:

Mp3editor.setID3v1Tag(
  filepath: filepath,
  title: 'Title',
  artist: 'Artist',
  album: 'Album',
  year: '2019',
  genre: 52,
  comment: 'Comment'
);

Be careful with the 'genre' parameter, you need to specify an ID3v1 genre number, see this for more.

Checkout the example for further details.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

1
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Plugin for editing mp3 tags

Homepage

License

GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on mp3editor