1
votes

I have an Angular 2 Cordova application that's flushed out for Android now I'm working on iOS conversion.

I have a video component that allows streaming or optionally downloading the video to watch later. I have streaming working using video tag. I got it to work using video src rather then the source child element which didn't work.

<video width="100%" src="https://path/to/source.mp4" controls></video>

For some reason though it won't play local files, either with path type cdv/file. I'm using cordova-plugin-file to store the video file and it's working fine. I navigated to the /Documents folder for the app with a separate tool and found the video was stored correctly and plays fine on my machine.

cdv://
file:///

So really the last step is why the browser isn't playing the file? is it preventing the url? do I need to use a relative path and if so how do I get to /Documents folder? from www/

1

1 Answers

1
votes

I found a solution using cordova.file

If i use

cordova.file.applicationStorageDirectory

I get a path with an ID, which I assume is the application ID. Well what I failed to realize is that every time the application is built using xCode it creates a new ID.

So when I was hardcoding in the file url to the video tag, i was using an old ID. By use the cordova.file path it has the right ID every time and consequently the correct root path.