Hi everyone
How i can check if there is a command is executed in real time and get status if there is finished ?
Because here i have a chat application with react native and user can send a video and before the video terminate compress he send another so it will call the method of compress another time without terminate the compress of the first ?
here is my code :
for (var i = 0; i < media.length; i++) {
// console.log("send :", media[i].uri);
this.setState({ mediaUploaded: true });
let name;
if (media[i].image) {
type = "image/jpeg";
name = "photo.jpg";
data.append("files[" + i + "]", {
uri:
Platform.OS === "android"
? media[i].uri
: media[i].uri.replace("file://", ""), // your file path string
name: name,
type: type
});
} else if (media[i].video) {
let output;
//setTimeout(this.compressionVideo(),2000);
if (media[i].camera) {
await this.convertVideo(i.toString(),
Platform.OS === "android"
? media[i].path
: media[i].uri.replace("file://", "")
);
} else
output = await this.convertVideo(i.toString(),
Platform.OS === "android"
? media[i].uri
: media[i].uri.replace("file://", "")
);
// console.log(output);
type = "video/mp4";
name = "video.mp4";
let file = "";
if (Platform.OS == "ios")
file = `${RNFetchBlob.fs.dirs.DocumentDir}/convert${i.toString()}.mp4`;
else file = `file://${RNFetchBlob.fs.dirs.PictureDir}/convert${i.toString()}.mp4`;
console.log(file);
data.append("files[" + i + "]", {
uri: file, // your file path string
name: name,
type: type
});
}
}
command
).then(result => {
let messagesChat = [...this.state.messagesChat];
for (var i = 0; i < messagesChat.length; i++) {
let item = messagesChat[i];
this.setState({videoConvert:false})
if (item && item.destination === "web") {
let media = item.media[0].media;
if(media[index])
media[index].compression = false;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi everyone How i can check if there is a command is executed in real time and get status if there is finished ? Because here i have a chat application with react native and user can send a video and before the video terminate compress he send another so it will call the method of compress another time without terminate the compress of the first ? here is my code : for (var i = 0; i < media.length; i++) { // console.log("send :", media[i].uri); this.setState({ mediaUploaded: true });
async convertVideo(i,uri) {
this.setState({videoConvert:true})
command ).then(result => { let messagesChat = [...this.state.messagesChat]; for (var i = 0; i < messagesChat.length; i++) { let item = messagesChat[i]; this.setState({videoConvert:false}) if (item && item.destination === "web") { let media = item.media[0].media; if(media[index]) media[index].compression = false;
}