]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added example.html and removed test/demo.js and demo.html [#313 state:peer-review...
authorAnna Sobiepanek <annaopensource@gmail.com>
Tue, 8 Feb 2011 21:04:07 +0000 (16:04 -0500)
committerAnna Sobiepanek <annaopensource@gmail.com>
Tue, 8 Feb 2011 21:04:07 +0000 (16:04 -0500)
example.html [new file with mode: 0644]
test/demo.html [deleted file]
test/demo.js [deleted file]

diff --git a/example.html b/example.html
new file mode 100644 (file)
index 0000000..ece9839
--- /dev/null
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Popcorn Simple Demo</title>
+  <!-- You muct include the popcorn.js file. Ensure the path is correct -->
+  <script src="popcorn.js"></script>
+ 
+  <!-- You must include each plug-in needed for the demo individually. Ensure the path is correct -->
+  <!-- Footnote Plugin -->
+  <script src="plugins/footnote/popcorn.footnote.js"></script>
+  <!-- Subtitle Plugin -->
+  <script src="plugins/subtitle/popcorn.subtitle.js"></script>
+  
+  <!-- Link popcorn-js to the video by uing the id of the video element -->
+  <!-- You need to tell popcorn when you want each plugin to execute -->
+  <script>
+    // wait for DOM to load
+    document.addEventListener('DOMContentLoaded', function () {
+      // popcorn events are chainable this means that you can also do:
+      // p.play(); or p.footnote{};
+      // Make a popcorn instance
+      var p = Popcorn('#video')
+      // use the footnote plugin
+      // notice the <div id='footnotediv'> tag at the bottom of the page
+      .footnote({
+        start: 0, // seconds
+        end: 15, // seconds
+        text: 'This video made exclusively for drumbeat.org',
+        target: 'footnotediv'
+      } )
+      // use the subtitle plugin
+      .subtitle({
+        start: 1, // seconds
+        end: 15, // seconds
+        text: 'this is the first subtitle of 2011'
+      } )
+      // make the video play right automatically 
+      .play();
+    }, false);
+
+  </script>
+</head>
+<body>
+  <h1 id="qunit-header">Popcorn Simple Demo</h1>
+  <p>You should see a footnote "This video made exclusively for drumbeat.org" appear right away</p>
+  <p>You should see a subtitle "this is the first subtitle of 2011" appear at 1 sec away</p>
+  <div>
+       <!-- You need a video element with an id -->
+    <video id='video' 
+      controls preload='none' 
+      width= '250px'
+      poster="test/poster.png"> 
+      <source id='mp4'
+        src="test/trailer.mp4"
+        type='video/mp4; codecs="avc1, mp4a"'> 
+      <source id='ogv'
+        src="test/trailer.ogv"
+        type='video/ogg; codecs="theora, vorbis"'> 
+      <p>Your user agent does not support the HTML5 Video element.</p> 
+    </video> 
+  </div>
+  <!-- this is needed for the footnote plugin -->
+  <div id="footnotediv"></div>
+</body>
+</html>
diff --git a/test/demo.html b/test/demo.html
deleted file mode 100644 (file)
index ce2b7dd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>Popcorn API Draft DEMO</title>
-  
-  <script src="jquery.js"></script>
-  <script src="../popcorn.js"></script>
-  <script src="demo.js"></script>
-</head>
-<body>
-  <h1 id="qunit-header">Popcorn API Draft</h1>
-  
-  <style>
-    /* test positioning  */
-    
-    video {
-      position: fixed;
-      left: 100px;
-      top: 100px;
-    }
-  
-  </style>
-  
-  <div>
-    <video id='video' 
-      controls preload='none' 
-      poster="http://media.w3.org/2010/05/sintel/poster.png"> 
-
-      <source id='mp4'
-        src="http://media.w3.org/2010/05/sintel/trailer.mp4"
-        type='video/mp4; codecs="avc1, mp4a"'> 
-
-      <source id='ogv'
-        src="http://media.w3.org/2010/05/sintel/trailer.ogv"
-        type='video/ogg; codecs="theora, vorbis"'> 
-
-      <p>Your user agent does not support the HTML5 Video element.</p> 
-
-    </video> 
-  </div>
-</body>
-</html>
diff --git a/test/demo.js b/test/demo.js
deleted file mode 100644 (file)
index c4a5a9b..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-// EXAMPLE PLUGIN: SUBTITLER
-
-(function (Popcorn) {
-  
-  
-  
-  
-  
-  
-  Popcorn.plugin( "complicator", (function () {
-    
-      //create your fucking dom elements here.
-  
-  
-      return {
-
-        start: function () {
-
-        },
-
-        end: function () {
-
-        }, 
-
-        timeupdate: function () {
-
-        }
-      }; 
-
-    
-    })() 
-  );
-  
-  
-  
-  
-  
-  
-  Popcorn.plugin( "subtitler" , function ( options ) {
-    
-    var subtitles = [], 
-        context = this.video, 
-        div = document.getElementById("subtitle-container");
-    
-    //  Check for existing frame
-    if ( !div ) {
-      // if no existing frame, create it.
-      div = document.createElement("div");
-      div.id = "subtitle-container";
-      
-      context.parentNode.appendChild(div);
-      
-      Popcorn.extend(div.style, {
-        //border: "1px solid red",
-        width: context.clientWidth + "px",  //offsetWidth
-        height: context.clientHeight + "px", //offsetHeight
-        top: context.offsetTop + "px", 
-        left: context.offsetLeft + "px",         
-        position: "absolute",
-        color:  "white",
-        textShadow: "black 2px 2px 6px",
-        fontSize: "18px",
-        fontWeight: "bold",
-        textAlign: "center"
-      });
-      
-      
-    }
-    
-    if ( typeof options === "object" && "join" in options ) {
-      subtitles = options;
-    } else {
-      subtitles.push(options);
-    }
-    
-    this.listen("timeupdate", function (event) {
-      
-      Popcorn.forEach(subtitles, function ( subtitle ) {
-        
-        var temp  = div.querySelectorAll( subtitle.id );
-        
-        if ( this.currentTime() >= subtitle.start && !temp.length ) {
-          div.innerHTML = div.innerHTML + subtitle.html;
-        }
-
-        if ( temp.length && this.currentTime() >= subtitle.end ) {
-
-          Popcorn.forEach(temp, function ( title ) {
-            if ( title && title.style ) {
-              title.style.display = "none";
-            }
-            
-          });
-
-        }
-      }, this);
-      
-    });
-  });
-
-})(Popcorn);
-
-
-// END EXAMPLE
-
-
-$(function () {
-
-  var p = Popcorn('#video');
-  
-
-  
-  
-  p.play();  
-  
- 
-  p.subtitler({
-    id: "#subtitle-a", 
-    start: 2, // seconds
-    end: 5, // seconds
-    html: '<p id="subtitle-a">Appear at 2 second mark, dissappear at 5 second mark</p>'
-  });
-  
-  // Butter would generate the data to populate this api function call's argument
-  
-  p.subtitler([
-    {
-      id: "#stays-forever", 
-      start: 5,
-      html: '<p id="stays-forever">Stays forever!</p>'
-    },
-    {
-      id: "#comes-and-goes-1", 
-      start: 10,
-      end: 12,
-      html: '<p id="comes-and-goes-1">Comes and goes</p>'
-    },
-    {
-      id: "#comes-and-goes-2", 
-      start: 12,
-      end: 14,
-      html: '<p id="comes-and-goes-2">BACK! For the second time...</p>'
-    },
-    {
-      id: "#comes-and-goes-3", 
-      start: 14,
-      end: 16,
-      html: '<p id="comes-and-goes-3">This is the last time. I promise.</p>'
-    }
-    
-  ]);
-  
-  
-  
-  
-  p.complicator({
-    start: 1, 
-    end: 10, 
-    wtf: "throws exception?"
-  });
-
-  
-
-
-});