显示音频广告的海报图片
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本指南将演示如何使用 IMA HTML5 SDK 叠加显示您的视频
带有海报图片的播放器。此方法应在
在您的 VAST 网址请求中设置了 ad_type=audio_video
。这样,您就可以
由于音频广告和视频广告都符合条件且完整播放,因此广告创收能力得到了提升
进行投放。请参阅 ad_type
文档
和视频中的音频
内容
了解详情。
您可以按照本指南中的说明,对基本的 IMA
集成,或参阅
视频示例应用中的音频
,以便与此功能全面集成。
前提条件
- 实施 IMA HTML5 SDK 视频广告的应用。请参阅 IMA HTML5
入门指南
。
- 音频广告播放时,默认海报图片会叠加在视频播放器上
不包含相关的重叠式广告图片。为了让图片符合
视频播放器,其宽度必须小于或等于视频的尺寸
播放器,并且其高度必须比视频高度至少低 75 像素
。
启用海报图片功能
在发出音频和视频广告请求之前,请将 audioPosterImageEnabled
将功能标志设置为 true
,将 audioPosterImageDefaultUrl
功能标志设置为
默认的海报图片网址。为此,请使用
ImaSdkSettings.setFeatureFlags()
然后再创建 AdDisplayContainer
。如果已设置该属性,且音频广告
IMA 会自动将与广告相关的图片叠加到
视频播放器。IMA 会选择适合的最大随播广告图片
且比视频播放器短至少 75 像素。
如果广告的 VAST 中未包含可用作重叠式广告的图片,则 IMA
使用指定的默认图像作为叠加层。
function initializeIMA() {
console.log('initializing IMA');
adContainer = document.getElementById('ad-container');
google.ima.settings.setFeatureFlags(
{
'audioPosterImageEnabled': true,
'audioPosterImageDefaultUrl':'http://your-ad-overlay/image.png'
});
adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);
adsLoader = new google.ima.AdsLoader(adDisplayContainer);
// Let the AdsLoader know when the video has ended
videoElement.addEventListener('ended', function() {
adsLoader.contentComplete();
});
var adsRequest = new google.ima.AdsRequest();
adsRequest.adTagUrl = 'http://your-audio-video-ad-tag';
...
// Pass the request to the adsLoader to request ads
adsLoader.requestAds(adsRequest);
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-01。
[null,null,["最后更新时间 (UTC):2025-08-01。"],[[["\u003cp\u003eThis guide explains how to overlay a poster image on your video player during audio ads using the IMA HTML5 SDK to enhance ad monetization.\u003c/p\u003e\n"],["\u003cp\u003eThis implementation involves enabling the \u003ccode\u003eaudioPosterImageEnabled\u003c/code\u003e and \u003ccode\u003eaudioPosterImageDefaultUrl\u003c/code\u003e feature flags in the IMA SDK settings.\u003c/p\u003e\n"],["\u003cp\u003eDuring audio ad playback, IMA automatically selects and displays a relevant companion ad image or the default image as an overlay on the video player.\u003c/p\u003e\n"],["\u003cp\u003eTo use this feature, you need a basic IMA HTML5 SDK integration and a default poster image meeting specific size requirements.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided links for detailed information on ad types, audio in video content, and a sample implementation.\u003c/p\u003e\n"]]],[],null,["# Display poster image for audio ads\n\nThis guide demonstrates how to use the IMA HTML5 SDK to overlay your video\nplayer with a poster image when audio ads are played. This should be used when\n`ad_type=audio_video` is set in your VAST URL request. Doing this allows for\nimproved ad monetization as both audio and video ads are eligible and complete\nto be served. See the [`ad_type`\ndocumentation](//support.google.com/admanager/answer/10678356#ad_type)\nand [Audio in video\ncontent](//support.google.com/admanager/answer/7642796#audio-in-video-content)\nfor more details.\n\nYou can follow along with this guide, making the changes to a basic IMA\nintegrations, or see the\n[audio in video sample app](//github.com/googleads/googleads-ima-html5/tree/main/audio_in_video)\nfor a full integration with this feature.\n\nPrerequisites\n-------------\n\n- An app implementing the IMA HTML5 SDK for video ads. See the [IMA HTML5\n getting started guide](/interactive-media-ads/docs/sdks/html5/client-side) for more information.\n- A default poster image which overlays the video player when an audio ad is served without a relevant overlay image. In order for the image to fit within the video player, its width must be less than or equal to that of the video player and its height must be at least 75 px less than that of the video player.\n\nEnable the poster image feature\n-------------------------------\n\nBefore making your audio and video ad request, set the `audioPosterImageEnabled`\nfeature flag to `true` and the `audioPosterImageDefaultUrl` feature flag to\nyour default poster image URL. Do this with the\n[`ImaSdkSettings.setFeatureFlags()`](/interactive-media-ads/docs/sdks/html5/client-side/reference/interface/google.ima.ImaSdkSettings#google.ima.ImaSdkSettings.setFeatureFlags)\nAPI before creating the `AdDisplayContainer`. When this is set and an audio ad\nis playing, IMA automatically overlays an image related to the ad on top of the\nvideo player. IMA chooses the largest companion ad image available that fits\nwithin the video player and is at least 75 px shorter than the video player.\nIf the ad's VAST doesn't include an image that IMA can use as an overlay, IMA\nuses your specified default image as an overlay. \n\n function initializeIMA() {\n console.log('initializing IMA');\n adContainer = document.getElementById('ad-container');\n google.ima.settings.setFeatureFlags(\n {\n 'audioPosterImageEnabled': true,\n 'audioPosterImageDefaultUrl':'http://your-ad-overlay/image.png'\n });\n adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);\n adsLoader = new google.ima.AdsLoader(adDisplayContainer);\n\n // Let the AdsLoader know when the video has ended\n videoElement.addEventListener('ended', function() {\n adsLoader.contentComplete();\n });\n\n var adsRequest = new google.ima.AdsRequest();\n adsRequest.adTagUrl = 'http://your-audio-video-ad-tag';\n ...\n // Pass the request to the adsLoader to request ads\n adsLoader.requestAds(adsRequest);\n }"]]