mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:51:20 -08:00
组件添加add方法
This commit is contained in:
1 parent
1d859e2049
commit
2fcd44e8e7
28 files changed
+303
-328
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { setStyles, srtToVtt, vttToBlob, getExt, assToVtt } from './utils';
|
||||
import Component from './utils/components';
|
||||
import Component from './utils/component';
|
||||
|
||||
export default class Subtitle extends Component {
|
||||
constructor(art) {
|
||||
@@ -12,7 +12,17 @@ export default class Subtitle extends Component {
|
||||
} = art;
|
||||
|
||||
setStyles($subtitle, subtitle.style);
|
||||
proxy(this.textTrack, 'cuechange', this.update.bind(this));
|
||||
|
||||
proxy(this.textTrack, 'cuechange', () => {
|
||||
$subtitle.innerHTML = '';
|
||||
if (this.activeCue) {
|
||||
$subtitle.innerHTML = this.activeCue.text
|
||||
.split(/\r?\n/)
|
||||
.map(item => `<p>${item}</p>`)
|
||||
.join('');
|
||||
art.emit('subtitle:update', this.activeCue.text);
|
||||
}
|
||||
});
|
||||
|
||||
if (subtitle.url) {
|
||||
this.init(subtitle.url);
|
||||
@@ -31,18 +41,6 @@ export default class Subtitle extends Component {
|
||||
return this.textTrack.activeCues[0];
|
||||
}
|
||||
|
||||
update() {
|
||||
const { $subtitle } = this.art.template;
|
||||
$subtitle.innerHTML = '';
|
||||
if (this.activeCue) {
|
||||
$subtitle.innerHTML = this.activeCue.text
|
||||
.split(/\r?\n/)
|
||||
.map(item => `<p>${item}</p>`)
|
||||
.join('');
|
||||
this.art.emit('subtitle:update', this.activeCue.text);
|
||||
}
|
||||
}
|
||||
|
||||
switch(url, name = 'unknown') {
|
||||
const { i18n, notice } = this.art;
|
||||
return this.init(url).then(subUrl => {
|
||||
|
||||
Reference in new issue
Block a user