Skip to content

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
souvik-ghosh committed Apr 20, 2020
1 parent 03d172b commit cd5581a
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 6,802 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
iOS/Android thumbnail generator with support for both local and remote videos. `react-native-create-thumbnail` is a wrapper around
[`AVAssetImageGenerator`](https://developer.apple.com/documentation/avfoundation/avassetimagegenerator?language=objc) (iOS) and [`MediaMetadataRetriever`](https://developer.android.com/reference/android/media/MediaMetadataRetriever) (Android)

[![npm](https://img.shields.io/npm/v/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![npm](https://img.shields.io/npm/dm/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![License](https://img.shields.io/npm/l/react-native-create-thumbnail.svg)](https://www.npmjs.com/package/react-native-create-thumbnail)
[![npm version](https://img.shields.io/npm/v/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![npm downloads](https://img.shields.io/npm/dm/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![Maintenance Status](https://img.shields.io/badge/maintenance-active-green.svg)](#maintenance-status)

## Getting started

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ public void create(ReadableMap options, Promise promise) {
Bitmap image = retriever.getFrameAtTime(timeStamp * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
retriever.release();

if (image == null) {
throw new IllegalStateException("File doesn't exist or not supported");
}

File dir = new File(thumbnailDir);
if (!dir.exists()) {
dir.mkdirs();
// Add .nomedia to hide the thumbnail directory from gallery
File noMedia = new File(thumbnailDir, ".nomedia");
file.createNewFile();
noMedia.createNewFile();
}

File file = new File(thumbnailDir, fileName);
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ local.properties
node_modules/
npm-debug.log
yarn-error.log
yarn.lock

# BUCK
buck-out/
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ PODS:
- React-cxxreact (= 0.61.5)
- React-jsi (= 0.61.5)
- React-jsinspector (0.61.5)
- react-native-create-thumbnail (1.1.0):
- react-native-create-thumbnail (1.1.1):
- React
- React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5)
Expand Down Expand Up @@ -326,7 +326,7 @@ SPEC CHECKSUMS:
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
react-native-create-thumbnail: 056455814fe07dc68a4d8051601724e5785a7127
react-native-create-thumbnail: 98493415cc6e722e80fee6522e5412857a1eed3b
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
Expand Down
130 changes: 65 additions & 65 deletions example/ios/example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6,724 changes: 0 additions & 6,724 deletions example/yarn.lock

This file was deleted.

1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare module "react-native-create-thumbnail" {
timeStamp?: number;
type?: "local" | "remote";
format?: "jpeg" | "png";
dirSize?: number
}

export interface Thumbnail {
Expand Down
16 changes: 8 additions & 8 deletions ios/CreateThumbnail.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ @implementation CreateThumbnail

UIImage *thumbnail = [self generateThumbImage:vidURL atTime:timeStamp];

if (thumbnail == nil) {
NSException *e = [NSException
exceptionWithName:@"FileNotSupportedException"
reason:@"File doesn't exist or not supported"
userInfo:nil];
@throw e;
}

// Save to temp directory
NSString* tempDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
tempDirectory = [tempDirectory stringByAppendingString:@"/thumbnails/"];
Expand All @@ -47,14 +55,6 @@ @implementation CreateThumbnail
fullPath = [tempDirectory stringByAppendingPathComponent: [NSString stringWithFormat:@"thumb-%@.jpeg",[[NSProcessInfo processInfo] globallyUniqueString]]];
}

if (data == nil) {
NSException *e = [NSException
exceptionWithName:@"FileNotSupportedException"
reason:@"File doesn't exist or not supported"
userInfo:nil];
@throw e;
}

NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:fullPath contents:data attributes:nil];
resolve(@{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-native-create-thumbnail",
"title": "React Native Create Thumbnail",
"version": "1.1.0",
"version": "1.1.1",
"description": "iOS/Android thumbnail generator with support for both local and remote videos",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cd5581a

Please sign in to comment.