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.1

Issues are maintained here.

Support

Consider supporting the project by starring the repository or buying me a coffee.

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
Android Working
Linux Working
Windows Working

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 9
  • 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 cross-platform media playback library for C/C++ with good number of features (only Windows & Linux).

libwinmedia A cross-platform media playback library for C/C++ & Flutter with good number of features. Example A very simple example can be as follows.

Harmonoid 38 Nov 2, 2022
An 🎡 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.

βœ’ libwinmedia is sequel to this project. It provides network playback, better format support, control & features. An audio playback library for Flutte

Hitesh Kumar Saini 50 Oct 31, 2022
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Miguel Ruivo 987 Jan 6, 2023
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
Suwariyomi means to sit and read. Opposite of Tachiyomi which is to stand and read.

Suwariyomi Suwariyomi means to sit and read. Opposite of Tachiyomi which is to stand and read. Getting Started Install Android Studio (or any IDE you

Woon Eusean 5 Mar 24, 2022
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

ChunKoo Park 72 Dec 2, 2022
A cross-platform app ecosystem, bringing iMessage to Android, PC (Windows, Linux, & even macOS), and Web!

BlueBubbles Android App BlueBubbles is an open-source and cross-platform ecosystem of apps aimed to bring iMessage to Android, Windows, Linux, and mor

BlueBubbles 318 Jan 8, 2023
Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.

go-flutter - A package that brings Flutter to the desktop Purpose Flutter allows you to build beautiful native apps on iOS and Android from a single c

null 5.5k Jan 6, 2023
Flutter library for window blur & transparency effects for on Windows & Linux. πŸ’™

flutter_acrylic Window blur & transparency effects for Flutter on Windows & Linux Installation Mention in your pubspec.yaml. dependencies: ... flu

Hitesh Kumar Saini 437 Dec 31, 2022
A simple-to-use flutter update package for Windows, MacOS, and Linux.

Updat - The simple-to-use, flutter-based desktop update package Updat is a simple-to-use reliable flutter-native updater that handles your application

Eduardo M. 14 Dec 21, 2022
A pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows.

FlutterFire Desktop A work in progress pure Dart implementation of Firebase with initial support aimed at FlutterFire for Linux & Windows. A FlutterFi

Invertase 293 Jan 4, 2023
Create Msix installer for flutter windows-build files.

Msix A command-line tool that create Msix installer for your flutter windows-build files. ?? Install In your pubspec.yaml, add msix as a new dependenc

Yehuda Kremer 191 Dec 30, 2022
A clean front-end plugin to Volumio, the Linux distribution for music playback. Volumio Touch Display Lite is written in Flutter and runs on flutter-pi.

EN | δΈ­ζ–‡ Touch Display Lite plugin for Volumio 3 Feng Zhou, 2021-12 Touch Display Lite is a clean and fast user interface for Volumio 3, the Linux dist

Feng Zhou 5 Jul 26, 2022
A cross-platform (Windows/macOS) scanner plugin for Flutter

quick_scanner A cross-platform (Windows/macOS) scanner plugin for Flutter Usage QuickScanner.startWatch(); var _scanners = await QuickScanner.getScan

Woodemi Co., Ltd 5 Jun 10, 2022
A tutorial for creating an Ubuntu Linux Flutter app, using the yaru theme

Building a Yaru app with Flutter Summary URL https://github.com/ubuntu/user_manager Category Environment Linux Status Feedback Link Author Frederik Fe

Ubuntu 22 Dec 21, 2022
Embedded Linux embedding for Flutter

Embedded Linux (eLinux) embedding for Flutter This project was created to develop non-official embedded Linux embeddings of Flutter. This embedder is

Sony 918 Dec 30, 2022
A flutter application to monitor your Linux PC statistic.

Linux Stats App A flutter application to monitor your Linux PC statistic. Screenshots Installation Download or clone the repository: $ git clone https

Malte2036 7 Dec 17, 2022
Embedded Flutter runtime targeting Embedded Linux with Wayland

ivi-homescreen IVI Homescreen for Wayland Strongly Typed (C++) Lightweight Clang 11 Release Stripped = 151k GCC 9.3 Release Stripped = 168k Source run

null 172 Jan 6, 2023
A small karaoke app made in Flutter for Linux

Karaoke app for linux A small karaoke/lyrics display for the currently running VLC song. Video: Make sure the songs have metadata (at least title and

Wazzaps 63 Jan 7, 2023