A Flutter plugin to read 🔖 metadata of 🎵 media files. Supports Windows, Linux & Android.

Overview

flutter_media_metadata

A Flutter plugin to read metadata of media files.

A part of Harmonoid open source project 💜


Install

Add in your pubspec.yaml.

dependencies:
  ...
  flutter_media_metadata: ^0.1.2

Issues are maintained here.

Example

var metadata = await MetadataRetriever.fromFile(File('C:/Users/Alex/Music/SampleMusic.OGG'))

String? trackName = metadata.trackName;
List<String>? trackArtistNames = metadata.trackArtistNames;
String? albumName = metadata.albumName;
String? albumArtistName = metadata.albumArtistName;
int? trackNumber = metadata.trackNumber;
int? albumLength = metadata.albumLength;
int? year = metadata.year;
String? genre = metadata.genre;
String? authorName = metadata.authorName;
String? writerName = metadata.writerName;
int? discNumber = metadata.discNumber;
String? mimeType = metadata.mimeType;
int? trackDuration = metadata.trackDuration;
int? bitrate = metadata.bitrate;
Uint8List? albumArt = metadata.albumArt;

Platforms

Platform Status Author/Maintainer
Windows Working Hitesh Kumar Saini
Linux Working Hitesh Kumar Saini
Android Working Hitesh Kumar Saini
iOS Working @DiscombobulatedDrag
MacOS Not Working N/A

License

This library & work under this repository is MIT licensed.

Copyright (C) 2021 Hitesh Kumar Saini [email protected]

Comments
  • Provide pure Dart support in case of a platform is not supported

    Provide pure Dart support in case of a platform is not supported

    Imagine we try to run this project in the web, iOS or macOS. Likely, a Not Supported error will be thrown.

    With a pure dart implementation of this, we could make this work for every platform. I am not saying to remove the native implementation, since they're faster than Dart, I'm saying to support all the platforms, regardless of how fast it is.

    This could be done through ffi and add a pure dart implementation for the web, or just don't provide web support (I don't see how web apps would be manipulating media files, and if they do, that'd be uneffectively).

    great project btw :)

    question 
    opened by bdlukaa 4
  • Meta data scrambled when requesting meta data from a sequence of files asynchronously

    Meta data scrambled when requesting meta data from a sequence of files asynchronously

    When requesting meta data for a list of files the meta data gets mixed up. The MetaDataRetriever quite often returns the same meta data twice or thrice or scrambles together a completly new set of meta data.

    A quick but dirty fix is delaying each meta data request by a 100ms.

    bug 
    opened by ton-An 4
  • Error in setDataSource

    Error in setDataSource

    When I use the following code, the continuation of the code stops without any error await MetadataRetriever.fromFile(File(songInfo.filePath));

    I tried to find the library problem to fix it image I noticed that an error occurs when using setFilePath (retriever.setFilePath(filePath);) image This function gives java.lang.IllegalArgumentException error without any message

    question 
    opened by MrMontazer 3
  • Add iOS support

    Add iOS support

    I don't own a mac or an iOS device.

    There are some people out there, who wanna use this plugin on iOS devices.

    Any Objective-C or Swift geek is free to add iOS support to this plugin.

    Thanks. My appreciation, if you decide to help out.

    enhancement help wanted 
    opened by alexmercerind 3
  • Use CompletableFuture from package for lower API level support

    Use CompletableFuture from package for lower API level support

    According to CompletableFuture CompletableFuture is Added in [API level 24]

    If app imported this package build with minSdkVersion less than [API level 24], app would run into this error

    Fatal Exception: java.lang.NoClassDefFoundError
    Failed resolution of: Ljava/util/concurrent/CompletableFuture;
    
    Caused by java.lang.ClassNotFoundException
    Didn't find class "java.util.concurrent.CompletableFuture" 
    

    So this PR is needed to support lower API level, which referred from the flutter official plugin https://github.com/flutter/plugins/commit/0bd38d2a2cf367e2418334bd32d362c1880704be

    opened by zhileichen 2
  • Compilation fails on Linux

    Compilation fails on Linux

    When attempting to run a flutter app that uses flutter_media_metadata on Linux, the compilation of the application fails.

    flutter run -d linux
    Launching lib/main.dart on Linux in debug mode...
    [/home/abitofevrything/Programming/music_player/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/utils.hpp:108:12](): warning: variable 'last_index' set but not used [-Wunused-but-set-variable]
    [/home/abitofevrything/Programming/music_player/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/metadata_retriever.cpp:56:16](): warning: variable 'size' set but not used [-Wunused-but-set-variable]
    [/home/abitofevrything/Programming/music_player/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/metadata_retriever.cpp:57:16](): warning: variable 'header' set but not used [-Wunused-but-set-variable]
    clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
    Exception: Build process failed
    
    flutter doctor -v
    [✓] Flutter (Channel stable, 2.10.2, on Artix Linux 5.16.10-artix1-1, locale en_GB.UTF-8)
        • Flutter version 2.10.2 at /opt/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 097d3313d8 (12 days ago), 2022-02-18 19:33:08 -0600
        • Engine revision a83ed0e5e3
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [✗] Android toolchain - develop for Android devices
        ✗ ANDROID_HOME = /opt/android-sdk
          but Android SDK not found at this location.
    
    [✓] Chrome - develop for the web
        • CHROME_EXECUTABLE = chromium
    
    [✓] Linux toolchain - develop for Linux desktop
        • clang version 13.0.1
        • cmake version 3.22.2
        • ninja version 1.10.2
        • pkg-config version 1.8.0
    
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
    
    [✓] Connected device (2 available)
        • Linux (desktop) • linux  • linux-x64      • Artix Linux 5.16.10-artix1-1
        • Chrome (web)    • chrome • web-javascript • Chromium 98.0.4758.102 Arch Linux
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 2 categories.
    
    opened by abitofevrything 1
  • Fatal Exception: java.lang.NoClassDefFoundError Failed resolution of: Ljava/util/concurrent/CompletableFuture;

    Fatal Exception: java.lang.NoClassDefFoundError Failed resolution of: Ljava/util/concurrent/CompletableFuture;

    Fatal Exception: java.lang.NoClassDefFoundError Failed resolution of: Ljava/util/concurrent/CompletableFuture;

    java.lang.ClassLoader.loadClass (ClassLoader.java:469) com.alexmercerind.flutter_media_metadata.a.onMethodCall (FlutterMediaMetadataPlugin.java:2) io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage (MethodChannel.java:2) io.flutter.embedding.engine.dart.DartMessenger.invokeHandler (DartMessenger.java:2) io.flutter.embedding.engine.dart.DartMessenger.a (DartMessenger.java:2) io.flutter.embedding.engine.dart.DartMessenger.b (DartMessenger.java) io.flutter.embedding.engine.dart.c.run (lambda) android.os.Handler.handleCallback (Handler.java:739)

    Not support CompletableFuture while android's minSdk is less than 24

    It is similar to an flutter/plugin issue.

    The solution can be refer to https://github.com/flutter/plugins/pull/2770/commits/0bd38d2a2cf367e2418334bd32d362c1880704be

    opened by jinchengwu-ola 1
  • No such method defined

    No such method defined

    Hello, I am having a problem that this package gives an error no such method (MetadataRetriever) defined in channel when I put the path of an audio file of my phone which is connected to my dekstop through USB.

    question 
    opened by AssassinAguilar 1
  • Linux build failed

    Linux build failed

    Hello! Your library works on Android very well & it's amazing. But, if I build for Linux, I get this strange error.

    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:22:10: error: explicit specialization of
    'returnValue' in class scope
    [   +1 ms]     void returnValue<int>(int result) {
    [        ]          ^
    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:33:10: error: explicit specialization of
    'returnValue' in class scope
    [   +1 ms]     void returnValue<std::string>(std::string result) {
    [        ]          ^
    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:45:10: error: explicit specialization of
    'returnValue' in class scope
    [        ]     void returnValue<std::map<std::string, std::string>>(std::map<std::string, std::string> result) {
    [        ]          ^
    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:79:9: error: explicit specialization of
    'getArgument' in class scope
    [        ]     int getArgument<int>(const char* argument) {
    [        ]         ^
    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:89:17: error: explicit specialization of
    'getArgument' in class scope
    [        ]     std::string getArgument<std::string>(const char* argument) {
    [        ]                 ^
    [        ] /home/mytja/Documents/harmonoid/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/linux/include/flutter_media_metadata/flutter_types.hpp:101:11: error: explicit specialization of
    'getArgument' in class scope
    [        ]     float getArgument<float>(const char* argument) {
    [        ]           ^
    

    Do you know what could be wrong??? Thank you so much

    opened by mytja 1
  • Null check operator used on a null value

    Null check operator used on a null value

    this line throw such error await retriever.setFile(File(song.path));

    [ERROR:flutter/runtime/dart_isolate.cc(1137)] Unhandled exception:
    Null check operator used on a null value
    #0      MethodChannel.binaryMessenger
    package:flutter/…/services/platform_channel.dart:142
    #1      MethodChannel._invokeMethod
    package:flutter/…/services/platform_channel.dart:148
    #2      MethodChannel.invokeMethod
    package:flutter/…/services/platform_channel.dart:331
    #3      MetadataRetriever.setFile
    package:flutter_media_metadata/flutter_media_metadata.dart:85
    <asynchronous suspension>
    #4      GenerateThumbnails.isolatedThread
    package:ruminate/…/utils/generate_thumbnails.dart:38
    <asynchronous suspension>
    

    dart version sdk: '>=2.13.0 <3.0.0'

    opened by 4-alok 1
  • retriever is racy

    retriever is racy

    That is when you have a listview where for each item you are trying to fetch album art, if queries are done simulatniously, multiple items will eventaually receive same data.

    I created a repro for this, see #10

    opened by nt4f04uNd 1
  • Not work in isolate

    Not work in isolate

    when using in isolate this error happen try adding WidgetsFlutterBinding.ensureInitialized() in main method but not fix.

    Binding has not yet been initialized. The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized. Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding. In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.

    opened by H3mnz 2
  • Error on Flutter web for media files without album art

    Error on Flutter web for media files without album art

    Hi,

    Following piece of code:

    FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
      if (result != null) {
      for(int x = 0; x < result.files.length; x++) {
        print(result.files[x].name);
        Uint8List bytes = result.files[x].bytes as Uint8List;
        final metadata = await MetadataRetriever.fromBytes(bytes); // throws the error
        String? trackName = metadata.trackName;
        print(trackName);
    

    [...]

    I checked this with mp3, m4a and wmv files. It only occurs on Flutter web. If the audio files contain an album art everything works fine. If they do not contain an album art, I get the following error message:

    Error: Expected a value of type 'String', but got one of type 'Null' at Object.throw_ [as throw] (http://localhost:50323/dart_sdk.js:5067:11) at Object.castError (http://localhost:50323/dart_sdk.js:5026:15) at Object.cast [as as] (http://localhost:50323/dart_sdk.js:5351:17) at Function.as (http://localhost:50323/dart_sdk.js:46170:19) at http://localhost:50323/packages/flutter_media_metadata/src/flutter_media_metadata_web.dart.lib.js:89:159 at Object._checkAndCall (http://localhost:50323/dart_sdk.js:5274:16) at Object.dcall (http://localhost:50323/dart_sdk.js:5279:17) at ret (http://localhost:50323/dart_sdk.js:62346:21)

    Afaik this relates to the following line of code:

    let metadata = new (T.IdentityMapOfString$dynamic()).from(["metadata", new _js_helper.LinkedMap.new(), "albumArt", convert.base64Decode(core.String.as(dart.dsend(rawMetadataJson, '_get', ["Cover_Data"]))), "filePath", null]);

    I cannot read nor write .js :) but it looks like a null check is missing?

    What else do you need?

    Thanks, Michael

    opened by 50n13x 2
  • Build process failed on Linux

    Build process failed on Linux

    Cannot build my project on Linux.

    flutter run -d linux:

    /home/pizi/Documents/Project/boombox/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/utils.hpp:108:12: error: variable 'last_index' set but not used [-Werror,-Wunused-but-set-variable]
    /home/pizi/Documents/Project/boombox/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/metadata_retriever.cpp:56:16: error: variable 'size' set but not used [-Werror,-Wunused-but-set-variable]
    /home/pizi/Documents/Project/boombox/linux/flutter/ephemeral/.plugin_symlinks/flutter_media_metadata/cxx/metadata_retriever.cpp:57:16: error: variable 'header' set but not used [-Werror,-Wunused-but-set-variable]
    Exception: Build process failed
    

    flutter doctor:

    [✓] Flutter (Channel stable, 2.10.4, on Manjaro Linux 5.15.28-1-MANJARO, locale
        en_US.UTF-8)
    [✓] Android toolchain - develop for Android devices (Android SDK version
        32.1.0-rc1)
    [✓] Chrome - develop for the web
    [✓] Linux toolchain - develop for Linux desktop
    [✓] Android Studio (version 2021.1)
    [✓] Connected device (2 available)
    [✓] HTTP Host Availability
    

    tried as per #23, still not working

    mediainfo --version

    MediaInfo Command line, 
    MediaInfoLib - v22.03
    
    opened by MaddPenguin 8
  • Duration on web returns null (and breaks code)

    Duration on web returns null (and breaks code)

    Uint8List byteString = await pickedFile.readAsBytes(); <<pickedFile is XFile Metadata videoMetaData = await MetadataRetriever.fromBytes(byteString); int? dur = videoMetaData.trackDuration; << returns null

    Note: I have added this script in the section of index.html

    also the code crashes on this line line 110 of flutter_media_metadata_web.dart:'albumArt': base64Decode(rawMetadataJson['Cover_Data']),

    I'm basically struggling to get the duration of a picked video file on the web.

    opened by sunilguptasg 1
Releases(v1.0.0)
  • v1.0.0(Jan 30, 2022)

    • Now supporting all platforms Windows, Linux, macOS, Android, iOS & Web. 🎉🎉🎉
    • Add web support (@alexmercerind).
    • Add iOS support (@DiscombobulatedDrag).
    • Revert to using CompletableFuture on Android (@alexmercerind).
    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Dec 4, 2021)

    This new release of flutter_media_metadata adds & fixes:

    • Add iOS support (@DiscombobulatedDrag)
    • Linux: Use wcstombs for std::wstring conversion (@alexmercerind).
    • Linux: Fix segmentation fault with no album art files (@alexmercerind).
    • Windows: Fix media having no tags & embedded album art container causing crash (@alexmercerind).
    • Windows: Fix UTF16 tags not being parsed properly (@alexmercerind).
    • Windows: Add file_path to metadata (@alexmercerind).
    • Windows & Linux: Fix FLAC album arts (@alexmercerind).
    • Windows & Linux: Use Format Stream_General for METADATA_BLOCK_PICTURE detection (@alexmercerind).
    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Aug 15, 2021)

    This new release of flutter_media_metadata adds & fixes:

    • Added Windows support.
    • Moved MediaMetadataRetriever.setDataSource & MediaMetadataRetriever.extractMetadata calls to another non-UI thread on Android.
    • Improved Linux support.
    • Added support for embedded album arts on Windows & Linux.
    • Changed API to be more async friendly by being just a single call, MetadataRetriever.fromFile.
    Source code(tar.gz)
    Source code(zip)
Owner
Harmonoid
🎵 An elegant music app. Running everywhere with same awesome experience. 💜
Harmonoid
A program for Mac, Windows and Linux to manage multiple translation files at once

A program for Mac, Windows and Linux to manage multiple translation files at once. Easy to use UI, multithreaded for optimization and Google Translate natively integrated. NB: At the moment it doesn't support nested translation keys.

Jesper Paulsen 4 Aug 8, 2022
Flutter video compress - Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.

flutter_video_compress Generate a new path by compressed video, Choose to keep the source video or delete it by a parameter. Get video thumbnail from

天海るり 179 Dec 8, 2022
Modern UI with Flutter for Web, Android, Windows and Linux.

Modern UI with Flutter for Web, Android, Windows and Linux.

null 1 Apr 9, 2022
Backs up Android devices on Linux, macOS and Windows. Backup your device without vendor lock-ins, using insecure software or root.

Backs up Android devices on Linux, macOS and Windows. Backup your device without vendor lock-ins, using insecure software or root. Supports encryption and compression out of the box.

null 255 Dec 31, 2022
Aves is a gallery and metadata explorer app, built for Android with Flutter.

Aves Aves is a gallery and metadata explorer app. It is built for Android, with Flutter. Features Aves can handle all sorts of images and videos, incl

Thibault Deckers 729 Jan 3, 2023
A Gitmoji app for macOS, Linux, and Windows.

GitmojiApp A Gitmoji app for macOS, Linux, and Windows. macOS Linux Windows What is this GitmojiApp is a simple desktop app that allows you to add a G

Patrick Fu 11 Dec 24, 2022
changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart ?? changelog.dart: a collection of tools to manages in a fashion way a repository as maintainer. ?? Project Homepage Table of Content I

Vincenzo Palazzo 7 Dec 18, 2022
Flutter plugin (android) for sharing bytes and files Offline, (Based on the android Nearby Connections API)

nearby_connections An android flutter plugin for the Nearby Connections API Currently supports Bytes and Files. Transfer Data between multiple connect

Prerak Mann 63 Nov 21, 2022
Download files from Firebase Storage with Flutter. List all images, videos, or other files from Firebase and download them.

Flutter Tutorial - Download Files From Firebase Storage Download files from Firebase Storage with Flutter. List all images, videos, or other files fro

Johannes Milke 28 Dec 4, 2022
Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your device and upload them to Firebase.

Flutter Tutorial - Upload Files To Firebase Storage Upload Files To Firebase Storage with Flutter. Pick images, videos, or other files from your devic

Johannes Milke 30 Dec 28, 2022
This is just the simplyfied Flutter Plugin use for one of the popular flutter plugin for social media login.

social_media_logins Flutter Plugin to login via Social Media Accounts. Available Social Media Logins: Facebook Google Apple Getting Started To use thi

Reymark Esponilla 3 Aug 24, 2022
A Flutter plugin for fetching Firestore documents with read from cache first then server.

Firestore Cache A Flutter plugin for fetching Firestore documents with read from cache first then server. This plugin is mainly designed for applicati

null 22 Nov 24, 2022
Flutter plugin that allows you to keep the device screen awake on Android, iOS, macOS, Windows, and web.

Wakelock Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping. Supported platforms Platfo

null 341 Jan 4, 2023
Mangato - An Android & IOS app to read manga on your phone without ads.

Mangato Read your favorite Japanese manga on Mangato including Attack on Titan, Fairy Tail, The Seven Deadly Sins, Fuuka, One Piece, and more. WARNING

Marouane 20 Nov 21, 2022
Flutter Downloader - A plugin for creating and managing download tasks. Supports iOS and Android.

Flutter Downloader A plugin for creating and managing download tasks. Supports iOS and Android. This plugin is based on WorkManager in Android and NSU

Flutter Community 789 Jan 3, 2023
A Video Player For Vimeo Videos in Flutter. This plugin allows us to play video from Vimeo and it supports Android and iOS platforms.

vimeo_video_player A Video Player For Vimeo Videos in Flutter. This plugin allow us to play video from vimeo and it's supports Android and iOS platfor

MindInventory 26 Dec 8, 2022
Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS

flutter_barcode_scanner A plugin for Flutter apps that adds barcode scanning support on both Android and iOS. Try example Just clone or download the r

Amol Gangadhare 325 Jan 6, 2023
Flutter plugin for Firebase Auth UI. Supports popular auth providers by using native SDK for Android and iOS.

firebase_auth_ui Flutter plugin of Firebase UI which allows to add login/sign-up quickly. NOTE: This plugin is under development. Please provide Feedb

Sandip Fichadiya 50 Mar 23, 2022
A flutter plugin for viewing PDF files in mobile app (Android & iOS)

PDF Viewer (JK) A flutter plugin for viewing PDF files in mobile app (Android & iOS) Pub.dev https://pub.dev/packages/pdf_viewer_jk Github ht

Jawad 8 Sep 30, 2021