找了一阵,发现一个比较好用的npm包 npm地址
下载
npm install --save videojs-dynamic-watermark
main.js 中引入
import 'videojs-dynamic-watermark'
使用
var player = videojs("my-video");
player.dynamicWatermark({
elementId: "unique_id",
watermarkText: "It will be displayed over video",
changeDuration: 1000,
cssText:
"display: inline-block; color: grey; background-color: transparent; font-size: 1rem; z-index: 9999; position: absolute; @media only screen and (max-width: 992px){font-size: 0.8rem;}",
});