diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d5f041..7e2ffb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ Release notes follow the [keep a changelog](https://keepachangelog.com/en/1.0.0/ ### Added -- Added `ARCHITECTURE.md` with mermaid sequence diagram documenting the full media permission flow. +- Added `AirConsole.getConfiguration()` to expose the platform capability configuration from the `ready` event on screens. ## [1.10.0] - 2026-02-17 diff --git a/airconsole-1.10.0.js b/airconsole-1.10.0.js index 7c7c4fb..a8906e6 100644 --- a/airconsole-1.10.0.js +++ b/airconsole-1.10.0.js @@ -249,6 +249,23 @@ AirConsole.prototype.arePlayersSilenced = function () { && (this.devices[AirConsole.SCREEN]["players"] !== undefined && this.devices[AirConsole.SCREEN]["players"].length > 0); } +/** + * Returns the platform capability configuration delivered in the ready event. + * Use this to branch on device capabilities instead of platform or partner + * names. Only available on the screen; controllers receive undefined. + * Can only be called after onReady. + * @return {Object|undefined} An object with: + * supportedVideoFormats {string[]} - e.g. ["vp9","h264","vp8"] + * transparentVideoSupported {boolean} + * unityVideoSupported {boolean} + * graphicsQualityTier {string} - "low", "medium", or "high" + * Returns undefined on controllers or if the platform did not send it. + * @since 1.10.0 + */ +AirConsole.prototype.getConfiguration = function() { + return this.configuration; +} + /** * Dictionary of silenced update messages queued during a running game session. * @private @@ -1365,6 +1382,7 @@ AirConsole.prototype.onPostMessage_ = function(event) { } me.gameSafeArea = data.gameSafeArea; + me.configuration = data.configuration; if (data.translations) { me.translations = data.translations; var elements = document.querySelectorAll("[data-translation]"); diff --git a/beta/airconsole-1.11.0.js b/beta/airconsole-1.11.0.js index f6d1d0e..b65fe37 100644 --- a/beta/airconsole-1.11.0.js +++ b/beta/airconsole-1.11.0.js @@ -293,6 +293,23 @@ AirConsole.prototype.arePlayersSilenced = function () { && (this.devices[AirConsole.SCREEN]["players"] !== undefined && this.devices[AirConsole.SCREEN]["players"].length > 0); } +/** + * Returns the platform capability configuration delivered in the ready event. + * Use this to branch on device capabilities instead of platform or partner + * names. Only available on the screen; controllers receive undefined. + * Can only be called after onReady. + * @return {Object|undefined} An object with: + * supportedVideoFormats {string[]} - e.g. ["vp9","h264","vp8"] + * transparentVideoSupported {boolean} + * unityVideoSupported {boolean} + * graphicsQualityTier {string} - "low", "medium", or "high" + * Returns undefined on controllers or if the platform did not send it. + * @since 1.10.0 + */ +AirConsole.prototype.getConfiguration = function() { + return this.configuration; +} + /** * Dictionary of silenced update messages queued during a running game session. * @private @@ -1585,6 +1602,7 @@ AirConsole.prototype.onPostMessage_ = function(event) { } me.gameSafeArea = data.gameSafeArea; + me.configuration = data.configuration; if (data.translations) { me.translations = data.translations; var elements = document.querySelectorAll("[data-translation]"); diff --git a/tests/airconsole-1.10.0-spec.html b/tests/airconsole-1.10.0-spec.html index fbd6136..8c84c22 100644 --- a/tests/airconsole-1.10.0-spec.html +++ b/tests/airconsole-1.10.0-spec.html @@ -28,9 +28,10 @@ - + + - + diff --git a/tests/airconsole-1.11.0-spec.html b/tests/airconsole-1.11.0-spec.html index 896a6de..f4973e2 100644 --- a/tests/airconsole-1.11.0-spec.html +++ b/tests/airconsole-1.11.0-spec.html @@ -30,9 +30,10 @@ - + + - + diff --git a/tests/spec/airconsole-1.10.0-spec.js b/tests/spec/airconsole-1.10.0-spec.js index a5be8e8..9502e6d 100644 --- a/tests/spec/airconsole-1.10.0-spec.js +++ b/tests/spec/airconsole-1.10.0-spec.js @@ -384,4 +384,21 @@ describe("AirConsole 1.10.0", function () { testAirConsole110Plus(); }); + + /** + ====================================================================================== + TEST CONFIGURATION FUNCTIONALITY + */ + + describe("Configuration", function () { + beforeEach(function () { + initAirConsole(); + }); + + afterEach(function () { + tearDown(); + }); + + testGetConfiguration(); + }); }); diff --git a/tests/spec/airconsole-1.11.0-spec.js b/tests/spec/airconsole-1.11.0-spec.js index 664c738..25f62af 100644 --- a/tests/spec/airconsole-1.11.0-spec.js +++ b/tests/spec/airconsole-1.11.0-spec.js @@ -397,4 +397,21 @@ describe("AirConsole 1.11.0", function () { testUserMediaPermissions(); }); + + /** + ====================================================================================== + TEST CONFIGURATION FUNCTIONALITY + */ + + describe("Configuration", function () { + beforeEach(function () { + initAirConsole(); + }); + + afterEach(function () { + tearDown(); + }); + + testGetConfiguration(); + }); }); diff --git a/tests/spec/methods/spec-configuration.js b/tests/spec/methods/spec-configuration.js new file mode 100644 index 0000000..44f2df8 --- /dev/null +++ b/tests/spec/methods/spec-configuration.js @@ -0,0 +1,36 @@ +function testGetConfiguration() { + + it ("Should store configuration from ready event", function() { + var configuration = { + supportedVideoFormats: ["vp9", "h264", "vp8"], + transparentVideoSupported: true, + unityVideoSupported: true, + graphicsQualityTier: "high" + }; + dispatchCustomMessageEvent({ + action: "ready", + code: 1237, + device_id: 0, + devices: [{}, undefined, airconsole.devices[DEVICE_ID]], + configuration: configuration + }); + expect(airconsole.getConfiguration()).toEqual(configuration); + }); + + it ("Should return undefined configuration when not provided in ready event", function() { + dispatchCustomMessageEvent({ + action: "ready", + code: 1237, + device_id: 0, + devices: [{}, undefined, airconsole.devices[DEVICE_ID]] + }); + expect(airconsole.getConfiguration()).toBeUndefined(); + }); + + it ("Should return undefined configuration before onReady fires", function() { + // getConfiguration() must return undefined until the READY message has been processed; + // a freshly-constructed AirConsole instance has not yet received a ready event. + expect(airconsole.getConfiguration()).toBeUndefined(); + }); + +}