Android TV에 최적화

Android용 IMA SDK를 사용할 때 Android TV에서 앱이 제대로 작동하도록 몇 가지 권장사항을 따르는 것이 좋습니다.

먼저 Android용 TV 앱 개발에 관해 알아보세요. 특히 시작 가이드에 설명된 대로 활동이 TV용으로 설정되어 있는지 확인합니다. 또한 사용자가 Android TV에서 앱을 잘 탐색할 수 있도록 TV 탐색을 처리해야 합니다.

건너뛸 수 있는 광고 처리

SDK는 자세히 알아보기 버튼과 상호작용하는 기능을 삭제하는 등 TV와 유사한 기기에 맞게 건너뛸 수 있는 형식을 최적화합니다. 기본적으로 SDK는 건너뛸 수 있는 경우 건너뛰기 버튼에 포커스를 설정하므로 Android TV에서 광고를 건너뛸 수 있습니다. 따라서 건너뛸 수 있는 광고를 지원하기 위해 추가 작업이 필요하지 않습니다.

AdsRenderingSettings.setFocusSkipButtonWhenAvailable()을 호출하여 이를 구성할 수 있습니다.

지원되는 광고에 관한 자세한 내용은 호환성 매트릭스를 확인하세요.

VAST 아이콘 대체 이미지 처리

IMA SDK는 VAST 아이콘 대체 이미지를 감지, 렌더링하고 사용자의 상호작용을 처리합니다. 앱은 '이 광고가 표시되는 이유'(WTA)를 사용하는 광고의 광고 재생을 처리하기 위해 ICON_TAPPEDICON_FALLBACK_IMAGE_CLOSED 이벤트를 수신 대기해야 합니다.

VAST 아이콘 대체 이미지가 표시되는지 추적하는 불리언을 추가합니다. 그런 다음 ICON_TAPPEDICON_FALLBACK_IMAGE_CLOSED를 수신 대기하여 VAST 아이콘 대체 이미지 주변의 광고 재생을 처리합니다. 고급 예에서 이 작업이 처리되는 방법의 예는 다음 코드 스니펫을 참고하세요.

VideoPlayerController.java

// Copyright 2014 Google Inc. All Rights Reserved.

package com.google.ads.interactivemedia.v3.samples.videoplayerapp;

import android.app.UiModeManager;
import android.content.Context;

...

// Tracks if the SDK is playing an ad, since the SDK might not necessarily use
// the video player provided to play the video ad.
private boolean isAdPlaying;

// Tracks whether the SDK has a VAST icon fallback image showing.
private boolean isConnectedTvFallbackImageShowing = false;

// View that handles taps to toggle ad pause/resume during video playback.
private View playPauseToggle;

// View that we can write log messages to, to display in the UI.
private Logger log;

...

    adsManager.addAdEventListener(
        new AdEvent.AdEventListener() {
          /** Responds to AdEvents. */
          @Override
          public void onAdEvent(AdEvent adEvent) {

              ...

              case CONTENT_RESUME_REQUESTED:
                // AdEventType.CONTENT_RESUME_REQUESTED is fired when the ad is
                // completed and you should start playing your content.
                resumeContent();
                break;
              case ICON_TAPPED:
                // The user has tapped a VAST icon fallback image. On Android
                // mobile apps, the SDK will navigate to the landing page. On
                // Connected TV devices, the SDK will present a modal dialog
                // containing the VAST icon fallback image.

                // Check if the app is running on a TV device.
                UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
                if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
                  isConnectedTvFallbackImageShowing = true;
                }

                // Focus the IMA WebView for easier access to ad UI elements.
                adsManager.focus();
                break;
              case PAUSED:
                if (isConnectedTvFallbackImageShowing) {
                  // Do not show the controls; continue to leave the controls in
                  // the hands of the ads SDK.
                  break;
                }
                isAdPlaying = false;
                videoPlayerWithAdPlayback.enableControls();
                break;
              case ICON_FALLBACK_IMAGE_CLOSED:
                // The user has closed the VAST icon fallback image. This may
                // be a good time to resume ad playback if the user is ready to
                // continue playing the ad. This event only fires for Connected
                // TV devices.

                isConnectedTvFallbackImageShowing = false;
                adsManager.resume();
                break;
              case RESUMED:
                isAdPlaying = true;
                videoPlayerWithAdPlayback.disableControls();
                break;