Configurar a reprodução do intervalo de anúncio
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Selecione a plataforma:
Android
iOS
Este guia é destinado a usuários que querem controlar manualmente o tempo de reprodução dos intervalos comerciais. Em uma implementação padrão, o SDK reproduz automaticamente os mid-rolls no horário programado. Alguns desenvolvedores podem querer impedir que o SDK toque esses intervalos de anúncio automaticamente. Ao implementar a reprodução manual de intervalos de anúncio, o SDK dispara um evento AD_BREAK_READY
quando um mid-roll é carregado e aguarda você iniciar a reprodução do intervalo.
Pré-requisitos
- Aplicativo iOS com o SDK do IMA implementado.
Materiais de referência úteis
Se você ainda precisar implementar o SDK do IMA no seu app, confira nosso guia de primeiros passos.
A configuração da reprodução manual de intervalos de anúncio tem três etapas:
- Informe ao SDK que você quer controlar a reprodução do intervalo comercial.
- Detecte o evento AD_BREAK_READY.
- Diga ao SDK para veicular anúncios quando você estiver pronto.
O snippet abaixo mostra as modificações necessárias no
Exemplo avançado para implementar a reprodução manual de intervalos comerciais:
- (void)setUpAdsLoader {
...
IMASettings settings = [[IMASettings alloc] init];
// Tell the SDK that you want to control ad break playback.
settings.autoPlayAdBreaks = NO;
self.adsLoader = [[IMAAdsLoader alloc] initWithSettings:settings];
...
}
- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event {
...
switch (event.type) {
// Listen for the AD_BREAK_READY event
case kIMAAdEvent_AD_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;
...
}
}
Perguntas frequentes
- Isso é necessário para uma implementação do SDK do IMA?
- Claro que não. Essa opção só é oferecida para editores que não querem que o SDK do IMA reproduza automaticamente anúncios no meio do vídeo quando eles são programados pelas regras de anúncio ou pela resposta VMAP.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-08-31 UTC.
[null,null,["Última atualização 2025-08-31 UTC."],[[["\u003cp\u003eThis guide explains how to manually control ad break playback timing within the IMA SDK for iOS apps, preventing automatic mid-roll playback.\u003c/p\u003e\n"],["\u003cp\u003eBy implementing manual ad break playback, developers can trigger mid-roll ads using the \u003ccode\u003eAD_BREAK_READY\u003c/code\u003e event and the \u003ccode\u003estart\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThis feature is optional and intended for publishers seeking greater control over ad playback timing, requiring code modifications to the IMA SDK setup and event handling.\u003c/p\u003e\n"],["\u003cp\u003eManual ad break playback involves three steps: disabling automatic ad breaks, listening for the \u003ccode\u003eAD_BREAK_READY\u003c/code\u003e event, and initiating ad playback when desired.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/interactive-media-ads/docs/sdks/android/client-side/manual_ad_playback \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/manual_ad_playback \"View this page for the iOS platform docs.\")\n\nThis guide is intended for users who want manual control over ad break playback timing. In a default implementation, the SDK automatically plays mid-rolls at their scheduled time. Some developers may want to prevent the SDK from playing these ad breaks automatically. By implementing manual ad break playback, the SDK fires an `AD_BREAK_READY` event when a mid-roll has been loaded, and wait on you to start the break's playback.\n\nPrerequisites\n\n\u003cbr /\u003e\n\n- iOS application with the IMA SDK implemented.\n\n\u003cbr /\u003e\n\nHelpful primers\n\nIf you still need to implement the IMA SDK in your app, check out our [Get Started guide](/interactive-media-ads/docs/sdks/ios/client-side).\n\nConfiguring Manual Ad Break Playback Configuring manual ad break playback takes three steps: \n\n1. Tell the SDK you want to control ad break playback.\n2. Listen for the AD_BREAK_READY event.\n3. Tell the SDK to play ads when you're ready.\n\nThe snippet below shows the modifications required on the [Advanced Example](//github.com/googleads/googleads-ima-ios/tree/master/Objective-C/AdvancedExample) to implement manual ad break playback: \n\n```objective-c\n- (void)setUpAdsLoader {\n ...\n IMASettings settings = [[IMASettings alloc] init];\n // Tell the SDK that you want to control ad break playback.\n settings.autoPlayAdBreaks = NO;\n self.adsLoader = [[IMAAdsLoader alloc] initWithSettings:settings];\n ...\n}\n\n- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event {\n ...\n switch (event.type) {\n // Listen for the AD_BREAK_READY event\n case kIMAAdEvent_AD_BREAK_READY:\n // Tell the SDK to play ads when you're ready. To skip this ad break,\n // simply return from this handler without calling [adsManager start].\n [adsManager start];\n break;\n ...\n }\n}\n```\n\nFAQ\n\nIs this required for an IMA SDK implementation?\n: Absolutely not! This is only offered for publishers who do not want the IMA SDK to automatically play mid-roll ads when they are scheduled by your ad rules or VMAP response."]]