add artplayer-plugin-ass

This commit is contained in:
Harvey committed 2020-11-24 15:48:49 +08:00
1 parent f414b9d9a4
commit d911e206f4
13 files changed
+2357 -4

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
node_modules
.DS_Store
yarn.lock
package-lock.json
test
coverage
.nyc_output
.cache
docs
+1
View File
@@ -0,0 +1 @@
package-lock=false
+47
View File
@@ -0,0 +1,47 @@
# artplayer-plugin-ass
Ass plugin for ArtPlayer, use [weizhenye/ASS](https://github.com/weizhenye/ASS) as a dependency
## Demo
[Checkout the demo](https://artplayer.org/?libs=.%2Funcompiled%2Fartplayer-plugin-ass.js&example=ass) from Github Pages
## Install
Install with `npm`
```bash
$ npm install artplayer-plugin-ass
```
Or install with `yarn`
```bash
$ yarn add artplayer-plugin-ass
```
```js
import artplayerPluginAss from 'artplayer-plugin-ass';
```
Or umd builds are also available
```html
<script src="artplayer-plugin-ass.js"></script>
```
Will expose the global variable to `window.artplayerPluginAss`.
## Usage
```js
var art = new Artplayer({
container: '.artplayer-app',
url: 'path/to/video.mp4',
plugins: [artplayerPluginAss('path/to/subtitle.ass')],
});
```
## License
MIT © [Harvey Zack](https://sleepy.im/)
@@ -0,0 +1,28 @@
{
"name": "artplayer-plugin-ass",
"version": "3.5.24",
"expose": "artplayerPluginAss",
"description": "Ass plugin for ArtPlayer",
"main": "dist/artplayer-plugin-ass.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/zhw2590582/ArtPlayer.git"
},
"keywords": [
"video",
"player"
],
"author": "Harvey Zack <laozhaochaguan@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
},
"homepage": "https://github.com/zhw2590582/ArtPlayer#readme",
"gitHead": "0a3a20568e37f99972eefb01d4b1dcf4036a46db",
"dependencies": {
"assjs": "^0.0.11"
}
}
@@ -0,0 +1,32 @@
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;
@@ -0,0 +1,3 @@
.artplayer-plugin-ass {
bottom: 0 !important;
}