Coder Social home page Coder Social logo

video-embed's Introduction

Video Embed

Simple library that returns embed information for a given video url.

Supported video services: Dailymotion, Facebook, Flickr, Hulu, Kickstarter, The New York Times, Ted, Vimeo, Vine, YouTube.

Build Status Latest Stable Version codecov.io License Codacy Badge

Download and install

  • Install via Composer
composer require ivopetkov/video-embed
  • Download the zip file

Download the latest release from our GitHub page, unzip and include the autoload.php file.

Usage

$videoEmbed = new IvoPetkov\VideoEmbed('https://www.youtube.com/watch?v=Pwe-pA6TaZk');

// IvoPetkov\VideoEmbed Object
// (
//     [url] => https://www.youtube.com/watch?v=Pwe-pA6TaZk
//     [html] => <iframe width="480" height="270" src="https://www.youtube.com/embed/Pwe-pA6TaZk?feature=oembed" frameborder="0" allowfullscreen></iframe>
//     [width] => 480
//     [height] => 270
//     [duration] => 
//     [title] => Where the Hell is Matt? 2012
//     [description] => 
//     [thumbnail] => Array
//         (
//             [url] => https://i.ytimg.com/vi/Pwe-pA6TaZk/hqdefault.jpg
//             [width] => 480
//             [height] => 360
//         )
//     [author] => Array
//         (
//             [name] => Matt Harding
//             [url] => https://www.youtube.com/user/mattharding2718
//         )
//     [provider] => Array
//         (
//             [name] => YouTube
//             [url] => https://www.youtube.com/
//         )
//     [rawResponse] => {"html": "\u003ciframe width=\"480\" height=\"270\" ...
// )

$videoEmbed->setSize(800, 600); // will set a new width and height in the video html code

Documentation

Classes

IvoPetkov\VideoEmbed

Constants

const string VERSION

Properties

public string $url

      The video url

public string $html

      The video html code

public string|int $width

      The video width

public string|int $height

      The video height

public int $duration

      The video duration

public string $title

      The video title

public string $description

      The video description

public array $thumbnail

      An array containing an url and sizes for the video thumbnail image

public array $author

      An array containing the name and the url of the author

public array $provider

      An array containing the name and the url of the provider

public string $rawResponse

      The raw response from the provider embed endpoint

Methods
public __construct ( [ string $url ] )

Creates a new VideoEmbed object and load it if an url is specified

Parameters

      $url

            The video url

Returns

      No value is returned.

public void load ( string $url )

Loads the data for the url specified

Parameters

      $url

            The video url

Returns

      No value is returned

public void setSize ( string|int $width , string|int $height )

Sets new width and height in the video html code

Parameters

      $width

            Thew new width

      $height

            Thew new height

Returns

      No value is returned

License

Video Embed is open-sourced software. It's free to use under the MIT license. See the license file for more information.

Author

This library is created by Ivo Petkov. Feel free to contact me at @IvoPetkovCom or ivopetkov.com.

video-embed's People

Contributors

ivopetkov avatar

Watchers

James Cloos avatar  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.