修复字幕插件

This commit is contained in:
Harvey committed 2019-11-22 17:37:53 +08:00
1 parent ee90291897
commit 15f6f2759a
3 files changed
+28 -22

No files matched your search

+13 -11
View File
@@ -12,17 +12,7 @@ export default class Subtitle extends Component {
} = art;
setStyles($subtitle, subtitle.style);
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);
}
});
proxy(this.textTrack, 'cuechange', this.update.bind(this));
if (subtitle.url) {
this.init(subtitle.url);
@@ -41,6 +31,18 @@ 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 => {