WBCE CMS Forum

WBCE CMS – Way Better Content Editing.

You are not logged in.

#1 14.03.2017 21:40:22

berny
Member

youtube player 2.0 BETA

so, youtube Player version 2, mit i-Frame API, mal zum testen...

/*
 * usage: [[youtube2?id=video-id&params1=value1&pram2=value2&.....]]
 * 
 * Parameter
 * 
 * $id // youtube-id // necesary !!!
 * $width // width // width of youtube-player
 * $height // height // height of youtube player
 * 
 * $autoplay // 0|1 // autoplay no or yes
 * $rel // 0|1 // 1 = play related video after end 
 * $showinfo // 0|1 // 1 = show infos about uploader, title and so on
 * $start // seconds // int in seconds, when player starts video
 * $end // seconds // int in seconds, when player ist stoped
 * 
 * $cc_load_policy // 1 // Play subtitle
 * $color // red|white // color of progress bar
 * $controls // 0|1|2 // 0 = non control Bar, 1 = load control and player imitadly, 2 = load control, load player at click
 * $disablekb // 0|1 // if 0, keyboard assist for player will be loaded
 * $enablejsapi // 0|1 // if 1, javascript api will be laoded
 * $origin // url // put in your domain if eneablejsapi is 1
 * 
 * 
 * $fs // 0|1 // 1 enables fullscreen button
 * $hl // iso Code // language for player
 * $iv_load_policy // 1|3 // 3 = don't play video comments
 * $loop // 0|1 // 1 = loop video
 * $modestbranding // 1 // deactivate youtube branding in player
 * 
 * by Berny Stummer
 * 
 */

$width = isset($width) ? $width : 640;
$height = isset($height) ? $height : 360;


$content = "";

$content .= "<div id=\"ytplayer\"></div>

<script>
  
  var tag = document.createElement('script');
  tag.src = \"https://www.youtube.com/player_api\";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  
  var player;
  function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', {
      height: '".$height."',
      width: '".$width."', 
";

$content .= isset($autoplay)? "      autoplay: '".$autoplay."', \n" : "";
$content .= isset($rel)? "      rel: '".$rel."', \n" : "";
$content .= isset($showinfo)? "      showinfo: '".$showinfo."', \n" : "";
$content .= isset($start)? "      start: '".$start."', \n" : "";
$content .= isset($end)? "      end: '".$end."', \n" : "";
$content .= isset($cc_load_policy)? "      cc_load_policy: '".$cc_load_policy."', \n" : "";
$content .= isset($color)? "      color: '".$color."', \n" : "";
$content .= isset($controls)? "      controls: '".$controls."', \n" : "";
$content .= isset($disablekb)? "      disablekb: '".$disablekb."', \n" : "";
$content .= isset($enablejsapi)? "      enablejsapi: '".$enablejsapi."', \n" : "";
$content .= isset($origin)? "      origin: '".$origin."', \n" : "";
$content .= isset($fs)? "      fs: '".$fs."', \n" : "";
$content .= isset($hl)? "      autoplay: '".$autoplay."', \n" : "";
$content .= isset($iv_load_policy)? "      iv_load_policy: '".$iv_load_policy."', \n" : "";
$content .= isset($loop)? "      loop: '".$loop."', \n" : "";
$content .= isset($modestbranding)? "      modestbranding: '".$modestbranding."', \n" : "";




$content .= "      videoId: '".$id."'
    });
  }
</script>";

return $content;

Ev kann ja einiges noch verbessert werden.

Zum Testen:
[[youtube2?id=zHUXSEdFOIg&height=768&width=1024&autoplay=1&color=white]]

wobei das white zB nicht geht, obwohl das branding aktiviert ist.
Ich vermute, dass es noch Änderungen bei den Parametern gab....

Last edited by berny (14.03.2017 22:13:56)

Offline

Board footer

Powered by FluxBB

up