mirror of
https://github.com/videojs/video.js.git
synced 2025-02-02 11:34:50 +02:00
fix(subs-caps-button): add hide threshold to subs-caps button (#4171)
This is a followup from #4157 but for the subs-caps button.
This commit is contained in:
parent
c611f9f358
commit
88ee6af431
@ -40,33 +40,6 @@ class SubsCapsButton extends TextTrackButton {
|
|||||||
return `vjs-subs-caps-button ${super.buildWrapperCSSClass()}`;
|
return `vjs-subs-caps-button ${super.buildWrapperCSSClass()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update caption menu items
|
|
||||||
*
|
|
||||||
* @param {EventTarget~Event} [event]
|
|
||||||
* The `addtrack` or `removetrack` event that caused this function to be
|
|
||||||
* called.
|
|
||||||
*
|
|
||||||
* @listens TextTrackList#addtrack
|
|
||||||
* @listens TextTrackList#removetrack
|
|
||||||
*/
|
|
||||||
update(event) {
|
|
||||||
let threshold = 2;
|
|
||||||
|
|
||||||
super.update();
|
|
||||||
|
|
||||||
// if native, then threshold is 1 because no settings button
|
|
||||||
if (this.player().tech_ && this.player().tech_.featuresNativeTextTracks) {
|
|
||||||
threshold = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.items && this.items.length > threshold) {
|
|
||||||
this.show();
|
|
||||||
} else {
|
|
||||||
this.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create caption/subtitles menu items
|
* Create caption/subtitles menu items
|
||||||
*
|
*
|
||||||
@ -78,6 +51,8 @@ class SubsCapsButton extends TextTrackButton {
|
|||||||
|
|
||||||
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
|
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
|
||||||
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.label_}));
|
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.label_}));
|
||||||
|
|
||||||
|
this.hideThreshold_ += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
items = super.createItems(items, SubsCapsMenuItem);
|
items = super.createItems(items, SubsCapsMenuItem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user