diff --git a/src/js/player.js b/src/js/player.js index 3412ca3008..f25badeff6 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -795,7 +795,8 @@ class Player extends Component { 'IS_WEBOS', 'IS_ANDROID', 'IS_IPAD', - 'IS_IPHONE' + 'IS_IPHONE', + 'IS_CHROMECAST_RECEIVER' ].filter(key => browser[key]).map(key => { return 'vjs-device-' + key.substring(3).toLowerCase().replace(/\_/g, '-'); }); diff --git a/src/js/utils/browser.js b/src/js/utils/browser.js index 607986d924..1b9a32b003 100644 --- a/src/js/utils/browser.js +++ b/src/js/utils/browser.js @@ -96,6 +96,14 @@ export let CHROMIUM_VERSION = null; */ export let CHROME_VERSION = null; +/** + * Whether or not this is a Chromecast receiver application. + * + * @static + * @type {Boolean} + */ +export const IS_CHROMECAST_RECEIVER = Boolean(window.cast && window.cast.framework && window.cast.framework.CastReceiverContext); + /** * The detected Internet Explorer version - or `null`. * diff --git a/test/unit/player.test.js b/test/unit/player.test.js index 5504dbeea1..73bd638164 100644 --- a/test/unit/player.test.js +++ b/test/unit/player.test.js @@ -1045,6 +1045,19 @@ QUnit.test('should add iphone classname when on iphone', function(assert) { player.dispose(); }); +QUnit.test('should add chromecast-receiver classname when on chromecast receiver', function(assert) { + assert.expect(1); + + browser.stub_IS_CHROMECAST_RECEIVER(true); + + const player = TestHelpers.makePlayer({}); + + assert.ok(player.hasClass('vjs-device-chromecast-receiver'), 'chromecast-receiver classname added'); + + browser.reset_IS_CHROMECAST_RECEIVER(); + player.dispose(); +}); + QUnit.test('should add a svg-icons-enabled classname when svg icons are supported', function(assert) { // Stub a successful parsing of the SVG sprite. sinon.stub(window.DOMParser.prototype, 'parseFromString').returns({