-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
pubspec.lock | ||
|
||
build/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# thumbnails | ||
|
||
A new flutter plugin project. | ||
|
||
## Getting Started | ||
|
||
For help getting started with Flutter, view our online | ||
[documentation](https://flutter.io/). | ||
|
||
For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>thumbnails</name> | ||
<comment>Project thumbnails created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(C\:\\Gradle\\gradle-4.7)) | ||
connection.project.dir=../example/android | ||
eclipse.preferences.version=1 | ||
gradle.user.home= | ||
offline.mode=false | ||
override.workspace.settings=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
group 'com.asapjay.thumbnails' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.1.2' | ||
} | ||
} | ||
|
||
rootProject.allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 27 | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx1536M |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'thumbnails' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.asapjay.thumbnails"> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.asapjay.thumbnails; | ||
|
||
import android.graphics.Bitmap; | ||
import android.media.ThumbnailUtils; | ||
import android.provider.MediaStore; | ||
import android.util.Log; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import io.flutter.plugin.common.MethodCall; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
import io.flutter.plugin.common.MethodChannel.Result; | ||
import io.flutter.plugin.common.PluginRegistry.Registrar; | ||
|
||
/** | ||
* ThumbnailsPlugin | ||
*/ | ||
public class ThumbnailsPlugin implements MethodCallHandler { | ||
/** | ||
* Plugin registration. | ||
*/ | ||
public static void registerWith(Registrar registrar) { | ||
final MethodChannel channel = new MethodChannel(registrar.messenger(), "thumbnails"); | ||
channel.setMethodCallHandler(new ThumbnailsPlugin()); | ||
} | ||
|
||
@Override | ||
public void onMethodCall(MethodCall call, Result result) { | ||
Map<String, Object> arguments = call.arguments(); | ||
if (call.method.equals("getThumbnail")) { | ||
|
||
String videoFile = (String) arguments.get("videoFilePath"); | ||
String thumbOutputFile = (String) arguments.get("thumbFilePath"); | ||
int imageType = (int) arguments.get("thumbnailFormat"); | ||
int quality = (int) arguments.get("thumbnailQuality"); | ||
try { | ||
buildThumbnail(videoFile, thumbOutputFile, imageType, quality); | ||
result.success("success"); | ||
} catch (Throwable throwable) { | ||
throwable.printStackTrace(); | ||
} | ||
} else { | ||
result.notImplemented(); | ||
} | ||
} | ||
|
||
private void buildThumbnail(String vidPath, String thumbPath, int type, int quality) { | ||
|
||
if (vidPath == null || vidPath == "") { | ||
Log.println(Log.INFO, "WARNING", "Thumbnails: Video Path must not be null or empty"); | ||
return; | ||
} | ||
if (thumbPath == null || thumbPath == "") { | ||
Log.println(Log.INFO, "WARNING", "Thumbnails: Thumbnail Path must not be null or empty"); | ||
return; | ||
} | ||
|
||
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(vidPath, MediaStore.Video.Thumbnails.MINI_KIND); | ||
switch (type) { | ||
case 1: | ||
try { | ||
FileOutputStream out = new FileOutputStream(new File(thumbPath)); | ||
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, out); | ||
out.flush(); | ||
out.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
break; | ||
|
||
case 2: | ||
try { | ||
FileOutputStream out = new FileOutputStream(new File(thumbPath)); | ||
bitmap.compress(Bitmap.CompressFormat.PNG, quality, out); | ||
out.flush(); | ||
out.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
break; | ||
case 3: | ||
try { | ||
FileOutputStream out = new FileOutputStream(new File(thumbPath)); | ||
bitmap.compress(Bitmap.CompressFormat.WEBP, quality, out); | ||
out.flush(); | ||
out.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
break; | ||
|
||
} | ||
} | ||
} |