React Native cameraRoll save video to device from URL - react-native

I want to save video to a device from a URL.
I tried:
CameraRoll.saveToCameraRoll(videoURL, 'video')
and also:
CameraRoll.save(videoURL, {type: 'Video', album: 'Test'})
I'm getting this error:
The operation couldn’t be completed. (Cocoa error -1.)
What's going wrong?

It looks like you are missing link CameraRoll into Xcode.

While you fetch the file via RNFetchBlob.fetch. Pass appendExt : 'mp4' or 'mov' as config parameter alongside fileCache : true. This should fix your problem.
Also, type:'video' and not 'Video'.

Related

How to solve track disable error in agora when grab mic and mic drop?

AgoraRTCError TRACK_IS_DISABLED: can not publish a disabled track:
displayCurrentSpeaker # agora-client-video.js:288
Uncaught (in promise) r {name: 'AgoraRTCException', code: 'TRACK_IS_DISABLED', message: 'AgoraRTCError TRACK_IS_DISABLED: can not publish a disabled track: track-cam-845cd018', data: undefined}
Cannot read properties of undefined (reading 'getMediaStreamTrack')
at attachStreamToBigCircle (agora-client-video.js:506)
at async changeMicSpeaker
[enter image description here][1]
I attached error's screenshot . Please provide solution
[1]: https://i.stackstrong text.imgur.com/BUH4X.png
The track is disabled, usually because you have called Track.setEnabled(false) to disable the track.
Call Track.setEnabled(true) to enable the track and retry.
If you could share more code, we can debug it further.
See how you can change the device (mic and video) here: https://docs.agora.io/en/Voice/test_switch_device_web_ng?platform=Web
I made a sample app doing the same: https://github.com/akshatvg/speakOut/blob/master/assets/js/goLive.js

react-native : image import err : None of these files exist

I am trying to import an img.JPG photo in my React Native project using import image from './media/img.JPG';.
But I get an error saying the file doesn't exist
For reference, my files look like this:
It came out well on the screen when the external path was inserted.
In your question, you say the image name is img.PNG, but in the code it says img.JPG. Could that be the issue?

Getting the following error: Unable to resolve "../assets/icon.png" from "app\assets\screens\WelcomeScreen.js"

When I try to run my app I get the error
Unable to resolve "../assets/icon.png" from "app\assets\screens\WelcomeScreen.js"
Error: Problems validating asset fields in app.json. See https://docs.expo.io/
• Field: icon - cannot access file at './assets/icon.png'.
I created a screens folder and input my homescreen into it as I heard that the majority of the react native community does things that way. Attached is a picture of my filesenter image description here
I think that the image path is off, however I had changed it multiple times and am still getting the same error.
Any help would be appreciated.
try the following: ../icon.png
Cause that's what I can see from your file structure.
If you use visual studio code as dev tool, when you type path cue, correct path will be appeared. so you can avoid to make mistake in path of image.

Is there a way I can detect text from an Image using Expo React Native?

I am working with Expo, React Native and I want to to be able to detect text from images. Is there an package i can work with to achieve this?
I am using Expo camera module to snap the picture and supply the URI to the text detector
I have tried using react-native-text-detector but I am getting the error that the function detectFromUri is not defined. I have also tried with tesserect.js but it fails on import with "unable to resolve variable location".
await this.camera.takePictureAsync(options).then(photo => {
photo.exif.Orientation = 1;
//console.log(photo.uri);
const visionResp = await RNTextDetector.detectFromUri(photo.uri);
if (!(visionResp && visionResp.length > 0)) {
throw "UNMATCHED";
}
console.log(visionResp);
});
I am expecting the visionResp to log the results returned from the detection but instead i get undefined is not an object (evaluating '_reactNativeTextDetector.default.detectFromUri')
Is your project created with expo-cli?
If yes, Expo is not supporting OCR currently. There is a feature request on canny.io but you can't know for sure when it will become available.
Your only choice is to use an OCR service like this one.Internet connectivity will be required.
If not, (and the project is created with react-native-cli) you should be able to successfully use react-native-text-detector. Just make sure you link the package correctly. Docs here

How can I cache videos in React Native

It is already long time that I struggle and can't find a proper solution to this question: how handle video cache in RN. I am using react-native-video to show the videos, but that package does not have cache option yet. Please help to find a solution. Thanks a lot
David's answer is good but you will need to go into node_modules/react-native-cached-image/utils/pathUtils.js and edit defaultImageTypes array to include mp4 or whatever file extension you want to save. If you don't do this then the video files will be saved as JPG and cause the Video component to crash.
There doesn't seem to be a way to override the accepted file types without directly modifying the core cached-image module. Also you'll want to make sure to check the loaded state property before trying to load the video because it will crash for that as well. After you do that it will work!
I finally found a solution here. So the magic is in ImageCacheManager, which now can be used to cache any type of file, e.g. video files or pdf files. So I used the following package https://github.com/kernelnetworks/react-native-cached-image.git, where all proper changes are done to be able to cache any type of files.
...
import { ImageCacheManager } from "react-native-cached-image";
import Video from "react-native-video";
...
componentDidMount() {
ImageCacheManager({})
.downloadAndCacheUrl(this.props.source.uri)
.then(res => {
this.setState({ cachedVideoURI: res, loaded: true });
})
.catch(err => {
...
});
}
And then use that cached uri as a source for your video (or for any other type of file).
<Video source={{uri: this.state.cachedVideoURI}}
That's it !!!
Hope this will help someone to save bunch of times