Skip to content

Commit 20865e8

Browse files
author
terrill
committed
Don't show captions or transcript preferences if not applicable
1 parent a761a63 commit 20865e8

6 files changed

Lines changed: 210 additions & 123 deletions

File tree

‎build/ableplayer.dist.js‎

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,18 @@ var AblePlayerInstances = [];
15811581
// in the Preferences popup menu
15821582
// Human-readable label for each group is defined in translation table
15831583
if (this.mediaType === 'video') {
1584-
return ['captions','descriptions','keyboard','transcript'];
1584+
if (this.usingYouTubeCaptions) {
1585+
// no transcript is possible
1586+
return ['captions','descriptions','keyboard'];
1587+
}
1588+
else if (this.usingVimeoCaptions) {
1589+
// users cannot control caption appearance
1590+
// and no transcript is possible
1591+
return ['descriptions','keyboard'];
1592+
}
1593+
else {
1594+
return ['captions','descriptions','keyboard','transcript'];
1595+
}
15851596
}
15861597
else if (this.mediaType === 'audio') {
15871598
var groups = [];
@@ -1648,56 +1659,68 @@ var AblePlayerInstances = [];
16481659
if (this.mediaType === 'video') {
16491660

16501661
// Caption preferences
1662+
16511663
prefs.push({
16521664
'name': 'prefCaptions', // closed captions default state
16531665
'label': null,
16541666
'group': 'captions',
16551667
'default': 1
16561668
});
1657-
/* // not supported yet
1658-
prefs.push({
1659-
'name': 'prefCaptionsStyle',
1660-
'label': this.tt.prefCaptionsStyle,
1661-
'group': 'captions',
1662-
'default': this.tt.captionsStylePopOn
1663-
});
1664-
*/
1665-
prefs.push({
1666-
'name': 'prefCaptionsPosition',
1667-
'label': this.tt.prefCaptionsPosition,
1668-
'group': 'captions',
1669-
'default': this.defaultCaptionsPosition
1670-
});
1671-
prefs.push({
1672-
'name': 'prefCaptionsFont',
1673-
'label': this.tt.prefCaptionsFont,
1674-
'group': 'captions',
1675-
'default': 'sans-serif'
1676-
});
1669+
1670+
if (!this.usingYouTubeCaptions) {
1671+
1672+
/* // not supported yet
1673+
prefs.push({
1674+
'name': 'prefCaptionsStyle',
1675+
'label': this.tt.prefCaptionsStyle,
1676+
'group': 'captions',
1677+
'default': this.tt.captionsStylePopOn
1678+
});
1679+
*/
1680+
prefs.push({
1681+
'name': 'prefCaptionsPosition',
1682+
'label': this.tt.prefCaptionsPosition,
1683+
'group': 'captions',
1684+
'default': this.defaultCaptionsPosition
1685+
});
1686+
1687+
prefs.push({
1688+
'name': 'prefCaptionsFont',
1689+
'label': this.tt.prefCaptionsFont,
1690+
'group': 'captions',
1691+
'default': 'sans-serif'
1692+
});
1693+
}
1694+
1695+
// This is the one option that is supported by YouTube IFrame API
16771696
prefs.push({
16781697
'name': 'prefCaptionsSize',
16791698
'label': this.tt.prefCaptionsSize,
16801699
'group': 'captions',
16811700
'default': '100%'
16821701
});
1683-
prefs.push({
1684-
'name': 'prefCaptionsColor',
1685-
'label': this.tt.prefCaptionsColor,
1686-
'group': 'captions',
1687-
'default': 'white'
1688-
});
1689-
prefs.push({
1690-
'name': 'prefCaptionsBGColor',
1691-
'label': this.tt.prefCaptionsBGColor,
1692-
'group': 'captions',
1693-
'default': 'black'
1694-
});
1695-
prefs.push({
1696-
'name': 'prefCaptionsOpacity',
1697-
'label': this.tt.prefCaptionsOpacity,
1698-
'group': 'captions',
1699-
'default': '100%'
1700-
});
1702+
1703+
if (!this.usingYouTubeCaptions) {
1704+
1705+
prefs.push({
1706+
'name': 'prefCaptionsColor',
1707+
'label': this.tt.prefCaptionsColor,
1708+
'group': 'captions',
1709+
'default': 'white'
1710+
});
1711+
prefs.push({
1712+
'name': 'prefCaptionsBGColor',
1713+
'label': this.tt.prefCaptionsBGColor,
1714+
'group': 'captions',
1715+
'default': 'black'
1716+
});
1717+
prefs.push({
1718+
'name': 'prefCaptionsOpacity',
1719+
'label': this.tt.prefCaptionsOpacity,
1720+
'group': 'captions',
1721+
'default': '100%'
1722+
});
1723+
}
17011724

17021725
// Description preferences
17031726
prefs.push({
@@ -2100,7 +2123,8 @@ var AblePlayerInstances = [];
21002123

21012124
if (form === 'captions') {
21022125
// add a sample closed caption div to prefs dialog
2103-
if (this.mediaType === 'video') {
2126+
// do not show this for YouTube captions, since it's not an accurate reflection
2127+
if (this.mediaType === 'video' && !this.usingYouTubeCaptions) {
21042128
this.$sampleCapsDiv = $('<div>',{
21052129
'class': 'able-captions-sample'
21062130
}).text(this.tt.sampleCaptionText);
@@ -5994,6 +6018,11 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
59946018
thisObj.youTubePlayer.setOption('captions', 'track', {'languageCode': thisObj.captionLangPending});
59956019
thisObj.captionLangPending = null;
59966020
}
6021+
if (typeof thisObj.prefCaptionsSize !== 'undefined') {
6022+
// set the default caption size
6023+
// this doesn't work until the captions module is loaded
6024+
thisObj.youTubePlayer.setOption('captions','fontSize',thisObj.translatePrefs('size',thisObj.prefCaptionsSize,'youtube'));
6025+
}
59976026
deferred.resolve();
59986027
});
59996028
// Trigger the above event listener by briefly playing the video

‎build/ableplayer.js‎

Lines changed: 69 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,18 @@ var AblePlayerInstances = [];
15811581
// in the Preferences popup menu
15821582
// Human-readable label for each group is defined in translation table
15831583
if (this.mediaType === 'video') {
1584-
return ['captions','descriptions','keyboard','transcript'];
1584+
if (this.usingYouTubeCaptions) {
1585+
// no transcript is possible
1586+
return ['captions','descriptions','keyboard'];
1587+
}
1588+
else if (this.usingVimeoCaptions) {
1589+
// users cannot control caption appearance
1590+
// and no transcript is possible
1591+
return ['descriptions','keyboard'];
1592+
}
1593+
else {
1594+
return ['captions','descriptions','keyboard','transcript'];
1595+
}
15851596
}
15861597
else if (this.mediaType === 'audio') {
15871598
var groups = [];
@@ -1648,56 +1659,68 @@ var AblePlayerInstances = [];
16481659
if (this.mediaType === 'video') {
16491660

16501661
// Caption preferences
1662+
16511663
prefs.push({
16521664
'name': 'prefCaptions', // closed captions default state
16531665
'label': null,
16541666
'group': 'captions',
16551667
'default': 1
16561668
});
1657-
/* // not supported yet
1658-
prefs.push({
1659-
'name': 'prefCaptionsStyle',
1660-
'label': this.tt.prefCaptionsStyle,
1661-
'group': 'captions',
1662-
'default': this.tt.captionsStylePopOn
1663-
});
1664-
*/
1665-
prefs.push({
1666-
'name': 'prefCaptionsPosition',
1667-
'label': this.tt.prefCaptionsPosition,
1668-
'group': 'captions',
1669-
'default': this.defaultCaptionsPosition
1670-
});
1671-
prefs.push({
1672-
'name': 'prefCaptionsFont',
1673-
'label': this.tt.prefCaptionsFont,
1674-
'group': 'captions',
1675-
'default': 'sans-serif'
1676-
});
1669+
1670+
if (!this.usingYouTubeCaptions) {
1671+
1672+
/* // not supported yet
1673+
prefs.push({
1674+
'name': 'prefCaptionsStyle',
1675+
'label': this.tt.prefCaptionsStyle,
1676+
'group': 'captions',
1677+
'default': this.tt.captionsStylePopOn
1678+
});
1679+
*/
1680+
prefs.push({
1681+
'name': 'prefCaptionsPosition',
1682+
'label': this.tt.prefCaptionsPosition,
1683+
'group': 'captions',
1684+
'default': this.defaultCaptionsPosition
1685+
});
1686+
1687+
prefs.push({
1688+
'name': 'prefCaptionsFont',
1689+
'label': this.tt.prefCaptionsFont,
1690+
'group': 'captions',
1691+
'default': 'sans-serif'
1692+
});
1693+
}
1694+
1695+
// This is the one option that is supported by YouTube IFrame API
16771696
prefs.push({
16781697
'name': 'prefCaptionsSize',
16791698
'label': this.tt.prefCaptionsSize,
16801699
'group': 'captions',
16811700
'default': '100%'
16821701
});
1683-
prefs.push({
1684-
'name': 'prefCaptionsColor',
1685-
'label': this.tt.prefCaptionsColor,
1686-
'group': 'captions',
1687-
'default': 'white'
1688-
});
1689-
prefs.push({
1690-
'name': 'prefCaptionsBGColor',
1691-
'label': this.tt.prefCaptionsBGColor,
1692-
'group': 'captions',
1693-
'default': 'black'
1694-
});
1695-
prefs.push({
1696-
'name': 'prefCaptionsOpacity',
1697-
'label': this.tt.prefCaptionsOpacity,
1698-
'group': 'captions',
1699-
'default': '100%'
1700-
});
1702+
1703+
if (!this.usingYouTubeCaptions) {
1704+
1705+
prefs.push({
1706+
'name': 'prefCaptionsColor',
1707+
'label': this.tt.prefCaptionsColor,
1708+
'group': 'captions',
1709+
'default': 'white'
1710+
});
1711+
prefs.push({
1712+
'name': 'prefCaptionsBGColor',
1713+
'label': this.tt.prefCaptionsBGColor,
1714+
'group': 'captions',
1715+
'default': 'black'
1716+
});
1717+
prefs.push({
1718+
'name': 'prefCaptionsOpacity',
1719+
'label': this.tt.prefCaptionsOpacity,
1720+
'group': 'captions',
1721+
'default': '100%'
1722+
});
1723+
}
17011724

17021725
// Description preferences
17031726
prefs.push({
@@ -2100,7 +2123,8 @@ var AblePlayerInstances = [];
21002123

21012124
if (form === 'captions') {
21022125
// add a sample closed caption div to prefs dialog
2103-
if (this.mediaType === 'video') {
2126+
// do not show this for YouTube captions, since it's not an accurate reflection
2127+
if (this.mediaType === 'video' && !this.usingYouTubeCaptions) {
21042128
this.$sampleCapsDiv = $('<div>',{
21052129
'class': 'able-captions-sample'
21062130
}).text(this.tt.sampleCaptionText);
@@ -5994,6 +6018,11 @@ if (thisObj.useTtml && (trackSrc.endsWith('.xml') || trackText.startsWith('<?xml
59946018
thisObj.youTubePlayer.setOption('captions', 'track', {'languageCode': thisObj.captionLangPending});
59956019
thisObj.captionLangPending = null;
59966020
}
6021+
if (typeof thisObj.prefCaptionsSize !== 'undefined') {
6022+
// set the default caption size
6023+
// this doesn't work until the captions module is loaded
6024+
thisObj.youTubePlayer.setOption('captions','fontSize',thisObj.translatePrefs('size',thisObj.prefCaptionsSize,'youtube'));
6025+
}
59976026
deferred.resolve();
59986027
});
59996028
// Trigger the above event listener by briefly playing the video

‎build/ableplayer.min.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ableplayer",
3-
"version": "4.3.28",
3+
"version": "4.3.29",
44
"description": "fully accessible HTML5 media player",
55
"homepage": "http://ableplayer.github.io/ableplayer",
66
"bugs": "https://github.com/ableplayer/ableplayer/issues",

0 commit comments

Comments
 (0)