publicVideoPlayerController(Contextcontext,VideoPlayerWithAdPlaybackvideoPlayerWithAdPlayback,ViewplayButton,ViewplayPauseToggle,Stringlanguage,ViewGroupcompanionViewGroup,Loggerlog){...sdkFactory=ImaSdkFactory.getInstance();ImaSdkSettingsimaSdkSettings=sdkFactory.createImaSdkSettings();imaSdkSettings.setLanguage(language);// Tell the SDK you want to control ad break playback.imaSdkSettings.setAutoPlayAdBreaks(false);...}...@OverridepublicvoidonAdEvent(AdEventadEvent){...switch(adEvent.getType()){// Listen for the AD_BREAK_READY event.caseAD_BREAK_READY:// Tell the SDK to play ads when you're ready. To skip this ad break,// simply return from this handler without calling adsManager.start().adsManager.start();break;...}
常见问题解答
是否需要手动播放广告才能实现 IMA SDK?
否。对于不希望 IMA SDK 按照广告规则或 VMAP 响应的时间安排自动播放广告插播的发布商,手动广告播放是一项可选功能。
[[["易于理解","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"]],["最后更新时间 (UTC):2024-12-22。"],[[["This guide explains how to manually control ad break playback timing in your Android app using the IMA SDK."],["By disabling autoplay and listening for the `AD_BREAK_READY` event, you can trigger ad breaks at your desired moments."],["This feature is optional and provides flexibility for publishers who need custom ad playback control beyond the default ad schedule."],["The Advanced Example showcases the implementation, but the Basic Example with the Exoplayer-IMA extension cannot be used as a basis for this guide."]]],[]]