feat(sub): init old subtitle btn only url string

This commit is contained in:
yuusora
2022-01-13 09:24:28 +08:00
parent 0dc16c5360
commit c1159a5448
+19 -16
View File
@@ -28,7 +28,12 @@ class Controller {
this.initFullButton();
this.initQualityButton();
this.initScreenshotButton();
this.initSubtitleButton();
// if subtitle url not array, not init old single subtitle button
if (this.player.options.subtitle) {
if (typeof this.player.options.subtitle.url === 'string') {
this.initSubtitleButton();
}
}
this.initHighlights();
this.initAirplayButton();
if (!utils.isMobile) {
@@ -280,22 +285,20 @@ class Controller {
}
initSubtitleButton() {
if (this.player.options.subtitle) {
this.player.events.on('subtitle_show', () => {
this.player.template.subtitleButton.dataset.balloon = this.player.tran('Hide subtitle');
this.player.template.subtitleButtonInner.style.opacity = '';
this.player.user.set('subtitle', 1);
});
this.player.events.on('subtitle_hide', () => {
this.player.template.subtitleButton.dataset.balloon = this.player.tran('Show subtitle');
this.player.template.subtitleButtonInner.style.opacity = '0.4';
this.player.user.set('subtitle', 0);
});
this.player.events.on('subtitle_show', () => {
this.player.template.subtitleButton.dataset.balloon = this.player.tran('Hide subtitle');
this.player.template.subtitleButtonInner.style.opacity = '';
this.player.user.set('subtitle', 1);
});
this.player.events.on('subtitle_hide', () => {
this.player.template.subtitleButton.dataset.balloon = this.player.tran('Show subtitle');
this.player.template.subtitleButtonInner.style.opacity = '0.4';
this.player.user.set('subtitle', 0);
});
this.player.template.subtitleButton.addEventListener('click', () => {
this.player.subtitle.toggle();
});
}
this.player.template.subtitleButton.addEventListener('click', () => {
this.player.subtitle.toggle();
});
}
setAutoHide() {