justijndepover/embed-video 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

justijndepover/embed-video

最新稳定版本:1.0.6

Composer 安装命令:

composer require justijndepover/embed-video

包简介

Extract the embed url from Youtube and Vimeo videos

README 文档

README

Latest Version on Packagist Software License Build Status Total Downloads

This package makes it easier to work with both Youtube and Vimeo video url's. It automatically detects the reference from the url.

For example:

https://www.youtube.com/watch?v=dQw4w9WgXcQ
https://youtu.be/dQw4w9WgXcQ
https://www.youtube.com/embed/dQw4w9WgXcQ

are all valid youtube links, but to embed an iFrame, you need the third option.

This package allows all the options as input, and is able to generate the correct output urls to embed the iframe.

Installation

You can install the package with composer

composer require justijndepover/embed-video

Usage

use Justijndepover\EmbedVideo\Video;

$video = Video::from('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

If you provide the class with a faulty link, a Justijndepover\EmbedVideo\VideoException will be thrown.

Validate

$validated = Video::validate('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

This will validate the given url and return either true or false

Embed

$html = $video->embed();

This will generate the embedded iframe for either Youtube or Vimeo.

<iframe type="text/html" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0&rel=0" frameborder="0"></iframe>

Embed url

$url = $video->embedUrl();

This will generate the embedded url used in the iframe for either Youtube or Vimeo.

https://www.youtube.com/embed/dQw4w9WgXcQ

Thumbnail

$thumbnail = $video->thumbnail();

This will generate a thumbnail url for the cover image;

http://img.youtube.com/vi/dQw4w9WgXcQ/0.jpg

Reference

$reference = $video->reference();

This will return the video reference;

dQw4w9WgXcQ

Mute

To add mute to the embed iframe, you can make use of the fluent syntax:

$html = $video->muted()->embed();
<iframe type="text/html" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0&mute=1&rel=0" frameborder="0"></iframe>

Autoplay

To add autoplay to the embed iframe, you can make use of the fluent syntax:

$html = $video->autoplay()->embed();
<iframe type="text/html" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&mute=1&rel=0" frameborder="0"></iframe>

note: adding autoplay will automatically mute the video.

Class

To add a class to the embed iframe, you can make use of the fluent syntax:

$html = $video->class('video-container')->embed();
<iframe class="video-container" type="text/html" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0&mute=0&rel=0" frameborder="0"></iframe>

Additional attributes

To add additional attributes to the embed iframe, you can make use of the fluent syntax:

$html = $video->addAttribute('width', 'auto')->embed();
<iframe type="text/html" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=0&mute=0&rel=0" frameborder="0" width="auto"></iframe>

Security

If you find any security related issues, please open an issue or contact me directly at justijndepover@gmail.com.

Contribution

If you wish to make any changes or improvements to the package, feel free to make a pull request.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固