Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
:dart: A web-components html5 video player facing future.
<script src="https://unpkg.com/@webcomponents/webcomponentsjs"></script>
e-player
标签,没错,只需要将平时用的 video
换成 e-player
即可<e-player src="./001.mp4"></e-player>
type 属性可选,默认为 mp4,支持 hls 和 flv
2. 注册 customElement
,注意 type=module
,使用 es6 的 import
<script type="module">
import { Eplayer } from 'https://unpkg.com/eplayer'
//注册 customElement
customElements.define('e-player', Eplayer)
</script>
e-player {
/* 主题色 默认为哔哩哔哩同款蓝*/
--theme: #f13e7b;
/* 进度条底色 一般不用设置 */
--progress: rgba(255, 255, 255, 0.3);
/* 进度条偏移颜色 一般不用设置 */
--buffer: rgba(255, 255, 255, 0.3);
/* 图标颜色 一般不用设置 */
--icons: rgba(255, 255, 255, 0.6);
}
原生支持 mp4
和 mkv
,如果需要支持 m3u8
,需要先引入 hls.js
<script src="https://unpkg.com/hls.js"></script>
yarn add eplayer -S
同样的注册 customElement,但是注意,customElement 只能注册一次,然后还没完,往下看:
vue 默认是不支持 web-components 的,它无法主动判断含有-
的是 vue 组件还是 web 组件
所以需要手动配置,忽略掉e-player
Vue.config.ignoredElements = [
'e-player'
]
然后,同样需要引入上面的几个文件,然后 bind 一下 src 和 type
<e-player :src="url" :type="type"></e-player>
可以封装成 vue 组件来使用:vue-web-components-wrapper
react 直接支持 web-components,直接在 render 函数中e-player
标签
同样的,JSX 并不把它当作 vnode tree 的孩子,需要手动操作 dom
通常为了方便的使用 ref,会封装成 react 组件来使用:
function Eplayer(props) {
return <e-player src={props.src} type={props.type}></e-player>
}
ssr 服务端没有 web-components 的 API,通常 web-components 的 ssr 都会通过一些库去模拟这些 API
eplayer 不推荐这么做,请直接和正常的 html 引入方式一样,引入 cdn
暂时不支持移动端,急需 pr 嘿嘿
FAQs
A web-components html5 video player facing future
The npm package eplayer receives a total of 189 weekly downloads. As such, eplayer popularity was classified as not popular.
We found that eplayer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.