thelia/video-manager

Video url handling library

1.0.0 2015-01-26 08:38 UTC

This package is auto-updated.

Last update: 2024-04-14 21:38:17 UTC


README

Thelia video manager is PHP >=5.4 library that reads an url and translate it to a usable video player or embed link.

  1. Installation

You can install Thelia video manager with composer:

$ composer require thelia/video-manager ~1.0
  1. Usage

Use Thelia\VideoManger\VideoManger to resolve your url:

<?php

include "vendor/autoload.php";

use Thelia\VideoManager\VideoManager;

$resolver = new VideoManager();

$videoUrl = $resolver->resolve("https://www.youtube.com/watch?v=7GiOIRc-8Q0");
if (null !== $videoUrl) {
    echo $videoUrl->getVideoPlayerWidget() . "\n";
}

$videoUrl = $resolver->resolve("http://www.dailymotion.com/video/x25cki_hello_world");
if (null !== $videoUrl) {
    echo $videoUrl->getVideoPlayerWidget() . "\n";
}

$videoUrl = $resolver->resolve("http://vimeo.com/115794083");
if (null !== $videoUrl) {
    echo $videoUrl->getVideoPlayerWidget() . "\n";
}

Thelia\VideoManger\VideoManger::resolve returns a Thelia\VideoManger\VideoUrl object.

  1. Add your own provider

If you want to use another video service than those already available, you can add yours with the Thelia\VideoManger\ProviderBag::add method.

It must implement Thelia\VideoManger\Provider\ProviderInterface, but there is an abstract class that has some methods to help you: Thelia\VideoManger\Provider\AbstractProvider