ivopetkov/video-embed

视频嵌入库

v0.4.4 2024-01-08 16:15 UTC

This package is auto-updated.

Last update: 2024-09-18 23:11:29 UTC


README

这是一个简单的库,它返回给定视频URL的嵌入信息。

支持的视频服务:Dailymotion、Facebook、Flickr、Hulu、Kickstarter、纽约时报、Ted、Vimeo、Vine、YouTube。

Build Status Latest Stable Version codecov.io License Codacy Badge

下载和安装

  • 通过Composer安装
composer require ivopetkov/video-embed
  • 下载zip文件

从我们的GitHub页面下载最新版本,解压并包含autoload.php文件。

用法

$videoEmbed = new IvoPetkov\VideoEmbed('https://www.youtube.com/watch?v=Pwe-pA6TaZk');

// IvoPetkov\VideoEmbed Object
// (
//     [url] => https://www.youtube.com/watch?v=Pwe-pA6TaZk
//     [html] => <iframe width="480" height="270" src="https://www.youtube.com/embed/Pwe-pA6TaZk?feature=oembed" frameborder="0" allowfullscreen></iframe>
//     [width] => 480
//     [height] => 270
//     [duration] => 
//     [title] => Where the Hell is Matt? 2012
//     [description] => 
//     [thumbnail] => Array
//         (
//             [url] => https://i.ytimg.com/vi/Pwe-pA6TaZk/hqdefault.jpg
//             [width] => 480
//             [height] => 360
//         )
//     [author] => Array
//         (
//             [name] => Matt Harding
//             [url] => https://www.youtube.com/user/mattharding2718
//         )
//     [provider] => Array
//         (
//             [name] => YouTube
//             [url] => https://www.youtube.com/
//         )
//     [rawResponse] => {"html": "\u003ciframe width=\"480\" height=\"270\" ...
// )

$videoEmbed->setSize(800, 600); // will set a new width and height in the video html code

文档

IvoPetkov\VideoEmbed

常量

const string VERSION

属性

public string $url

      视频URL

public string $html

      视频HTML代码

public string|int $width

      视频宽度

public string|int $height

      视频高度

public int $duration

      视频时长

public string $title

      视频标题

public string $description

      视频描述

public array $thumbnail

      包含视频缩略图图像的URL和尺寸的数组

public array $author

      包含作者名称和URL的数组

public array $provider

      包含提供者名称和URL的数组

public string $rawResponse

      提供者嵌入端点的原始响应

方法
public __construct ( [ string $url ] )

创建一个新的VideoEmbed对象并在指定URL的情况下加载它

参数

      $url

            视频URL

返回

      没有返回值。

public void load ( string $url )

加载指定URL的数据

参数

      $url

            视频URL

返回

      没有返回值

public void setSize ( string|int $width , string|int $height )

设置视频HTML代码中的新宽度和高度

参数

      $width

            新的宽度

      $height

            新的高度

返回

      没有返回值

许可证

Video Embed是开源软件。在MIT许可证下免费使用。有关更多信息,请参阅许可证文件

作者

此库由Ivo Petkov创建。您可以通过@IvoPetkovComivopetkov.com与我联系。