]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
added translation and made it update real time
authorScottDowne <sdowne@learn.senecac.on.ca>
Thu, 24 Jun 2010 19:48:15 +0000 (15:48 -0400)
committerScottDowne <sdowne@learn.senecac.on.ca>
Thu, 24 Jun 2010 19:48:15 +0000 (15:48 -0400)
index.html
popcorn.js

index 7c2167e70747c339742ea4a92908092d617a2a6d..9c7fd9bd947ad3cd50f8cdcab3b2badf857a9499 100644 (file)
@@ -3,6 +3,8 @@
     <title>html5 video demo</title>    
     <script src="popcorn.js"></script>
     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+    <script src="http://google.com/jsapi"></script>
+    <script>google.load("language","1");</script>
     <style type="text/css" media="screen"> 
       body { 
         background-color:#eee; 
   </head> 
   <body> 
     <div id="container">
-      <video src="http://a52.video2.blip.tv/7320003802153/Etherworks-WebMadeMovies3BuildingABetterInternet799.ogg" data-timeline-sources="xml/webMadeMovies.xml" controls></video>
+      <video src="../webMadeMovies.ogg" data-timeline-sources="xml/webMadeMovies.xml" controls></video>
+      <select id="language">
+        <option val="en">English</option>
+        <option val="es">Spanish</option>
+        <option val="fr">French</option>
+        <option val="de">German</option>
+        <option val="ja">Japanese</option>
+        <option val="zh">Chinese</option>
+      </select>
       <div id="sub"></div><br />
       <div id="tagthisvideo">In this video:<span id="inthisvideo"></span></div><br />
       <div id="map"></div>
index 282b1c9f4e1c89fd7bebc5fb8265254043018b6b..ba1c1b2352406e463f25ae62bd48f435a7304f27 100644 (file)
   var SubtitleCommand = function(name, params, text) {
     VideoCommand.call(this, name, params, text);
     this.onIn = function() {
-      document.getElementById("sub").innerHTML  = this.text;
+      var i = document.getElementById("language").selectedIndex;
+      google.language.translate(this.text, '', document.getElementById("language").options[i].getAttribute("val"), function(result) {
+        document.getElementById("sub").innerHTML  = result.translation;
+      });
+      
     };
     this.onOut = function() {
       document.getElementById("sub").innerHTML  = "";