Local video files will not play in the Cordova Android application

I am creating an application in Cordoba where the first page of the application contains a video tag set for auto play. I do not get 404 errors when downloading a file ... The file simply will not play. The video is just black with a time of 0:00, which does not change.

It’s strange that I get two network requests in the tools for the remote Chrome video clip for the video file: the first shows status (success), and the second has status (canceled). I tried using two different URLs for the file:

file: ///android_asset/www/video/nameofmyvideo.mp4 with the video file actually located in /www/video/nameofmyvideo.mp4.

and

android.resource: // mypackagename / raw / nameofmyvideo with the video file is actually in / www / res / raw / nameofmyvideo and / platform / android / res / raw / nameofmyvideo

I use the latest Cordova (3.4.1-0.1.0) and test on incendiary fire CM-11 (4.4.2).

Here is the markup that I use:

<video width="400px" height="300px" autoplay controls> <source src="file:///android_asset/www/video/video-test.mp4" type="video/mp4"> </video> 

OR

 <video width="400px" height="300px" autoplay controls> <source src="android.resource://my.package.name/raw/videotest" type="video/mp4"> </video> 

Is this a problem for Android? The app works just as it does on iOS. I also tried using webm, without success.

edit:

It also seems that the problem of dual network downloads (one success, one canceled) occurs regardless of whether the file is actually downloading. I uploaded the same mp4 file via http hosted on my website and the video played normally (but still showed both requests).

+6
source share
3 answers

It is impossible to read the video from the internal resource folder on the Android device, you need to place it somewhere outside the application, SD card or remotely. This is due to the fact that the APK is compressed by the JAR mainly, and the files in the assets must be unpacked in order to work, and Android cannot decompress video files from the APK.

+1
source

There should be autoplay instead of autoplay="" and controls instead of controls="" . And delete px : width="400" height="300"

0
source

Perhaps try adding load to the video tag:

 <video width="400px" height="300px" autoplay controls onklcik="~videoClicked(this)"> <source src="file:///android_asset/www/video/video-test.mp4" type="video/mp4"> </video> //somewhere in your scripts videoClicked function(elem) { $(elem).load(); } 
0
source

All Articles