O SDK pode operar em um ou mais modos, dependendo da resposta de anúncio que recebe do servidor de anúncios.
Anúncio único
Um anúncio que pode ser veiculado a qualquer momento quando a mensagem start
é enviada ao IMAAdsManager. Nenhuma inicialização especial é necessária para veicular um único anúncio.
Conjunto de anúncios
Vários anúncios que são reproduzidos em sequência quando a mensagem start é enviada para o
IMAAdsManager. Nenhuma inicialização especial é necessária para
reproduzir um único conjunto de anúncios.
Regras de anúncio
Uma playlist de intervalos de anúncios programados em determinados horários para um conteúdo específico. A mensagem start é ignorada no modo de regras de anúncios. É possível programar vários intervalos de anúncios em uma única playlist (por exemplo, precedentes, intermediários e finais). Para mais detalhes sobre a implementação, consulte a seção Regras de anúncios abaixo.
Regras de anúncio
O SDK do tvOS do IMA
é compatível com playlists de anúncios totalmente automatizadas. Esse recurso
insere intervalos de anúncio no conteúdo conforme especificado no
Google Ad Manager
ao fazer o tráfego dos seus anúncios. Ele também simplifica muito o código do player de vídeo
necessário para oferecer suporte a intervalos de anúncio, incluindo anúncios precedentes, intermediários e finais.
Ao fazer o tráfego de anúncios no Ad Manager, é possível especificar várias regras de anúncio, como "sempre veicular um intervalo de anúncio no início do conteúdo" ou "veicular um intervalo de anúncio de um minuto a cada 30 minutos de conteúdo".
Quando os anúncios são solicitados, o servidor de anúncios pode retornar uma playlist de anúncios. O SDK
processa a playlist e programa automaticamente os intervalos de publicidade especificados.
Ao inicializar o AdsManager, um objeto IMAContentPlayhead é transmitido pela chamada initializeWithContentPlayhead:adsRenderingSettings:. Se você estiver usando um AVPlayer para mostrar seu conteúdo, transmita uma instância de IMAAVPlayerContentPlayhead ao SDK ao criar o adDisplayContainer. Esse objeto é usado para acompanhar o progresso da reprodução de conteúdo para que os intervalos de anúncios sejam inseridos automaticamente nos horários especificados no Ad Manager.
Implemente currentTime para retornar o tempo atual do seu
player de vídeo.
Mude a chamada de inicialização IMAAdsManager para
usar initializeWithContentPlayhead:self.
O IMAAdsManagerDelegate
é usado para pausar e retomar o conteúdo quando os intervalos de anúncio são veiculados.
Observação:quando o conteúdo terminar de ser reproduzido ou
o usuário interromper a reprodução, chame contentComplete
no IMAAdsLoader para sinalizar ao SDK que o conteúdo
terminou de ser reproduzido. Em seguida, o SDK reproduz o bloco de anúncios pós-vídeo, se um tiver sido programado.
O evento ALL_ADS_COMPLETED é gerado quando todos os intervalos de publicidade são
reproduzidos. Além disso, observe que o rastreamento de conteúdo começa quando o método initializeWithContentPlayhead:adsRenderingSettings de IMAAdsManager é chamado, e você sempre precisa chamar initializeWithContentPlayhead:adsRenderingSettings antes de reproduzir o conteúdo.
[null,null,["Última atualização 2025-09-06 UTC."],[[["\u003cp\u003eThe tvOS SDK utilizes a WebView for ad requests, parsing responses, tracking, and rendering the ad UI.\u003c/p\u003e\n"],["\u003cp\u003eIt supports various ad formats including single ads, ad pods, and ad rules (playlists of ad breaks).\u003c/p\u003e\n"],["\u003cp\u003eAd rules, managed through Google Ad Manager, allow for automated ad insertion at designated times within the content.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK uses \u003ccode\u003eIMAContentPlayhead\u003c/code\u003e, which integrates with AVPlayer or a custom implementation, to synchronize ad breaks with content playback.\u003c/p\u003e\n"],["\u003cp\u003eUpon content completion, calling \u003ccode\u003econtentComplete\u003c/code\u003e on \u003ccode\u003eIMAAdsLoader\u003c/code\u003e triggers any scheduled post-roll ads and signals the completion of all ads.\u003c/p\u003e\n"]]],[],null,["Select platform: [HTML5](/interactive-media-ads/docs/sdks/html5/client-side/ad-rules \"View this page for the HTML5 platform docs.\") [Android](/interactive-media-ads/docs/sdks/android/client-side/ad-rules \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/ad-rules \"View this page for the iOS platform docs.\") [tvOS](/interactive-media-ads/docs/sdks/tvos/client-side/ad-rules \"View this page for the tvOS platform docs.\")\n| **Note:** The tvOS SDK uses a WebView to load a JavaScript back end. This WebView is used to make ad requests, parse responses, ping tracking URLs, and render the ad UI.\n\nSDK operation modes\n\nThe SDK can operate in one or more modes, depending on the ad response it receives from the ad\nserver.\n\nSingle ad\n: An ad that can be played at any time when the `start`\n message is sent to the `IMAAdsManager`. No special initialization\n is necessary to play a single ad.\n:\n\nAd pod\n: Several ads that play back to back when the `start` message is sent to\n the `IMAAdsManager`. No special initialization is necessary to\n play a single ad pod.\n\nAd rules\n: A playlist of ad breaks scheduled at certain times against particular\n content. The `start` message is ignored in ad rules mode. There can\n be several ad breaks scheduled within a single playlist (e.g., pre-roll,\n mid-roll, post-roll). For further implementation details, see the\n [Ad Rules](#ad-rules) section below.\n\nAd rules\n\nIMA\ntvOS SDK supports fully automated ad playlists. This feature\ninserts ad breaks into the content as specified in\n[Google Ad Manager](//admanager.google.com/)\nwhen trafficking your ads. It also greatly simplifies the video player code\nnecessary to support ad breaks, including pre-rolls, mid-rolls, and post-rolls.\n\n- When trafficking ads in Ad Manager, it is possible to specify various ad rules like \"always play ad break at the beginning of the content\" or \"play a one-minute ad break every 30 minutes of content\".\n- When ads are requested, the ad server can return an ad playlist. The SDK processes the playlist and automatically schedules the ad breaks that have been specified.\n- When initializing the `AdsManager`, an `IMAContentPlayhead` object is passed in via the `initializeWithContentPlayhead:adsRenderingSettings:` call. If you are using an AVPlayer to display your content, you pass an instance of `IMAAVPlayerContentPlayhead` to the SDK when you create your `adDisplayContainer`. This object is used to track the progress of the content playback so ad breaks are automatically inserted at the times specified in Ad Manager. \n\n **With AVPlayer:** \n\n ```objective-c\n IMAContentPlayhead *contentPlayhead =\n [[IMAAVPlayerContentPlayhead alloc] initWithAVPlayer:self.contentAVPlayer];\n IMAAdsRequest *request = [[IMAAdsRequest alloc] initWithAdTagUrl:adTagUrl\n adDisplayContainer:adDisplayContainer\n contentPlayhead:contentPlayhead\n userContext:nil];\n ```\n\n **Without AVPlayer:**\n 1. Implement the `IMAContentPlayhead` interface.\n 2. Implement `currentTime` to return the current time of your video player.\n 3. Change the `IMAAdsManager` initialization call to use `initializeWithContentPlayhead:self`.\n- The [IMAAdsManagerDelegate](/interactive-media-ads/docs/sdks/tvos/client-side/reference/Protocols/IMAAdsManagerDelegate) is used to pause and resume the content as ad breaks are played.\n\n**Note:** When the content has finished playing or\nthe user has stopped playback, be sure to call `contentComplete`\non the `IMAAdsLoader` in order to signal to the SDK that the content\nhas finished playing. The SDK then plays the post-roll ad break, if one has been scheduled.\nThe `ALL_ADS_COMPLETED` event is raised when all ad breaks have\nbeen played. In addition, note that content tracking begins when\n`IMAAdsManager`'s `initializeWithContentPlayhead:adsRenderingSettings`\nmethod is called and you should always call `initializeWithContentPlayhead:adsRenderingSettings`\nbefore playing content."]]