Skip to content

Commit

Permalink
fix: unable to toggle subtitles on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Dec 30, 2022
1 parent 3036844 commit 31b3412
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class DPlayer {
this.volume(this.user.get('volume'), true, true);

if (this.options.subtitle) {
this.subtitle = new Subtitle(this.template.subtitle, this.video, this.plugins.aribb24Caption, this.plugins.aribb24Superimpose, this.options.subtitle, this.events);
this.subtitle = new Subtitle(this.template.subtitle, this.video, this.plugins, this.options.subtitle, this.events);
if (!this.user.get('subtitle')) {
this.subtitle.hide();
}
Expand Down
21 changes: 10 additions & 11 deletions src/js/subtitle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
class Subtitle {
constructor(container, video, aribb24Caption, aribb24Superimpose, options, events) {
constructor(container, video, plugins, options, events) {
this.container = container;
this.video = video;
this.aribb24Caption = aribb24Caption;
this.aribb24Superimpose = aribb24Superimpose;
this.plugins = plugins;
this.options = options;
this.events = events;

Expand Down Expand Up @@ -38,23 +37,23 @@ class Subtitle {
show() {
this.container.classList.remove('dplayer-subtitle-hide');
// for aribb24.js
if (this.options.type === 'aribb24' && this.aribb24Caption) {
this.aribb24Caption.show();
if (this.options.type === 'aribb24' && this.plugins.aribb24Caption) {
this.plugins.aribb24Caption.show();
}
if (this.options.type === 'aribb24' && this.aribb24Superimpose) {
this.aribb24Superimpose.show();
if (this.options.type === 'aribb24' && this.plugins.aribb24Superimpose) {
this.plugins.aribb24Superimpose.show();
}
this.events.trigger('subtitle_show');
}

hide() {
this.container.classList.add('dplayer-subtitle-hide');
// for aribb24.js
if (this.options.type === 'aribb24' && this.aribb24Caption) {
this.aribb24Caption.hide();
if (this.options.type === 'aribb24' && this.plugins.aribb24Caption) {
this.plugins.aribb24Caption.hide();
}
if (this.options.type === 'aribb24' && this.aribb24Superimpose) {
this.aribb24Superimpose.hide();
if (this.options.type === 'aribb24' && this.plugins.aribb24Superimpose) {
this.plugins.aribb24Superimpose.hide();
}
this.events.trigger('subtitle_hide');
}
Expand Down
2 changes: 1 addition & 1 deletion src/template/player.art
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<button class="dplayer-icon dplayer-comment-setting-icon" aria-label="{{ tran('Setting') }}" data-balloon-nofocus data-balloon-pos="up">
<span class="dplayer-icon-content">{{@ icons.pallette }}</span>
</button>
<input class="dplayer-comment-input" type="search" placeholder="{{ tran('Input danmaku, hit Enter') }}" maxlength="60">
<input class="dplayer-comment-input" type="search" placeholder="{{ tran('Input danmaku, hit Enter') }}" spellcheck="false" maxlength="60">
<button class="dplayer-icon dplayer-send-icon" aria-label="{{ tran('Send') }}" data-balloon-nofocus data-balloon-pos="up">
<span class="dplayer-icon-content">{{@ icons.send }}</span>
</button>
Expand Down

0 comments on commit 31b3412

Please sign in to comment.