Android용 IMA SDK를 사용할 때 Android TV에서 앱이 제대로 작동하도록 하려면 몇 가지 권장사항을 따르는 것이 좋습니다.
Android용 TV 앱 개발을 숙지하여 시작하세요. 특히 시작 가이드에 설명된 대로 활동이 TV용으로 설정되어 있는지 확인합니다. 또한 사용자가 Android TV에서 앱을 원활하게 탐색할 수 있도록 TV 탐색을 처리하려고 합니다.
건너뛸 수 있는 광고 처리
SDK는 예를 들어 자세히 알아보기 버튼을 사용하는 기능을 삭제하는 등 TV와 유사한 기기에 건너뛸 수 있는 형식을 최적화합니다. 기본적으로 SDK는 건너뛰기를 사용할 수 있는 경우 건너뛰기 버튼에 포커스를 설정하여 Android TV에서 광고를 건너뛸 수 있도록 합니다. 따라서 건너뛸 수 있는 광고를 지원하기 위해 추가 작업을 할 필요가 없습니다.
AdsRenderingSettings.setFocusSkipButtonWhenAvailable()
를 호출하여 이를 구성할 수 있습니다.
지원되는 광고에 관한 자세한 내용은 호환성 매트릭스를 확인하세요.
VAST 아이콘 대체 이미지 처리
IMA SDK는 VAST 아이콘 대체 이미지를 감지하고 렌더링하며 사용자와의
상호작용을 처리합니다. 앱에서 ICON_TAPPED
및 ICON_FALLBACK_IMAGE_CLOSED
이벤트를 수신 대기하여
'이 광고가 표시된 이유' (WTA)를 사용하는 광고의 광고 재생을
처리해야 합니다.
VAST 아이콘 대체 이미지의 표시 여부를 추적하는 부울을 추가합니다. 그런 다음 ICON_TAPPED
및 ICON_FALLBACK_IMAGE_CLOSED
를 수신 대기하여 VAST 아이콘 대체 이미지에서 광고 재생을 처리합니다. 고급 예에서 이 작업을 처리하는 방법의 예는 다음 코드 스니펫을 참고하세요.
app/src/main/java/com/google/ads/interactivemedia/v3/samples/videoplayerapp/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;