Git Product home page Git Product logo

flutter_thumbnails's Introduction

thumbnails

A Flutter Plugin to generate thumbnails from videos on Local Storage.

Compatibility

Android OS only

Usage

Depend on it

add thumbnails as a dependency in your pubspec.yaml file.

        thumbnails: ^1.0.1

Update Android Permissions

add the lines to AndroidManifest.xml

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

NOTE: for android versions >= 6.0 you need might to request Permission from user at runtime before calling this plugin. (There are available plugins that handles permissions on DartLang.)

Add import statement

Import the library

    import 'package:thumbnails/thumbnails.dart';

Examples

    String thumb = await Thumbnails.getThumbnail(
        thumbnailFolder:'[FOLDER PATH TO STORE THUMBNAILS]', // creates the specified path if it doesnt exist
        videoFile: '[VIDEO PATH HERE]',
        imageType: ThumbFormat.PNG,
        quality: 30);

    /*
    * thumbnailFolder property can be omitted if you dont wish to keep the generated thumbails past each usage
    */

flutter_thumbnails's People

Contributors

asapj avatar sharansingh00002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_thumbnails's Issues

Undefined symbols for architecture i386: "_FlutterMethodNotImplemented", referenced from: -[ThumbnailsPlugin handleMethodCall:result:] in ThumbnailsPlugin.o

running ios app gives this error,
earlier it was running fine
this is the error

ndefined symbols for architecture i386:
"_FlutterMethodNotImplemented", referenced from:
-[ThumbnailsPlugin handleMethodCall:result:] in ThumbnailsPlugin.o
"OBJC_CLASS$_FlutterMethodChannel", referenced from:
objc-class-ref in ThumbnailsPlugin.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

java.lang.NullPointerException

When calling

Thumbnails.getThumbnail(
                thumbnailFolder: tempDir,
                // creates the specified path if it doesnt exist
                videoFile: postVideo.path,
                imageType: ThumbFormat.JPEG,
                quality: 30)

I get

I/FilePicker(15864): Absolute file path:/storage/emulated/0/DCIM/Camera/VID_20190828_120040.mp4
D/EGL_emulation(15864): eglCreateContext: 0xdd073820: maj 3 min 0 rcv 3
D/EGL_emulation(15864): eglMakeCurrent: 0xdd073820: ver 3 0 (tinfo 0xe4852ee0)
D/EGL_emulation(15864): eglMakeCurrent: 0xdea85a20: ver 3 0 (tinfo 0xc5535e60)
D/EGL_emulation(15864): eglMakeCurrent: 0xdd073820: ver 3 0 (tinfo 0xe4852ee0)
W/System.err(15864): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.userDirectory(ThumbnailsPlugin.java:126)
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err(15864): 	at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err(15864): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
W/System.err(15864): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
W/System.err(15864): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
W/System.err(15864): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(15864): 	at android.os.MessageQueue.next(MessageQueue.java:326)
W/System.err(15864): 	at android.os.Looper.loop(Looper.java:160)
W/System.err(15864): 	at android.app.ActivityThread.main(ActivityThread.java:6669)
W/System.err(15864): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15864): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err(15864): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

java.lang.NullPointerException when use library

W/System.err(25430): java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
W/System.err(25430): at java.util.regex.Matcher.reset(Matcher.java:280)
W/System.err(25430): at java.util.regex.Matcher.(Matcher.java:186)
W/System.err(25430): at java.util.regex.Pattern.matcher(Pattern.java:1034)
W/System.err(25430): at com.asapjay.thumbnails.ThumbnailsPlugin.getFileName(ThumbnailsPlugin.java:176)
W/System.err(25430): at com.asapjay.thumbnails.ThumbnailsPlugin.cacheDirectory(ThumbnailsPlugin.java:70)
W/System.err(25430): at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err(25430): at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err(25430): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:231)
W/System.err(25430): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:93)
W/System.err(25430): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:642)
W/System.err(25430): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(25430): at android.os.MessageQueue.next(MessageQueue.java:336)
W/System.err(25430): at android.os.Looper.loop(Looper.java:174)
W/System.err(25430): at android.app.ActivityThread.main(ActivityThread.java:7356)
W/System.err(25430): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(25430): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
W/System.err(25430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

How to get the example working?

I've been running the example in this repo but when I press either buttons, this is the log I get. I suspect this is something to do with the location of the source video file but don't know what to do about it. Could you please add more detail to your example so it's clear how to get it working for a noob like me 🙇 ?

W/System.err(10797): java.io.FileNotFoundException: /storage/emulated/0/Videos/Thumbnails/Testvideo.png (No such file or directory)
W/System.err(10797): 	at java.io.FileOutputStream.open0(Native Method)
W/System.err(10797): 	at java.io.FileOutputStream.open(FileOutputStream.java:308)
W/System.err(10797): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
W/System.err(10797): 	at java.io.FileOutputStream.<init>(FileOutputStream.java:180)
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.userDirectory(ThumbnailsPlugin.java:137)
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err(10797): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
W/System.err(10797): 	at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
W/System.err(10797): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(10797): 	at android.os.MessageQueue.next(MessageQueue.java:326)
W/System.err(10797): 	at android.os.Looper.loop(Looper.java:160)
W/System.err(10797): 	at android.app.ActivityThread.main(ActivityThread.java:6669)
W/System.err(10797): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(10797): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err(10797): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/flutter (10797): path to File:
W/System.err(10797): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.cacheDirectory(ThumbnailsPlugin.java:82)
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.buildThumbnail(ThumbnailsPlugin.java:64)
W/System.err(10797): 	at com.asapjay.thumbnails.ThumbnailsPlugin.onMethodCall(ThumbnailsPlugin.java:49)
W/System.err(10797): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
W/System.err(10797): 	at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
W/System.err(10797): 	at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(10797): 	at android.os.MessageQueue.next(MessageQueue.java:326)
W/System.err(10797): 	at android.os.Looper.loop(Looper.java:160)
W/System.err(10797): 	at android.app.ActivityThread.main(ActivityThread.java:6669)
W/System.err(10797): 	at java.lang.reflect.Method.invoke(Native Method)
W/System.err(10797): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err(10797): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Not compatible for IOS

the author has written in the title that it is for "ANDROID/IOS/WEB"
and just below that in the ReadME file, they have written its compatible for android only!!
what is the meaning of misleading people?
if you are not providing support for IOS then you shouldn't have mention "IOS" in the title!!

No exception thrown to catch on flutter side when thumbnail.generate inside method channel fails.

Method Channel is throwing an error which is not passed to the result.
Screenshot 2020-12-30 at 6 27 54 PM

So, if it fails to create a thumbnail we can't catch the error on flutter side, below is an example

Future buildThumbnail() async {
    this.isLoading = true;
    print('Building thumbnail');
    try {
      this.thumbnailPath = await generateThumbnail(path);
    } catch (e) {
      print('[ERROR] StatusItem => Failed to generate thumbnail $e');
    } finally {
      this.isLoading = false;
    }
  }

/// Generates thumbnail for video statuses
Future generateThumbnail(String video) {
  return Thumbnails.getThumbnail(
    videoFile: video,
    imageType: ThumbFormat.PNG,
    quality: 50,
  );
}

iOS support

Any plans on adding iOS support?

Flutter is a cross-platform dev tool, would only hope it's packages are too 😢

FAILURE: Build failed with an exception

I'm also facing the same issue when I run flutter build apk.

  • What went wrong:
    Execution failed for task ':thumbnails:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84318244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

  \.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84318244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 45s

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.