廣告設定
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
adConfig() 呼叫會將遊戲的目前設定傳達給 Ad Placement API。Ad Placement API 可藉此調整預先載入廣告的方式,並篩選所要求的廣告類型,確保廣告適合放送 (例如需要音效的影片廣告)。
函式簽章:
adConfig({
preloadAdBreaks: 'on|auto', // Ad preloading strategy
sound: 'on|off' // This game has sound
onReady: () => {}, // Called when API has initialised and adBreak() is ready
});
adConfig 參數
名稱 |
類型 |
說明 |
sound |
字串 |
(選用) 遊戲目前是否正在播放音效。值: - on (預設) - off 這項呼叫會指定遊戲是否支援音效,以及在呼叫 adBreak() 前是否已啟用音效 (即取消靜音)。這有助於 Ad Placement API 為遊戲選取合適的廣告類型。 遊戲的音效狀態變更時,請立即呼叫這個函式,因為 Ad Placement API 可能必須要求新的廣告素材,這樣才能有充足的時間完成這項作業。
預設值為開啟音效。因此,大多數遊戲在開始宣告已啟用音效時,都需要呼叫 adConfig() 。 |
preloadAdBreaks |
字串 |
(選用) 廣告是否應一律在首次呼叫 adBreak() 前預先載入。值: - on - auto (預設)
預設值 auto 會將決策權交給 Ad Placement API。preloadAdBreaks 只能透過 adConfig() 設定一次,之後傳遞至 preloadAdBreaks 的值不會生效。 在首次呼叫 adBreak() 後設定 preloadAdBreaks 不會生效。 |
onReady |
字串 |
(選用):API 初始化並完成預先載入廣告後 (如果您使用上述 preloadAdBreaks 要求預先載入),系統就會呼叫這個方法。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],["The `adConfig()` function communicates the game's settings to the Ad Placement API. It accepts parameters to configure ad behavior: `sound` (specifying if sound is 'on' or 'off'), `preloadAdBreaks` ('on' or 'auto' for preloading ads), and `onReady` (a callback after initialization). `sound` informs the API of the game's sound capability and status, influencing ad selection. `preloadAdBreaks` dictates ad preloading strategy, set only once.\n"]]