mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 22:06:17 -08:00
33 lines
933 B
JavaScript
33 lines
933 B
JavaScript
import ASS from 'assjs';
|
|
import './style.scss';
|
|
|
|
function artplayerPluginAss(url) {
|
|
return (art) => {
|
|
let ass = null;
|
|
fetch(url)
|
|
.then((res) => res.text())
|
|
.then((text) => {
|
|
const { $video, $subtitle } = art.template;
|
|
$subtitle.classList.add('artplayer-plugin-ass');
|
|
|
|
art.once('ready', () => {
|
|
ass = new ASS(text, $video, {
|
|
container: $subtitle,
|
|
resampling: 'video_width',
|
|
});
|
|
|
|
ass.resize();
|
|
art.emit('artplayerPluginAss', ass);
|
|
art.on('resize', () => ass.resize());
|
|
art.on('destroy', () => ass.destroy());
|
|
});
|
|
});
|
|
return {
|
|
name: 'artplayerPluginAss',
|
|
ass,
|
|
};
|
|
};
|
|
}
|
|
|
|
export default artplayerPluginAss;
|