I have tried for days now to play a local video file on my galaxy tab 4.2 through a cordova 3.4 app.
When i use an absolute http url the video plays just fine.
Here is what i have tried:
I put the video file in the assets/res/raw folder as suggested here: Loading video failed on html5 phonegap
RESULT: After i click on play -> spinning loading icon no video
- Video in the www folder:
Result: Same as #1
<video id="myvideo" controls="controls" width="400">
<source src="file:///android_asset/www/gruppenruf.mp4" />
</video>
Result: Same as #1
I set all the permissions of the folders to 777
Then i tried with the https://github.com/jaeger25/Html5Video plugin
After installing the plugin all i get is: 03-06 18:27:06.953: E/Web Console(22530): Uncaught TypeError: Cannot read property 'html5Video' of undefined:37
All i am trying to do is play a local video file on android. Is this really that complicated?
any help would be appreciated.
As I spend some time with a similar issue, I feel its worth sharing:
Cheers
Take a look at this post. The File plugin (at least <=v1.3.1) has a bug for android devices. Also, I am not sure if jaeger25/Html5Video plugin is still working with cordova 3.6.x.
A working approach is to programmatically copy your video files from
www/gruppenruf.mp4
to a place accessible for playback by the app during runtime. You may usefile:///data/data/com.example.MyPackage/files/gruppenruf.mp4
for that. The FileTransfer cordova plugin will take care of this.If it does not play you may want to link a click event listener to it or start the video with
vid.play();
.If the mentioned options are not working try:
src="android.resource://com.example.hello/raw/Videofile" (leave the extension ".mp4" what so ever)
place your video files in "..\platforms\android\res\raw" note that you don't use the extension of the video file in the src.
I've struggled a lot with this issue, but this worked for me =]
Your code stopped working in Cordova 3.4.0 because they changed the file path structure. Instead of 'file:///' you have to use 'cdvfile://'.
Remember to update the File Plugin as well.