merujan99 / laravel-video-embed
Laravel Package for dereuromark/MediaEmbed With Thumbnail
Installs: 68 048
Dependents: 0
Suggesters: 0
Security: 0
Stars: 35
Watchers: 6
Forks: 8
Open Issues: 2
Requires
- dereuromark/media-embed: ^0.3.0
This package is not auto-updated.
Last update: 2024-11-15 19:14:06 UTC
README
A simple wrapper for dereuromark/MediaEmbed to generate embed HTML for popular media hosting services. + Thumbnail function based on Joe1992w/laravel-media-embed.
Installation
composer require merujan99/laravel-video-embed:dev-master
OR
"require": { "merujan99/laravel-video-embed": "dev-master", },
composer install
Service Provider
'providers' => [ // Others... Merujan99\LaravelVideoEmbed\Providers\LaravelVideoEmbedServiceProvider::class, ],
Facade
'aliases' => [ // Others... 'LaravelVideoEmbed' => Merujan99\LaravelVideoEmbed\Facades\LaravelVideoEmbed::class, ],
Publish configuration settings
After completing the step above, use the following command to publish configuration settings:
php artisan vendor:publish --provider="Merujan99\LaravelVideoEmbed\Providers\LaravelVideoEmbedServiceProvider"
then just add
use LaravelVideoEmbed;
this in your controller
Usage
//URL to be used for embed generation $url = "https://www.youtube.com/watch?v=8eK-5ivYb3o"; //Optional array of website names, if present any websites not in the array will result in false being returned by the parser $whitelist = ['YouTube', 'Vimeo']; //Optional parameters to be appended to embed $params = [ 'autoplay' => 1, 'loop' => 1 ]; //Optional attributes for embed container $attributes = [ 'type' => null, 'class' => 'iframe-class', 'data-html5-parameter' => true ]; return LaravelVideoEmbed::parse($url, $whitelist); // "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>" return LaravelVideoEmbed::parse($url); // "<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent" type="text/html" width="480" height="295" frameborder="0" allowfullscreen></iframe>" return LaravelVideoEmbed::parse($url, ['Vimeo']); // false return LaravelVideoEmbed::parse($url, $whitelist, $params, $attributes) //<iframe src="https://www.youtube.com/embed/8eK-5ivYb3o?wmode=transparent&autoplay=1&loop=1" type="" width="480" height="295" frameborder="0" allowfullscreen class="iframe-class" data-html5-parameter></iframe> return LaravelVideoEmbed::getYoutubeThumbnail($url) //https://<youtube image thumbnail with max resolution>. usage: <img src="{{ LaravelVideoEmbed::getYoutubeThumbnail($url) }}">
Supported Hosts
Please see dereuromark/MediaEmbed