Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CB-6051: Test HTML5 video with native URLs

  • Loading branch information...
commit 39f214e9750dfdd4b124429e27bcbc2419a41a27 1 parent 74de382
@clelland clelland authored
Showing with 34 additions and 12 deletions.
  1. +1 −0  config.xml
  2. +33 −12 file/index.html
View
1  config.xml
@@ -29,6 +29,7 @@
<access origin="http://*.apache.org" />
<access origin="https://*.apache.org" />
<access origin="http://www.google.com" />
+ <access origin="http://techslides.com" />
<access origin="httpssss://example.com" />
<preference name="iosPersistentFileLocation" value="Library" />
View
45 file/index.html
@@ -34,6 +34,9 @@
var deviceReady = false;
+ var imageURL = "http://apache.org/images/feather-small.gif";
+ var videoURL = "http://techslides.com/demos/sample-videos/small.mp4";
+
/**
* Function called when page has finished loading.
*/
@@ -53,6 +56,8 @@
function bindEvents() {
document.getElementById('downloadImgCDV').addEventListener('click', downloadImgCDV, false);
document.getElementById('downloadImgNative').addEventListener('click', downloadImgNative, false);
+ document.getElementById('downloadVideoCDV').addEventListener('click', downloadVideoCDV, false);
+ document.getElementById('downloadVideoNative').addEventListener('click', downloadVideoNative, false);
}
function clearLog() {
@@ -76,31 +81,45 @@
};
}
+ function downloadImgCDV(ev) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ downloadImg(imageURL, function(entry) { return entry.toURL(); }, new Image());
+ }
+
function downloadImgNative(ev) {
ev.preventDefault();
ev.stopPropagation();
- downloadImg(function(entry) { return entry.toNativeURL(); });
+ downloadImg(imageURL, function(entry) { return entry.toNativeURL(); }, new Image);
}
- function downloadImgCDV(ev) {
+ function downloadVideoCDV(ev) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ var videoElement = document.createElement('video');
+ videoElement.controls = "controls";
+ downloadImg(videoURL, function(entry) { return entry.toURL(); }, videoElement);
+ }
+
+ function downloadVideoNative(ev) {
ev.preventDefault();
ev.stopPropagation();
- downloadImg(function(entry) { return entry.toURL(); });
+ var videoElement = document.createElement('video');
+ videoElement.controls = "controls";
+ downloadImg(videoURL, function(entry) { return entry.toNativeURL(); }, videoElement);
}
- function downloadImg(urlFn) {
- var filename = "feather0.gif";
+ function downloadImg(source, urlFn, element) {
+ var filename = source.substring(source.lastIndexOf("/")+1);
function download(fileSystem) {
var ft = new FileTransfer();
- var imageURL = "http://apache.org/images/feather-small.gif";
logMessage("Starting download");
- ft.download(imageURL, fileSystem.root.toURL() + "/" + filename, function(entry) {
+ ft.download(source, fileSystem.root.toURL() + filename, function(entry) {
logMessage("Download complete")
- var imgElement = new Image();
- imgElement.src = urlFn(entry)
- logMessage("Image URL is " + imgElement.src, "green");
- logMessage("Inserting image");
- document.getElementById("output").appendChild(imgElement);
+ element.src = urlFn(entry)
+ logMessage("Src URL is " + element.src, "green");
+ logMessage("Inserting element");
+ document.getElementById("output").appendChild(element);
}, logError("ft.download"));
}
clearLog();
@@ -126,6 +145,8 @@
<h2>File</h2>
<div class="btn large" id="downloadImgCDV">Download and display img (cdvfile)</div>
<div class="btn large" id="downloadImgNative">Download and display img (native)</div>
+ <div class="btn large" id="downloadVideoCDV">Download and play video (cdvfile)</div>
+ <div class="btn large" id="downloadVideoNative">Download and play video (native)</div>
<div id="log"></div>
<div id="output"></div>
Please sign in to comment.
Something went wrong with that request. Please try again.