itinance / itinance/react-native-fs

copyAssetsVideoIOS not working properly.

Open
#572 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

```
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-fs": "^2.9.12",
"react-native-gallery-manager": "^1.0.9",
```
Hello there,
I've media picker screen like this,
![this](https://user-images.githubusercontent.com/39304144/47600731-6e87d780-d9e3-11e8-8e58-c480c8706c70.png),
which allow user to select category & media (Images & Video).
So, I'm fetching phone assets from CameraRoll using [react-native-gallery-manager](https://github.com/pentarex/react-native-gallery-manager) library. It's return me images & video URL like, `assets-library://`. this kind of URL can show images properly using [``](https://facebook.github.io/react-native/docs/images), but to load/play video, I need URL like `file://` for [``](https://github.com/react-native-community/react-native-video) & that's why I'm using this package, to fetch video's proper URL.

checkout my code.
```
// GalleryManager Usage
GalleryManager.getAssets({
type: 'all',
limit: 60,
startFrom: this.state.images.length,
}).then(data => this.storeImages(data))

// storeImages Usage
storeImages(data) {

const tempObj = data.assets;
alert('total data get : ' + tempObj.length);
if (tempObj.length > 0) {
const imagesObj = tempObj.filter((tempValue) => tempValue.duration <= 90)
if (Platform.OS === 'ios') {
for (let i = 0; i < imagesObj.length; i++) {
let tempData = imagesObj[i];
if (tempData.type === 'video') {
const res = await RNFS.copyAssetsVideoIOS(
tempData.uri,
`${RNFS.TemporaryDirectoryPath}${tempData.filename}`
)
tempData.uri = "file://" + res;
imagesObj[i] = tempData;
}
}
const imagesData = imagesObj.map(newData => ({
imageLocation: newData.uri,
fileType: newData.mimeType.split('/')[0]
}));
this.setState({
images: [...images, ...imagesData]
});
} else {
const imagesData = imagesObj.map(newData => ({
imageLocation: newData.uri,
fileType: newData.mimeType.split('/')[0]
}));
this.setState({
images: [...images, ...imagesData]
});
}
}

}
```
It's not showing me any output. checkout this images
![IPhone Xs max](https://user-images.githubusercontent.com/39304144/47600919-24ecbc00-d9e6-11e8-93e3-06311a96b5bc.png)
screenshot is of iPhone Xs max (IOS 12) real device (not of simulator) It's also showing me alert like : `total data get : 60`. however in simulator It's working fine.

if I comment entire `for loop` of my code, It's showing me images properly. checkout following snapshot.
![iPhone Xs max](https://user-images.githubusercontent.com/39304144/47600974-223e9680-d9e7-11e8-8630-539d7e282914.png)

Issue was clear for me that `RNFS.copyAssetsVideoIOS` is not working as expected.
I think this happening because phone contain many 4K quality video & might be It's taking so much time to download video from iCloud as you guys have mentioned [here](https://github.com/itinance/react-native-fs#copyassetsfileiosimageuri-string-destpath-string-width-number-height-number-scale--number--10-compression--number--10-resizemode--string--contain--promisestring). but It's not returning anything forever.

Thank you.
Looking forward to your reply.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.