I am developing ionic 3 app that download videos from server to the device's native storage . i used this URL to save file:
let externalDir = this.file.externalDataDirectory;
file download is fine it is downloaded and i can view it from the device. for more details the file link in the storage is:
/storage/emulated/0/Android/data/xxxxxxxx/files/VideoTest1/0.mp4
but the problem is i want to play that downloaded video into my app using <video>
tag, i used the same link to view it but it doesn't work. any help?
sorry for my english
I've been searching for a solution. I resolve this issue as follows.
After
platform.ready()
function I created a directory as follows.To download videos inside the created directory
That downloads a file inside the created
Videos
folder. You can actually find that on the device by goingAndroid/data/com.your.app/files/
.If you're using
android
and that didn't work, addfile.setReadable(true, false);
insideFileTransfer.java
.To play the videos for offline usage Make sure these lines exist in
index.html
And in your
config.xml
fileIf not add them.
Then finally in your video player page
And in the component
And that's it. I hope that works.
If you want to access any file for native storage of mobile. Then you have to create a local server of the folder you want the access of.
https://ionicframework.com/docs/native/httpd
Now you will able to localserveUrl as src="http://127.0.0.0.1:9000/VideoTest1/0.mp4"
put the code startLocalServe in app.component.ts