Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

/*
       * Chromeless player has no controls.
       */
      
      // Update a particular HTML element with a new value
      function updateHTML(elmId, value) {
        document.getElementById(elmId).innerHTML = value;
      }
      
      // This function is called when an error is thrown by the player
      function onPlayerError(errorCode) {
        alert("An error occured of type:" + errorCode);
      }
      
      // This function is called when the player changes state
      function onPlayerStateChange(newState) {
        updateHTML("playerState", newState);
      }
      

      
      // This function is automatically called by the player once it loads
      function onYouTubePlayerReady(playerId) {
          if(playerId == "ytPlayer1") {
        ytplayer = document.getElementById("ytPlayer");
        // This causes the updatePlayerInfo function to be called every 250ms to
        // get fresh data from the player
        //setInterval(updatePlayerInfo, 250);
        //updatePlayerInfo();
  //      ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
   //     ytplayer.addEventListener("onError", "onPlayerError");
        //Load an initial video into the player
        ytplayer.cueVideoById("dceW9l72mTE");
        }

else  if(playerId == "ytPlayer2") {
        ytplayer = document.getElementById("ytPlayer");
        // This causes the updatePlayerInfo function to be called every 250ms to
        // get fresh data from the player
        //setInterval(updatePlayerInfo, 250);
        //updatePlayerInfo();
//        ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
//        ytplayer.addEventListener("onError", "onPlayerError");
        //Load an initial video into the player
        ytplayer.cueVideoById("ylLzyHk54Z0");
        }
      }
      
      // The "main method" of this sample. Called when someone clicks "Run".
      function loadPlayer() {
        // Lets Flash from another domain call JavaScript
        var params = { allowScriptAccess: "always" };
        // The element id of the Flash embed
        var atts = { id: "ytPlayer" };
        // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
        swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
                           "&enablejsapi=1&playerapiid=ytplayer1",
                           "videoDiv1", "205", "275", "8", null, null, params, atts);

        swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
                           "&enablejsapi=1&playerapiid=ytplayer2",
                           "videoDiv2", "205", "275", "8", null, null, params, atts);

      }
      function _run() {
        loadPlayer();
      }