mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
修复字幕插件
This commit is contained in:
1 parent
ee90291897
commit
15f6f2759a
3 files changed
+28
-22
No files matched your search
@@ -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 => {
|
||||
|
||||
Reference in new issue
Block a user