rn-fetch-blob
rn-fetch-blob copied to clipboard
Download and play a video file
Good day, This is not an issue, per say. It is more of a challenge I am facing using your documentation to learn. I want to be able to access downloaded videos but all i get is a successful download and the download path. I have not been able to play the video from that path. Please if i can be guided on how to achieve this i will be grateful. Thanks
I have an issue. I am downloading a video file that is downloading to all other folders for example Downloads, Music, but through an error.
unsupported path /storage/emulated/0/VideoDownloader/TikTok/TIKTOKVIDEO .
` const normaldownload = dispatch => async (url, foldername , name_prefix) =>{
let mydirs = RNFetchBlob.fs.dirs.SDCardDir
var date = new Date()
let checkdir = await RNFetchBlob.fs.isDir(`${mydirs}/VideoDownloader/${foldername}`);
if(!checkdir){
RNFetchBlob.fs.mkdir(`${mydirs}/VideoDownloader/${foldername}`).then((res) =>{
console.log('created', res)
}).catch((error) =>{
console.log('Error', error)
})
}else{
console.log("Dir existss")
}
try{
let options = {
fileCache: true,
addAndroidDownloads : {
useDownloadManager :true, // setting it to true will use the device's native download manager and will be shown in the notification bar.
notification : true,
mime : 'video/mp4',
description : 'Downloading Video',
path: mydirs+`/VideoDownloader/${foldername}/${name_prefix}`+Math.floor(date.getTime() + date.getSeconds() / 2) + '.mp4', // this is the path where your downloaded file will live in
}
}
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,{
title: "Storage",
message: "This app would like to store some files on your phone"
}).then( async () => {
RNFetchBlob.config(options).fetch('GET', url).then((res) => {
console.log('path of the downloads ')
ToastAndroid.showWithGravityAndOffset(
`File Saved in VideoDownloader/${foldername}😃 `,
ToastAndroid.LONG,
ToastAndroid.BOTTOM,
25,
50
)
}).catch((error) =>{
console.log(error,'ERRRROR')
ToastAndroid.showWithGravityAndOffset(
`Download Failed`,
ToastAndroid.LONG,
ToastAndroid.BOTTOM,
25,
50
);
})
})
}
catch(error){
console.log("Error in catch " , error)
}
}
`
The above code WOrking fine on android 9 ad less but it through Error on android 10.
I have already added this line.
android:requestLegacyExternalStorage="true"
Still no improvement.
Hi, did you try
appendExt :'mp4'
in options.
same issue any update here?
Same issue in IOS any update? thanks
any update folks? sorry to mention @TheRightGift @aftabaminzoobiapps @momenfnnana @ashirkhan94 🙏