cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject [1/2] spec commit: CB-6051: Test HTML5 video with native URLs
Date Mon, 03 Mar 2014 16:25:32 GMT
Repository: cordova-mobile-spec
Updated Branches:
  refs/heads/master 74de382ad -> f6c9c2cc0


CB-6051: Test HTML5 video with native URLs


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/39f214e9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/39f214e9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/39f214e9

Branch: refs/heads/master
Commit: 39f214e9750dfdd4b124429e27bcbc2419a41a27
Parents: 74de382
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Mar 3 11:23:40 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Mon Mar 3 11:24:18 2014 -0500

----------------------------------------------------------------------
 config.xml      |  1 +
 file/index.html | 45 +++++++++++++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/39f214e9/config.xml
----------------------------------------------------------------------
diff --git a/config.xml b/config.xml
index 80a7dd5..9550311 100644
--- a/config.xml
+++ b/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" />

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/39f214e9/file/index.html
----------------------------------------------------------------------
diff --git a/file/index.html b/file/index.html
index 8b4da1a..be5edaa 100644
--- a/file/index.html
+++ b/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>


Mime
View raw message