Audio interface
Stay organized with collections
Save and categorize content based on your preferences.
Methods for controlling audio.
Methods
isEnabled(): boolean
Determines if game sound should be audible at this instant. Required
subscribe(callback: (isEnabled: boolean) => void): void
Subscribes to changes to isEnabled.
Requirements
- Your game should not show an overall mute button and should instead rely
on the GameSnacks platform control for this.
- Your game may have separate granular audio controls in the game, such as
for background music or sound effects, but it must still follow these
requirements.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-03 UTC."],[[["\u003cp\u003eAll games must respect the platform's audio control which dictates whether sound is enabled or disabled.\u003c/p\u003e\n"],["\u003cp\u003eGames can implement individual sound controls (e.g., for music or effects) but must still adhere to the platform's master audio control.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access and subscribe to the platform's audio state using provided methods \u003ccode\u003eisEnabled\u003c/code\u003e and \u003ccode\u003esubscribe\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eGames should not display their own global mute button, relying instead on the platform's built-in control.\u003c/p\u003e\n"]]],[],null,["# Audio interface\n\nMethods for controlling audio.\n\nMethods\n-------\n\n[`isEnabled(): boolean`](./isenabled) \n\nDetermines if game sound should be audible at this instant. **Required**\n\n[`subscribe(callback: (isEnabled: boolean) =\u003e void): void`](./subscribe) \n\nSubscribes to changes to isEnabled.\n\nRequirements\n------------\n\n- Your game **should not** show an overall mute button and should instead rely on the GameSnacks platform control for this.\n- Your game **may** have separate granular audio controls in the game, such as for background music or sound effects, but it **must** still follow these requirements."]]