Git Product home page Git Product logo

youtubeplayerphp's Introduction

YoutubePlayerPHP Build Status

It's allow you to create a youtube player and render it.

How to use

Create a youtube player

<?php
$youtubePlayer = new YoutubePlayer();

Customize the youtube player

<?php
$youtubePlayer->setVideoId('IUGzY-ihqWc');
$youtubePlayer->setHtmlContainerId('player');
$youtubePlayer->setWidth(800);
$youtubePlayer->setHeight(600);

You can also customize the youtube player in constructor

<?php
$youtubePlayer = new YoutubePlayer('u1zgFlCw8Aw', 800, 600, 'player');

By default if you call a the YoutubePlayer constructor without args, container id is 'player' width is set to 640 and height to 390.

It's ready to use

<?php
$youtubePlayer->renderContainer();
$youtubePlayer->renderJavaScript();

Those methods generate the html and the javascript to render the youtube player.

It's generate

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

    function onYouTubePlayerAPIReady()
    {
        var player;
        player = new YT.Player("player", {
            width:   640,
            height:  390,
            videoId: "IUGzY-ihqWc",
        });
     }
</script>

#### Add some options

<?php
$youtubePlayer->setPlayerVar('autohide', 1);
$youtubePlayer->setPlayerVars(array(
    'controls' => 1,
    'autoplay' => 1,
    'loop'     => 0,
    'theme'    => 'light',
));

For all options see the official doc

youtubeplayerphp's People

Contributors

blazarecki avatar

Stargazers

 avatar Dinesh Kesarwani avatar Ricardo Luz avatar  avatar Jordan Lyall avatar  avatar Amine EL G avatar

Watchers

James Cloos avatar Jordan Lyall avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.