adConfig
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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 |
string |
(選用) 遊戲目前正在播放音效。值: - on (預設) - off 此呼叫會指定遊戲能否發出音效,以及系統在呼叫 adBreak() 之前是否已啟用音效 (也就是取消靜音)。這有助於 Ad Placement API 選擇最適合您遊戲的廣告類型。 請在遊戲的音效狀態變更時,立即呼叫此函式,因為 Ad Placement API 可能必須要求新的廣告素材,且時間上限可以設為啟用。
預設值為音效。因此,大多數遊戲在開始宣告時已啟用音效,必須呼叫 adConfig() 。 |
preloadAdBreaks |
string |
(選用) 一律在首次呼叫 adBreak() 之前預先載入廣告。值: - on - auto (預設)
預設值 auto 會決定 Ad Placement API 的決定。preloadAdBreaks 只能透過 adConfig() 設定一次,而其他傳遞至 preloadAdBreaks 的值則無效。 在首次呼叫 adBreak() 之後設定 preloadAdBreaks 不會有任何作用。 |
onReady |
string |
(選用) 當 API 初始化且預先載入完成 (如果使用上述 preloadAdBreaks 要求預先載入) 時呼叫。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2022-09-27 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2022-09-27 (世界標準時間)。"],[[["`adConfig()` is used to inform the Ad Placement API about the game's settings, such as sound and ad preloading preferences, for better ad selection and delivery."],["The API uses this information to optimize ad preloading and ensure ads are suitable for the game's context, like avoiding sound-based ads in silent games."],["Developers can specify whether the game has sound enabled using the `sound` parameter and control ad preloading behavior with `preloadAdBreaks`."],["An optional `onReady` callback can be provided to notify the game when the API is initialized and ad preloading is complete, if requested."]]],["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"]]