//再生
function playVideo(playerId) {
  if (document.getElementById(playerId)) {
    document.getElementById(playerId).playVideo();
  }
}
//一時停止
function pauseVideo(playerId) {
  if (document.getElementById(playerId)) {
    document.getElementById(playerId).pauseVideo();
  }
}
//ミュート
function muteVideo(playerId) {
  if(document.getElementById(playerId)) {
    document.getElementById(playerId).mute();
  }
}
//ミュート解除
function unMuteVideo(playerId) {
  if(document.getElementById(playerId)) {
    document.getElementById(playerId).unMute();
  }
}


function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById(playerId);
  ytplayer.cueVideoById(playerId); //YouTubeの動画ID
  ytplayer.setVolume('100'); //音量の初期値
  //playVideo(playerId); //自動再生
}

function loadPlayer(vid, divname) {
  //<param>の設定　name:"value"
  var params = { allowScriptAccess: "always", wmode: "transparent" };
  //<object>のIDとnameの設定　id:"hoge", name:"hoge"
  var atts = { id: vid };
  //objectの生成　
  /*********************
  //1.swf URI 
  //2．HTML内のID
  //3.width
  //4.height
  //5.player var.
  //6.expressInstall.swf URI
  //7.flashvars object
  //8.param object
  //9.attribute
  *********************/
  swfobject.embedSWF("http://www.youtube.com/apiplayer?" +
                     "&enablejsapi=1&playerapiid=" + vid + "&wmode=transparent",
                     divname, "400", "400", "8", null, null, params, atts);
}


//window.onload = loadPlayer();



/************************************************************************************
//YouTubeAPIプレイヤーURLのplayerapiidの値は、onYouTubePlayerReady()の引数で利用できる
//vid = playerId = <object>のID = Youtube動画ID
************************************************************************************/
