Android TV के लिए ऑप्टिमाइज़ करना

हमारा सुझाव है कि IMA SDK for Android का इस्तेमाल करते समय, Android TV पर आपका ऐप्लिकेशन सही तरीके से काम करे. इसके लिए, यहां दिए गए सबसे सही तरीके अपनाएं.

Android के लिए टीवी ऐप्लिकेशन डेवलप करने के बारे में जानकारी पाकर शुरुआत करें. खास तौर पर, यह पक्का करें कि आपकी गतिविधि, टीवी के लिए सेट अप हो. इसके लिए, शुरू करने से जुड़ी गाइड में दिया गया तरीका अपनाएं. आपको टीवी नेविगेशन को भी मैनेज करना होगा, ताकि यह पक्का किया जा सके कि लोग Android TV पर आपके ऐप्लिकेशन को आसानी से नेविगेट कर सकें.

स्किप किए जा सकने वाले विज्ञापनों को मैनेज करना

एसडीके, टीवी जैसे डिवाइसों के लिए स्किप किए जा सकने वाले फ़ॉर्मैट ऑप्टिमाइज़ करता है. उदाहरण के लिए, ज़्यादा जानें बटन के साथ इंटरैक्ट करने की सुविधा हटाकर. डिफ़ॉल्ट रूप से, एसडीके स्किप करने की सुविधा उपलब्ध होने पर, स्किप बटन पर फ़ोकस सेट करता है, ताकि Android TV पर विज्ञापन को स्किप किया जा सके. इसलिए, स्किप किए जा सकने वाले विज्ञापनों के लिए, अलग से कुछ करने की ज़रूरत नहीं है.

इसे AdsRenderingSettings.setFocusSkipButtonWhenAvailable() को कॉल करके कॉन्फ़िगर किया जा सकता है.

कौनसे विज्ञापन फ़ॉर्मैट काम करते हैं, इस बारे में ज़्यादा जानने के लिए, कंपैटिबिलिटी मैट्रिक्स देखें.

वीएएसटी (वीडियो विज्ञापन देने के लिए टेंप्लेट) आइकॉन की फ़ॉलबैक इमेज को मैनेज करना

IMA SDK, वीएएसटी (वीडियो विज्ञापन देने के लिए टेंप्लेट) आइकॉन की फ़ॉलबैक इमेज को डिटेक्ट, रेंडर, और मैनेज करता है. साथ ही, यह भी मैनेज करता है कि लोग इन इमेज के साथ कैसे इंटरैक्ट करते हैं. आपके ऐप्लिकेशन को ICON_TAPPED और ICON_FALLBACK_IMAGE_CLOSED इवेंट सुनने चाहिए, ताकि 'यह विज्ञापन क्यों दिख रहा है' (डब्ल्यूटीए) सुविधा का इस्तेमाल करने वाले विज्ञापनों के लिए, विज्ञापन चलाने की सुविधा को मैनेज किया जा सके.

यह ट्रैक करने के लिए कि वीएएसटी (वीडियो विज्ञापन देने के लिए टेंप्लेट) आइकॉन की फ़ॉलबैक इमेज दिख रही है या नहीं, एक बूलियन वैल्यू जोड़ें. इसके बाद, वीएएसटी (वीडियो विज्ञापन देने के लिए टेंप्लेट) आइकॉन की फ़ॉलबैक इमेज के आस-पास विज्ञापन चलाने की सुविधा को मैनेज करने के लिए, ICON_TAPPED और ICON_FALLBACK_IMAGE_CLOSED को सुनें. एडवांस उदाहरण में, इसे मैनेज करने के तरीके का उदाहरण देखने के लिए, यहां दिया गया कोड स्निपेट देखें.

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;