Comments (5)
I forgot to mention that you may also need the permission on Android (typescript example):
import { PermissionsAndroid } from "react-native";
/*
*
* Types.
*
*/
export type permissionDialog = {
title: string;
message: string;
buttonNeutral?: string;
buttonNegative?: string;
buttonPositive?: string;
};
/*
*
* Functions.
*
*/
export async function isPermissionGrantedOnAndroid(permission: Permission, dialog: permissionDialog) {
const status = await PermissionsAndroid.request(permission, {
title: dialog.title,
message: dialog.title,
buttonNeutral: dialog.buttonNeutral || "Ask Me Later",
buttonNegative: dialog.buttonNegative || "Don't allow",
buttonPositive: dialog.buttonPositive || "OK"
});
console.log("status", status, "dialog:", dialog);
return status === PermissionsAndroid.RESULTS.GRANTED;
}
// ...later...
await isPermissionGrantedOnAndroid(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
title: "Media Library Permission",
message: "App needs the permission to access your camera storage"
});
await isPermissionGrantedOnAndroid(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, {
title: "Media Library Permission",
message: "App needs the permission to access your camera storage"
});
from react-native-thumbnail.
Same issue is there in my case.
Please help me in this
from react-native-thumbnail.
Facing same issue..
Need help ASAP.
from react-native-thumbnail.
Does this happen on android only? On android, you can just use the component for rendering video thumbnails. This package seems to work only on iOS where it is actually needed because the
component does not render video thumbnails
from react-native-thumbnail.
It's probably how you handle the the URIs in your app. This a working example in a project I'm working on:
import RNVideoThumb from "react-native-thumbnail";
import fs from "react-native-fs";
// ...
async function createVideoItem(tempUri){
// Get file's suffix.
// 'tempUri' is a uri returned from react-native-camera
const type = tempUri.substring(tempUri.lastIndexOf(".") + 1);
// Create a persistent directory for our video as the provided
// path by RNCamera is only a temporary cache.
// 'id' is a simple UID as an example here.
const id = `${Date.now()}`
const fileUri = `${fs.DocumentDirectoryPath}/${id}.${type}`;
// Copy the video now.
await fs.copyFile(tempUri, fileUri);
// Handle the thumbnail's creation + storing.
// We use the newly created, persistent 'fileUri' as source, as
// this is where our video is now stored, with the file-prefix.
// Note that we also extract the thumb's image-type to avoid
// a hardcoded suffix.
const thumbResult = await RNVideoThumb.get(`file://${fileUri}`);
const thumbType = thumbResult.path.substring(thumbResult.path.lastIndexOf(".") + 1);
// Using '_thumb' in the path to distinguish from the video-file.
const thumbUri = `${fs.DocumentDirectoryPath}/${id}_thumb.${thumbType}`;
// Now copy the thumbnail image.
await fs.copyFile(thumbResult.path, thumbUri);
// Now create an object for later use (e.g. storing in DB).
const videoItem = {
id,
fileUri: `file://${fileUri}`,
thumbUri: `file://${thumbUri}`,
createdAt: new Date(),
};
return videoItem;
}
from react-native-thumbnail.
Related Issues (20)
- Feature Request: Support setting the timestamp for the created thumbnail
- Height and width of 0 thumbnail result HOT 1
- More than one library with package name 'com.reactlibrary' [Android] HOT 2
- How should the filepath be? HOT 4
- Request: Add provision to select thumb from given time
- Error building for android: more than one library with package name 'com.reactlibrary' HOT 1
- Gradle DSL method not found: 'google()' HOT 1
- Thumbnails are blurry HOT 2
- Android requires storage permission
- Cannot resolve symbol 'reactlibrary' HOT 6
- any way to assign the return file path to variable? HOT 1
- So it doesn't support IOS? HOT 5
- Android publishing application failed HOT 5
- Cache Handling HOT 1
- is there any option to decrease image size?
- How to get the first tick of frame?
- not work in Android
- 是否能获取网络视频的封面,现在会报错 HOT 9
- Does not work with latest react-native 0.60.x HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-thumbnail.