├── .gitignore ├── LICENSE ├── README.md ├── composer.json └── src ├── Facades └── LaravelVideoEmbed.php ├── Providers └── LaravelVideoEmbedServiceProvider.php └── Services └── LaravelVideoEmbed.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | node_modules/ 3 | .idea/ 4 | composer.lock 5 | .DS_Store 6 | 7 | # Laravel 4 specific 8 | bootstrap/compiled.php 9 | app/storage/ 10 | 11 | # Laravel 5 & Lumen specific 12 | bootstrap/cache/ 13 | .env.*.php 14 | .env.php 15 | .env 16 | 17 | # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer 18 | .rocketeer/ 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 DummyName 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Video Embed 2 | 3 | A simple wrapper for dereuromark/MediaEmbed to generate embed HTML for popular media hosting services. + Thumbnail function based on Joe1992w/laravel-media-embed. 4 | 5 | ## Installation 6 | ```bash 7 | composer require merujan99/laravel-video-embed:dev-master 8 | ``` 9 | 10 | OR 11 | 12 | ```json 13 | "require": { 14 | "merujan99/laravel-video-embed": "dev-master", 15 | }, 16 | ``` 17 | 18 | ```bash 19 | composer install 20 | ``` 21 | 22 | ## Service Provider 23 | ```php 24 | 'providers' => [ 25 | // Others... 26 | Merujan99\LaravelVideoEmbed\Providers\LaravelVideoEmbedServiceProvider::class, 27 | ], 28 | ``` 29 | 30 | ## Facade 31 | ```php 32 | 'aliases' => [ 33 | // Others... 34 | 'LaravelVideoEmbed' => Merujan99\LaravelVideoEmbed\Facades\LaravelVideoEmbed::class, 35 | ], 36 | ``` 37 | ## Publish configuration settings 38 | 39 | After completing the step above, use the following command to publish configuration settings: 40 | 41 | ```php artisan vendor:publish --provider="Merujan99\LaravelVideoEmbed\Providers\LaravelVideoEmbedServiceProvider" ``` 42 | 43 | then just add 44 | 45 | ``` use LaravelVideoEmbed; ``` 46 | 47 | this in your controller 48 | 49 | 50 | ## Usage 51 | 52 | ```php 53 | //URL to be used for embed generation 54 | $url = "https://www.youtube.com/watch?v=8eK-5ivYb3o"; 55 | 56 | //Optional array of website names, if present any websites not in the array will result in false being returned by the parser 57 | $whitelist = ['YouTube', 'Vimeo']; 58 | 59 | //Optional parameters to be appended to embed 60 | $params = [ 61 | 'autoplay' => 1, 62 | 'loop' => 1 63 | ]; 64 | 65 | //Optional attributes for embed container 66 | $attributes = [ 67 | 'type' => null, 68 | 'class' => 'iframe-class', 69 | 'data-html5-parameter' => true 70 | ]; 71 | 72 | return LaravelVideoEmbed::parse($url, $whitelist); 73 | // "" 74 | 75 | return LaravelVideoEmbed::parse($url); 76 | // "" 77 | 78 | return LaravelVideoEmbed::parse($url, ['Vimeo']); 79 | // false 80 | 81 | return LaravelVideoEmbed::parse($url, $whitelist, $params, $attributes) 82 | // 83 | 84 | return LaravelVideoEmbed::getYoutubeThumbnail($url) 85 | //https://. usage: 86 | ``` 87 | 88 | ## Supported Hosts 89 | 90 | Please see [dereuromark/MediaEmbed](https://github.com/dereuromark/MediaEmbed) 91 | 92 | ## Supported Website Whitelist names 93 | Name | 94 | --- | 95 | YouTube | 96 | Facebook | 97 | Dailymotion | 98 | MetaCafe | 99 | Vimeo | 100 | 123video | 101 | 5min Life Videopedia | 102 | AdultSwim | 103 | AniBoom | 104 | AOL Video (Old) | 105 | Aparat | 106 | Archive.org | 107 | Atom | 108 | Blastro | 109 | $2 | 110 | BoFunk | 111 | Break | 112 | Brightcove.com | 113 | CBS News | 114 | Cellfish | 115 | Clarin | 116 | Clip.vn | 117 | ClipFish (Old) | 118 | ClipFish (Special) | 119 | ClipFish (New) | 120 | ClipJunkie | 121 | ClipMoon | 122 | ClipShack | 123 | CNetTV | 124 | CollegeHumor | 125 | TheDailyShow | 126 | ColbertNation | 127 | Crackle | 128 | CrunchyRoll | 129 | Current | 130 | Dailyhaha | 131 | Dave.tv | 132 | DotSub (w/o Captions) | 133 | DoubleViking | 134 | dropshots.com | 135 | Dv.ouou | 136 | Divshare | 137 | EASportsWorld | 138 | EbaumsWorld | 139 | ESPN | 140 | Fandome | 141 | Flickr | 142 | Foxhead | 143 | FunnyOrDie | 144 | FunMansion | 145 | G4TV | 146 | GameKyo | 147 | GameSpot | 148 | GameTrailers (Inc. User Movies) | 149 | Gametube.org | 150 | GameVideos.1up | 151 | GarageTv | 152 | Gloria | 153 | GoEar | 154 | Good.IS | 155 | Glumbert | 156 | GodTube | 157 | GrindTv | 158 | Guzer | 159 | TheHub | 160 | Howcast | 161 | Hulu (Usa Only) | 162 | Humour | 163 | Video.i.ua | 164 | IGN | 165 | iJigg | 166 | IMDB | 167 | ImageShack | 168 | IndyaRocks | 169 | iReport | 170 | Izlesene | 171 | Jamendo | 172 | Jokeroo | 173 | JujuNation Video | 174 | JujuNation Audio | 175 | JustinTV | 176 | Kewego | 177 | Koreus | 178 | Last.fm (Audio) | 179 | Last.fm (Video) | 180 | Libero | 181 | LiveLeak | 182 | LiveVideo | 183 | MSNBC | 184 | Video.mail.ru | 185 | MadnessVideo | 186 | Metatube | 187 | MotionBox | 188 | Mpora | 189 | Mp3tube | 190 | MtvU (Usa Only) | 191 | MP3 Audio | 192 | MyNet | 193 | MyShows.cn/SeeHaha.com | 194 | MySpaceTv | 195 | MyVideo | 196 | MyVi | 197 | M Thai | 198 | NewGrounds | 199 | NhacCuaTui | 200 | OnSmash | 201 | Orb | 202 | Photobucket | 203 | PikNikTube | 204 | Project Playlist | 205 | Putfile | 206 | Rambler | 207 | RawVegas | 208 | RuTube | 209 | Screencast | 210 | ScreenToaster | 211 | SevenLoad | 212 | ShareView | 213 | Sharkle | 214 | Smotri | 215 | Snotr | 216 | SouthPark Studios | 217 | Space.tv.cctv.com | 218 | Spike | 219 | Songza | 220 | Streetfire | 221 | StupidVideos | 222 | TagTélé | 223 | Ted.com | 224 | The Onion | 225 | TinyPic | 226 | Todays Big Thing | 227 | TrailerAddict | 228 | TrTube | 229 | Trilulilu | 230 | Tu.tv | 231 | Tudou | 232 | Tumblr (Music) | 233 | Twitvid | 234 | UOL VideoLog | 235 | u-Tube | 236 | Ustream | 237 | VideoJug | 238 | videos.sapo | 239 | Vidiac | 240 | Viddler | 241 | Videa | 242 | VidiLife | 243 | VidMax | 244 | Vidivodo | 245 | VoiceThread | 246 | WeGame | 247 | Webshots (Slideshows) | 248 | Wistia | 249 | Yahoo Video HK | 250 | Yahoo Video | 251 | Yahoo Music Videos | 252 | YouKu | 253 | sina video | 254 | XVideos | 255 | Local Content | 256 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "merujan99/laravel-video-embed", 3 | "type": "library", 4 | "description": "Laravel Package for dereuromark/MediaEmbed With Thumbnail", 5 | "keywords": ["laravel","package development"], 6 | "minimum-stability": "stable", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Meruzhan Hovhannisyan", 11 | "email": "merujan99@gmail.com" 12 | } 13 | ], 14 | "autoload":{ 15 | "psr-4": { 16 | "Merujan99\\LaravelVideoEmbed\\": "src/" 17 | } 18 | }, 19 | "config": { 20 | "preferred-install": "dist" 21 | }, 22 | "require": { 23 | "dereuromark/media-embed": "^0.3.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Facades/LaravelVideoEmbed.php: -------------------------------------------------------------------------------- 1 | parseUrl($url); 14 | 15 | if ($MediaObject) 16 | { 17 | 18 | if(is_array($params)) 19 | { 20 | $MediaObject->setParam($params); 21 | } 22 | 23 | if(is_array($attributes)) 24 | { 25 | $MediaObject->setAttribute($attributes); 26 | } 27 | 28 | 29 | if (!empty($whitelist)) 30 | { 31 | 32 | if(!in_array($MediaObject->name(), $whitelist)) 33 | { 34 | 35 | return false; 36 | 37 | } 38 | 39 | } 40 | 41 | return $MediaObject; 42 | 43 | } 44 | 45 | return false; 46 | 47 | } 48 | 49 | public function getYoutubeThumbnail($url = null) 50 | { 51 | $MediaEmbed = new MediaEmbed(); 52 | 53 | $MediaObject = $MediaEmbed->parseUrl($url); 54 | 55 | if($MediaObject) 56 | { 57 | return "https://img.youtube.com/vi/{$MediaObject->id()}/maxresdefault.jpg"; 58 | } 59 | 60 | return false; 61 | } 62 | 63 | } 64 | --------------------------------------------------------------------------------