Skip to content

Commit

Permalink
Merge pull request #119 from souvik-ghosh/2.0.1
Browse files Browse the repository at this point in the history
2.0.1
  • Loading branch information
souvik-ghosh authored Dec 7, 2024
2 parents e254b30 + 3b56b92 commit 7e91965
Show file tree
Hide file tree
Showing 30 changed files with 8,071 additions and 8,270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Build;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.webkit.URLUtil;
Expand All @@ -26,8 +27,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.lang.ref.WeakReference;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -190,8 +191,17 @@ private static Bitmap getBitmapAtTime(Context context, String filePath, int time
}
retriever.setDataSource(filePath, headers);
}

Bitmap image = retriever.getScaledFrameAtTime(time * 1000, onlySyncedFrames ? MediaMetadataRetriever.OPTION_CLOSEST_SYNC : MediaMetadataRetriever.OPTION_CLOSEST, maxWidth, maxHeight);

Bitmap image;
if (Build.VERSION.SDK_INT >= 27) {
image = retriever.getScaledFrameAtTime(time * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC, maxWidth, maxHeight);
} else {
// If on versions lower than API 27, use other methods to get frames
image = retriever.getFrameAtTime(time * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
if (image != null) {
image = Bitmap.createScaledBitmap(image, maxWidth, maxHeight, true);
}
}
try {
retriever.release();
} catch(IOException e) {
Expand Down
12 changes: 10 additions & 2 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local
**/.xcode.env.local

# Android/IntelliJ
#
Expand Down Expand Up @@ -56,11 +56,19 @@ yarn-error.log
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
35 changes: 9 additions & 26 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
Text,
View,
StyleSheet,
TextInput,
Button,
ActivityIndicator,
} from 'react-native';
import {createThumbnail} from 'react-native-create-thumbnail';
import Input from './Input';

const placeholderImage = require('./assets/placeholder-image.png');

Expand All @@ -21,18 +21,17 @@ export default function App() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>☆CreateThumbnail example☆</Text>
<TextInput
<Input
label="Video URL"
value={path}
onChangeText={setPath}
style={styles.pathInput}
placeholder="Paste video url"
placeholderTextColor="lightgrey"
/>
<TextInput
<Input
label="Timestamp"
keyboardType="numeric"
value={timeStamp}
onChangeText={setTimeStamp}
style={styles.timeInput}
placeholder="Timestamp"
/>
<Button
Expand Down Expand Up @@ -78,14 +77,15 @@ export default function App() {
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
backgroundColor: '#f5f6fa',
padding: 20,
paddingTop: 50,
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 20,
margin: 30,
color: 'black',
},
instructions: {
Expand All @@ -99,21 +99,4 @@ const styles = StyleSheet.create({
backgroundColor: 'lightgrey',
justifyContent: 'center',
},
pathInput: {
backgroundColor: '#eaeaea',
width: '80%',
paddingHorizontal: 10,
color: 'black',
borderColor: 'lightgrey',
borderWidth: 1,
},
timeInput: {
backgroundColor: '#eaeaea',
width: '40%',
paddingHorizontal: 10,
margin: 20,
color: 'black',
borderColor: 'lightgrey',
borderWidth: 1,
},
});
6 changes: 4 additions & 2 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.13'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
58 changes: 38 additions & 20 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -33,7 +45,7 @@ GEM
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -53,47 +65,53 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.16.3)
ffi (1.17.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.1)
minitest (5.20.0)
json (2.9.0)
logger (1.6.2)
minitest (5.25.4)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.2.6)
rexml (3.3.9)
ruby-macho (2.5.1)
securerandom (0.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.23.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.3, < 7.1.0)
cocoapods (~> 1.13)
activesupport (>= 6.1.7.5, != 7.1.0)
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.2.2p53

BUNDLED WITH
2.4.10
2.5.7
60 changes: 60 additions & 0 deletions example/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { View, Text, TextInput, StyleSheet } from 'react-native';

interface InputProps extends React.ComponentPropsWithoutRef<typeof TextInput> {
label: string;
value: string;
placeholder?: string;
onChangeText?: (text: string) => void;
}

const Input: React.FC<InputProps> = ({ label, value, placeholder, onChangeText }) => {
return (
<View style={styles.container}>
<Text style={styles.label}>{label}</Text>
<View style={styles.inputContainer}>
<TextInput
style={styles.input}
value={value}
placeholder={placeholder}
keyboardType="numeric"
onChangeText={onChangeText}
/>
</View>
</View>
);
};

const styles = StyleSheet.create({
container: {
marginBottom: 20,
},
label: {
fontSize: 16,
color: '#7A7A7A',
marginBottom: 5,
},
inputContainer: {
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#ffffff',
borderRadius: 10,
paddingHorizontal: 10,
paddingVertical: 8,
width: '100%',
height: 70,
},
input: {
flex: 1,
fontSize: 20,
fontWeight: 'bold',
color: '#2E2E2E',
},
currency: {
fontSize: 16,
color: '#7A7A7A',
marginLeft: 8,
},
});

export default Input;
22 changes: 11 additions & 11 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ apply plugin: "com.facebook.react"
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -49,6 +49,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -107,13 +110,10 @@ android {
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Loading

0 comments on commit 7e91965

Please sign in to comment.