Files
ArtPlayer/packages/artplayer-plugin-danmuku/src/index.js
T
Harvey Zack 7b53de941d V5 (#500)
* update dep

* Update package.json

* update contextmenu

* update d.ts

* update onVttLoad

* build artplayer

* update style

* --art-theme

* update style

* update style

* update user-select

* add getIcon

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* update style

* add progress-hover

* update mini

* update style

* update style

* update style

* update style

* update style

* update volume

* update style

* add art-backdrop

* update style

* update style

* update style

* update currentLevel

* update artplayerPluginControl

* update artplayerPluginDanmuku

* Update package.json
2023-04-16 23:01:26 +08:00

48 lines
1.4 KiB
JavaScript

import Danmuku from './danmuku';
import setting from './setting';
function checkVersion(art) {
const {
version,
utils: { errorHandle },
} = art.constructor;
const arr = version.split('.').map(Number);
const major = arr[0];
const minor = arr[1] / 100;
errorHandle(major + minor >= 5, `Artplayer.js@${version} 不兼容该弹幕库,请更新到 5 版本以上`);
}
export default function artplayerPluginDanmuku(option) {
return (art) => {
checkVersion(art);
const danmuku = new Danmuku(art, option);
setting(art, danmuku);
return {
name: 'artplayerPluginDanmuku',
emit: danmuku.emit.bind(danmuku),
load: danmuku.load.bind(danmuku),
config: danmuku.config.bind(danmuku),
hide: danmuku.hide.bind(danmuku),
show: danmuku.show.bind(danmuku),
reset: danmuku.reset.bind(danmuku),
get option() {
return danmuku.option;
},
get isHide() {
return danmuku.isHide;
},
get isStop() {
return danmuku.isStop;
},
};
};
}
artplayerPluginDanmuku.env = process.env.NODE_ENV;
artplayerPluginDanmuku.version = process.env.APP_VER;
artplayerPluginDanmuku.build = process.env.BUILD_DATE;
if (typeof window !== 'undefined') {
window['artplayerPluginDanmuku'] = artplayerPluginDanmuku;
}