metadata_god 0.1.0 copy "metadata_god: ^0.1.0" to clipboard
metadata_god: ^0.1.0 copied to clipboard

outdated

Plugin for retrieving and writing audio tags/metadata from audio files

Metadata God #

A flutter plugin for retrieving and writing audio tags/metadata from audio files. It supports almost all kind of audio files

Supported Audio Formats #

File Format Metadata Format
mp3 id3v2.4
m4a, mp4 MPEG-4 audio metadata
flac Vorbis comment

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  metadata_god: ^0.1.0

Or, run in terminal:

$ flutter pub add metadata_god

Configuration #

Android #

For using metadata_god in Android it needs READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions

So, add following green highlighted lines to android/app/src/main/AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.example">

+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

  
  <application 
    android:label="Example"
    android:name="${applicationName}"
    android:icon="@mipmap/ic_launcher"
    android:usesCleartextTraffic="true"
+   android:requestLegacyExternalStorage="true"
  >
// .... rest of the file

Finally, use packages like permission_handler to request storage permissions from user if not granted already

// before calling any method of MetadataGod in android
// check if storage permission is granted or not
// if not, request for permission
  initState(){
    final hasStorageAccess = Platform.isAndroid ? await Permission.storage.isGranted : true
    if(!hasStorageAccess){
      await Permission.storage.request();
      if(!await Permission.storage.isGranted){
        return;
      }
    }
    // ... call all the metadata_god methods from here
  }

Following configuration would work with file path that are allowed explicitly by android. If you want entire storage access you'll need MANAGE_EXTERNAL_STORAGE permission and request the user to enable access to entire storage in app info settings.

Other platforms #

Linux, Windows and MacOS doesn't need any extra configuration and good to go after installation

Usage #

import 'package:metadata_god/metadata_god.dart';
import 'package:mime/mime.dart';

// Get metadata from file
Metadata metadata = await MetadataGod.getMetadata("/path/to/audio-file");

// Set metadata to file
await MetadataGod.writeMetadata(
  "/path/to/audio-file",
  Metadata(
    title: "Leave the Door Open",
    artist: "Bruno Mars, Anderson .Paak, Silk Sonic",
    album: "An Evening with Silk Sonic",
    genre: "R&B, Soul",
    year: 2021,
    albumArtist: "Bruno Mars, Anderson .Paak",
    trackNumber: 1,
    trackTotal: 12,
    discNumber: 1,
    discTotal: 5,
    durationMs: 248000,
    fileSize: file.lengthSync(),
    picture: Picture(
      data: File("/path/to/cover-image").readAsBytesSync(),
      mimeType: lookupMimeType("/path/to/cover-image"),
    ),
  ),
);

Contributing #

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License #

MIT

Author #

Kingkor Roy Tirtho

27
likes
0
pub points
90%
popularity

Publisher

verified publisherkrtirtho.dev

Plugin for retrieving and writing audio tags/metadata from audio files

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

ffi, flutter, flutter_rust_bridge, plugin_platform_interface

More

Packages that depend on metadata_god