fg / multiplayer
Builds customizable video embed codes from any URL.
Installs: 6 471
Dependents: 1
Suggesters: 0
Security: 0
Stars: 44
Watchers: 9
Forks: 4
Open Issues: 1
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-11-13 22:44:06 UTC
README
A tiny library to build nice HTML embed codes for videos.
composer require fg/multiplayer
Example
$Multiplayer = new Multiplayer\Multiplayer(); $options = array( 'autoPlay' => true, 'foregroundColor' => 'BADA55' ); echo $Multiplayer->html('http://www.dailymotion.com/video/xzn5qk', $options); echo $Multiplayer->html('http://vimeo.com/47457051', $options); echo $Multiplayer->html('http://www.youtube.com/watch?v=3qSMS4c5WAk', $options);
This code would produce:
<iframe src="http://www.dailymotion.com/embed/video/xzn5qk?autoplay=1&foreground=#BADA55" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <iframe src="http://player.vimeo.com/video/47457051?autoplay=1&color=BADA55" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <iframe src="http://www.youtube-nocookie.com/embed/3qSMS4c5WAk?autoplay=1" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
Templating
You can customize the generated HTML code by passing a templating function:
echo $Multiplayer->html($url, $options, function($playerUrl) { return '<iframe src="' . $playerUrl . '" class="video-player">' });
A default one can also be set on instanciation:
new Multiplayer\Multiplayer($services, function($playerUrl) { return '<iframe src="' . $playerUrl . '" class="video-player">' });