]> id.pley.net Git - movie_parser.git/blobdiff - AtomTester.html
Add new atom types: SampleSize, TrackExtends, OriginalFormat, SchemeType, and SchemeInfo.
[movie_parser.git] / AtomTester.html
index d0bcbf133020e5d26f5e630ddd3b8789e1edbbfb..78587ca5ae7d9660dd4cde017e421e910ddadee1 100644 (file)
@@ -3,45 +3,48 @@
     <title>AtomTester</title>
     <script src=Atom.js></script>
     <script>
     <title>AtomTester</title>
     <script src=Atom.js></script>
     <script>
+        // Add Blob.prototype.slice if it does not already exist:
+        if (typeof(Blob.prototype.slice) == 'undefined' && typeof(Blob.prototype.webkitSlice) != 'undefined')
+            Blob.prototype.slice = Blob.prototype.webkitSlice;
+
         var moovAtom;
         function onFileSelect(e) {
             var file = e.target.files[0];
             var reader = new FileReader();
             output.innerHTML = '';
             
         var moovAtom;
         function onFileSelect(e) {
             var file = e.target.files[0];
             var reader = new FileReader();
             output.innerHTML = '';
             
-            function checkForMoovAtom(offset) {
+            function checkForAtom(offset) {
                 reader.onload = function(e) {
                 reader.onload = function(e) {
-                    var result = e.target.result;
-                    var basicAtom = new Atom(result);
-                    if (!basicAtom)
-                        return;
-                    else if (basicAtom.type == 'moov') 
-                        readMoovAtom(offset, basicAtom.size);
-                    else
-                        checkForMoovAtom(offset + basicAtom.size);
+                    var atom = new Atom(e.target.result);
+                    if (atom)
+                        readAtom(offset, atom.size);
                 };
                 };
-                var subset = file.webkitSlice(offset, offset + 16);
+                var subset = file.slice(offset, offset + 16);
                 reader.readAsArrayBuffer(subset);
                 reader.readAsArrayBuffer(subset);
-            };
-            
-            function readMoovAtom(offset, length) {
-                reader.onload = function(e) { 
-                    moovAtom = Atom.create(e.target.result);
+            }
+
+            function readAtom(offset, length) {
+                reader.onload = function(e) {
+                    atom = Atom.create(e.target.result);
+                    if (!atom)
+                        return;
                     var output = document.getElementById('output');
                     var output = document.getElementById('output');
-                    output.appendChild(toDOMNode(moovAtom));
+                    output.appendChild(toDOMNode(atom));
+                    if (file.size > offset + length)
+                        checkForAtom(offset + length);
                 };
                 };
-                var subset = file.webkitSlice(offset, offset + length);
+                var subset = file.slice(offset, offset + length);
                 reader.readAsArrayBuffer(subset);
                 reader.readAsArrayBuffer(subset);
-            };
+            }
             
             
-            checkForMoovAtom(0);
+            checkForAtom(0);
         }
         
         function toDOMRepresentation(object)
         {
             if (object instanceof Atom)
                 return toDOMNode(object);
         }
         
         function toDOMRepresentation(object)
         {
             if (object instanceof Atom)
                 return toDOMNode(object);
-            else if (object instanceof Array) {
+            else if (object instanceof Array || object instanceof Uint32Array)  {
                 var span = document.createElement('span');
                 span.appendChild(document.createTextNode('['));
                 for (var i = 0; i < object.length; ++i) {
                 var span = document.createElement('span');
                 span.appendChild(document.createTextNode('['));
                 for (var i = 0; i < object.length; ++i) {
         function toDOMNode(object)
         {
             var output = document.createElement('dl');
         function toDOMNode(object)
         {
             var output = document.createElement('dl');
+            
+            if (typeof(object.description) == 'string') {
+                var div = document.createElement('div');
+                div.classList.add('description');
+                div.appendChild(document.createTextNode(object.description));
+                output.appendChild(div);
+            }
 
             for (property in object) {
                 var value = object[property];
 
             for (property in object) {
                 var value = object[property];
@@ -70,7 +80,7 @@
                     continue;
                 var div = document.createElement('div');
                 var dt = document.createElement('dt');
                     continue;
                 var div = document.createElement('div');
                 var dt = document.createElement('dt');
-                dt.innerText = property;
+                dt.appendChild(document.createTextNode(property));
                 var dd = document.createElement('dd');
                 dd.appendChild(toDOMRepresentation(value));
                 div.appendChild(dt);
                 var dd = document.createElement('dd');
                 dd.appendChild(toDOMRepresentation(value));
                 div.appendChild(dt);
 
         dt, dd { display: inline-block; min-width: 8em; }
         dd { margin-left: 1em; }
 
         dt, dd { display: inline-block; min-width: 8em; }
         dd { margin-left: 1em; }
+        .description { text-align: center; font-weight: bold; }
         
         /* make the output display as a table */
         /*
         
         /* make the output display as a table */
         /*