This plugin enables the use of normal HTML5 tags for local video - otherwise not functional in Cordova for Android. If you are looking to simply play videos in full screen started by JS, try the VideoPlayer plugin for Phonegap
Android Webview (which Cordova is based upon) limits access to local files (such as videos) and prohibits reading them, both via relative files and
file:/// URIs. Cordova Html5Video Plugin solves this by giving each of you video a
android.resource:// path and updating your
<video> tags accordingly.
For Android only. Tested on Android API 15-19.
For API >= 19, a workaround is employed to copy the video files over to your application's data directory, as world-readable.
WARNING: this is potentially insecure - other apps will be able to read your videos! However it is the only way to get around Chrome's strict limitations on content:// URLs. See Issue #20 for details.
cordova plugin add https://github.com/jaeger25/Html5Video.git
For more help on installing Cordova plugins, please read the official documentation
Create any video tags withing your html pages as normal, but:
<video id="myvideo" loop></video>
The next changes should be done inside your ProjectName/platforms/android folder
Android Webview disables video for none-hardware accelerated applications. Thus, make sure your manifest tag in AndroidManifest.xml contains:
Consult the official Android documentation if you require more help. This is enabled by default in newer versions of cordova.
Create a folder called raw inside the res folder (
$PROJECT_ROOT/platforms/android/res/raw) where you place your videos. Due to limitations in how Android uses the res folder, make sure:
video.highres.mp4the same file
If your file doesn't meet the above requirements
cordova build will fail to compile your application.
After deviceReady callback from Cordova, initialize your videos with:
Anytime you wish to play a video, call:
Where callback is optional and is triggered when the video is finished (at the end)
Play video1 with no callback:
Play video1 and call function finished:
Play video1 with anonymous function: