waughj / html-video

用于自动生成视频HTML代码的简单类。

v0.2.1 2019-09-10 17:48 UTC

This package is auto-updated.

Last update: 2024-09-11 14:21:58 UTC


README

用于自动生成视频HTML代码的简单类。

使用

此类的构造函数接受两个参数:源属性列表的哈希映射和视频元素本身的属性列表。

对于源的类型属性,您可以省略"video/",构造函数会自动添加。

示例

use WaughJ\HTMLVideo\HTMLVideo;

echo new HTMLVideo
(
    [ [ 'src' => 'video.mp4', 'type' => 'mp4', 'media' => '(max-width:480px)' ], [ 'src' => 'movie.webm', 'type' => 'webm' ] ],
    [ 'muted' => "true", 'controls' => "controls", 'preload' => "none", 'autoplay' => "autoplay", 'width' => "1200", 'height' => "674", 'class' => "center-img" ]
);

将生成

<video muted="true" controls="controls" preload="none" autoplay="autoplay" width="1200" height="674" class="center-img">
    <source src="video.mp4" type="video/mp4" media="(max-width:480px)"></source>
    <source src="movie.webm" type="video/webm"></source>
</video>

变更日志

0.2.1

  • 清理代码并减少冗余

0.2.0

  • 允许为每个源提供更多属性,包括媒体属性

0.1.0

  • 初始发布