levmyshkin/vidbg
Composer 安装命令:
composer require levmyshkin/vidbg
包简介
An HTML5 video player.
README 文档
README
A minimal vanilla JavaScript video background plugin.
Compatibility
- All modern web browsers
- IE 11+
- All mobile web browsers that support autoplaying HTML5
<video>
Working With Wordpress
If you plan on using vidbg.js with WordPress, make your life a little bit easier and download the plugin I made on the Wordpress Repo.
Usage
Install
npm install vidbg.js
Or download the built vidbg.zip from GitHub
Instructions
In the browser:
<!-- <head> --> <link href="dist/vidbg.css" rel="stylesheet" type="text/css" /> <!-- End of <body> --> <script src="dist/vidbg.js"></script>
Or if you are working with modules:
import vidbg from "vidbg.js";
Initializing the Script
The script accepts three arguments.
var instance = new vidbg(selector, options, attributes);
The selector argument is any JavaScript selector, the options are for configuring vidbg.js, and the attributes argument modifies the actual <video> element.
var instance = new vidbg( ".vidbg-box", { mp4: "http://example.com/video.mp4", // URL or relative path to MP4 video webm: "path/to/video.webm", // URL or relative path to webm video poster: "path/to/fallback.jpg", // URL or relative path to fallback image overlay: false, // Boolean to display the overlay or not overlayColor: "#000", // The overlay color as a HEX overlayAlpha: 0.3, // The overlay alpha. Think of this as the last integer in RGBA() }, { // Attributes } );
Note: Supplying both .mp4 and .webm will increase browser compatibility.
Options
const defaultOptions = { mp4: null, webm: null, poster: null, overlay: false, overlayColor: "#000", overlayAlpha: 0.3, };
Attributes
const defaultAttributes = { autoplay: true, controls: false, loop: true, muted: true, playsInline: true, };
Overlay
Setting the overlay option to true will add an RGBA background over your video. This is helpful when you want to display text or meaningful content over the video background to increase legibility.
Fallback Image Flashing
You may experience the fallback image flash on page load. This is because the fallback image is added through JavaScript. As a result of this, it will load after CSS styles are rendered.
If you'd like to combat this, you can preset the fallback image through CSS. For example, if your selector is .video-box you could do something like:
.video-box .vidbg-container { background-image: url(/assets/link-to-fallback.png); }
Methods
Below are the methods that are available:
// First, create the vidbg.js instance. var instance = new vidbg(".vidbg-box", { mp4: "http://example.com/video.mp4", webm: "path/to/video.webm", poster: "path/to/fallback.jpg", }); // Manually resize the video background instance.resize(); // Manually play the video instance.playVideo(); // Manually pause the video instance.pauseVideo(); // Get the video playing state instance.isVideoPlaying(); // Remove the <video> element instance.removeVideo(); // Completely remove the video background instance.destroy();
Media
Video and fallback image provided by Christophe Tauziet at https://vimeo.com/user27974867
License
vidbg.js is licensed under The MIT License. You can view it here.
levmyshkin/vidbg 适用场景与选型建议
levmyshkin/vidbg 是一款 基于 TypeScript 开发的 Composer 扩展包,目前已累计 68.12k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「HTML5」 「video」 「player」 「video background」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 levmyshkin/vidbg 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 levmyshkin/vidbg 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 levmyshkin/vidbg 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HTML5 support for SilverStripe
A video extension for TYPO3 built on the VideoJS HTML5 video player library. Allows you to embed video in your website using HTML5 with Flash fallback support for non-HTML5 browsers. Work on VideoJS 4.12.6 and support YouTube and Vimeo video in the same style.
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
Display a video using native HTML5 video
统计信息
- 总下载量: 68.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-03