
 
        function onYouTubePlayerReady(playerId) {
          ytplayer = document.getElementById("myytplayer");
          ytplayer.addEventListener("onError", "onPlayerError");
        }
 

 
        function onPlayerError(errorCode) {
          alert("An error occured: " + errorCode);
        }
 

 
        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
          if (ytplayer) {
            ytplayer.loadVideoById(id, parseInt(startSeconds));
          }
        }
 

 
        function play() {
          if (ytplayer) {
            ytplayer.playVideo();
          }
        }
 
        function pause() {
          if (ytplayer) {
            ytplayer.pauseVideo();
          }
        }
 
        function stop() {
          if (ytplayer) {
            ytplayer.stopVideo();
          }
        }
 
        function getPlayerState() {
          if (ytplayer) {
            return ytplayer.getPlayerState();
          }
        }
 
        function seekTo(seconds) {
          if (ytplayer) {
            ytplayer.seekTo(seconds, true);
          }
        }
 
        
 
        function mute() {
          if (ytplayer) {
            ytplayer.mute();
          }
        }
 
        function unMute() {
          if (ytplayer) {
            ytplayer.unMute();
          }
        }
        
        
 
 
        
        function setVolume(newVolume) {
          if (ytplayer) {
            ytplayer.setVolume(newVolume);
          }
        }
 
        function getVolume() {
          if (ytplayer) {
            return ytplayer.getVolume();
          }
        }
 
        function clearVideo() {
          if (ytplayer) {
            ytplayer.clearVideo();
          }
        }
