diff --git a/README.md b/README.md index 3413ea9..d024cc4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ add the lines to AndroidManifest.xml ``` -NOTE: for android versions >= 6.0 Request Permission from user at runtime before calling this plugin. +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 @@ -26,19 +27,14 @@ Import the library #### Examples ``` dart - // Fetch thumbnail, store in a specified output folder and return file path String thumb = await Thumbnails.getThumbnail( - thumbOutputFile: - '[YOUR OUTPUT FOLDER PATH TO SAVE THUMBNAILS]', // creates it if it doesnt already exist + thumbnailFolder:'[FOLDER PATH TO STORE THUMBNAILS]', // creates the specified path if it doesnt exist videoFile: '[VIDEO PATH HERE]', imageType: ThumbFormat.PNG, quality: 30); - -// Fetch thumbnail, store in app's Temporary directory output folder and return file path - String thumb = await Thumbnails.getThumbnail( - videoFile: '[VIDEO PATH HERE]', - imageType: ThumbFormat.JPEG, - quality: 45); + /* + * thumbnailFolder property can be omitted if you dont wish to keep the generated thumbails past each usage + */ ``` \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 8b7a938..ffeeee0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,18 +10,17 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { // Fetch thumbnail and store in a specified output folder - void _buildThumbToFile() async { + void _toUserFolder() async { String thumb = await Thumbnails.getThumbnail( - thumbOutputFile: - '/storage/emulated/0/Videos/Thumbnails', + thumbnailFolder: '/storage/emulated/0/Videos/Thumbnails', videoFile: '/storage/emulated/0/Videos/Testvideo.mp4', imageType: ThumbFormat.PNG, quality: 30); print('path to File: $thumb'); } -// when an output folder is not specified thumbnail are stored in app temporary directory - void _buildThumbToCache() async { +// when an output folder is not specified thumbnail are stored in app temporary directory + void _noFolder() async { String thumb = await Thumbnails.getThumbnail( videoFile: '/storage/emulated/0/Videos/Testvideo.mp4', imageType: ThumbFormat.JPEG, @@ -40,9 +39,9 @@ class _MyAppState extends State { child: Column( children: [ RaisedButton( - onPressed: _buildThumbToFile, child: Text('Build To File')), + onPressed: _toUserFolder, child: Text('To Specified Folder')), RaisedButton( - onPressed: _buildThumbToCache, child: Text('Build to Cache')), + onPressed: _noFolder, child: Text('No Folder Specified')), ], ), ), diff --git a/lib/thumbnails.dart b/lib/thumbnails.dart index 70a2086..78b4d21 100644 --- a/lib/thumbnails.dart +++ b/lib/thumbnails.dart @@ -11,12 +11,12 @@ class Thumbnails { static Future getThumbnail( {@required String videoFile, - String thumbOutputFile, + String thumbnailFolder, ThumbFormat imageType, int quality}) async { var utilMap = { 'videoFilePath': videoFile, - 'thumbFilePath': thumbOutputFile, + 'thumbFilePath': thumbnailFolder, 'thumbnailFormat': validateType(imageType), 'thumbnailQuality': validateQuality(quality) }; diff --git a/lib/validators.dart b/lib/validators.dart index dbb4717..fb8b286 100644 --- a/lib/validators.dart +++ b/lib/validators.dart @@ -4,7 +4,8 @@ const DEFAULT_THUMB_QUALITY = 50; const DEFAULT_IMAGE_TYPE = ThumbFormat.JPEG; int validateQuality(int choice) { - if (choice < 10 || choice > 100 || choice == null) return DEFAULT_THUMB_QUALITY; + if (choice < 10 || choice > 100 || choice == null) + return DEFAULT_THUMB_QUALITY; return choice; }