ভিডিও ইভেন্টের প্রতিক্রিয়া,ভিডিও ইভেন্টের প্রতিক্রিয়া

প্ল্যাটফর্ম নির্বাচন করুন: অ্যান্ড্রয়েড (বিটা)নতুন অ্যান্ড্রয়েড আইওএস

পূর্বশর্ত

GADMediaContent

নেটিভ অ্যাডগুলো GADMediaContent একটি ক্লাসে অ্যাক্সেস দেয়, যা ভিডিও বা ছবির মতো মিডিয়া কন্টেন্ট সম্পর্কে তথ্য পেতে ব্যবহৃত হয়। এটি ভিডিও অ্যাডের প্লেব্যাক নিয়ন্ত্রণ করতে এবং প্লেব্যাক ইভেন্ট শোনার জন্যও ব্যবহৃত হয়। আপনি অ্যাডের .mediaContent প্রপার্টির মাধ্যমে মিডিয়া কন্টেন্ট অবজেক্টটি অ্যাক্সেস করতে পারেন।

GADMediaContent অবজেক্টটিতে ভিডিওর অ্যাস্পেক্ট রেশিও এবং সময়কালের মতো তথ্য থাকে। নিচের কোড স্নিপেটটিতে দেখানো হয়েছে কীভাবে একটি নেটিভ অ্যাডের অ্যাস্পেক্ট রেশিও এবং সময়কাল বের করতে হয়।

সুইফট

if myNativeAd.mediaContent.hasVideoContent {
  let mediaAspectRatio = CGFloat(myNativeAd.mediaContent.aspectRatio)
  let duration = myNativeAd.mediaContent.duration
}

উদ্দেশ্য-সি

if(myNativeAd.mediaContent.hasVideoContent) {
  CGFloat mediaAspectRatio = myNativeAd.mediaContent.aspectRatio;
  NSTimeInterval duration = myNativeAd.mediaContent.duration;
}

GADVideoController

GADMediaContent অবজেক্টটিতে একটি GADVideoController অবজেক্টের রেফারেন্স থাকে। GADVideoController অবজেক্টটি পাবলিশারদের ভিডিও ইভেন্টে সাড়া দেওয়ার সুযোগ দেয়।

লাইন আইটেমের মাধ্যমে পরিবেশিত বিজ্ঞাপনগুলোও GADVideoController দিয়ে নিয়ন্ত্রণ করা যায়।

GADMediaContent.videoController কল করার মাধ্যমে এই GADVideoController অবজেক্টটি পাওয়া যায়।

ভিডিও ইভেন্টের জন্য কলব্যাক

নির্দিষ্ট ভিডিও ইভেন্টগুলো পরিচালনা করার জন্য আপনাকে এমন একটি ক্লাস লিখতে হবে যা GADVideoControllerDelegate প্রোটোকলটি ইমপ্লিমেন্ট করে। প্রোটোকলটির মেথডগুলো সবই ঐচ্ছিক।

নিম্নলিখিত উদাহরণটি দেখায় কিভাবে ডেলিগেট প্রোটোকল প্রয়োগ করতে হয়:

সুইফট

class ViewController: NativeAdLoaderDelegate, VideoControllerDelegate {
  private var adLoader: AdLoader?

  func viewDidLoad() {
    super.viewDidLoad()

    let videoOptions = VideoOptions()
    videoOptions.customControlsRequested = true
    adLoader = AdLoader(
        adUnitID: "ca-app-pub-3940256099942544/3986624511",
        rootViewController: self,
        adTypes: [.native],
        options: [videoOptions])
    adLoader?.delegate = self
    adLoader?.load(AdManagerRequest())

  }

  func adLoader(
      _ adLoader: AdLoader?,
      didReceive nativeAd: NativeAd?
  ) {
    // Set the videoController's delegate to be notified of video events.
    nativeAd?.mediaContent.videoController.delegate = self
  }

  // VideoControllerDelegate methods
  func videoControllerDidPlayVideo(_ videoController: VideoController) {
    // Implement this method to receive a notification when the video controller
    // begins playing the ad.
  }

  func videoControllerDidPauseVideo(_ videoController: VideoController) {
    // Implement this method to receive a notification when the video controller
    // pauses the ad.
  }

  func videoControllerDidEndVideoPlayback(_ videoController: VideoController) {
    // Implement this method to receive a notification when the video controller
    // stops playing the ad.
  }

  func videoControllerDidMuteVideo(_ videoController: VideoController) {
    // Implement this method to receive a notification when the video controller
    // mutes the ad.
  }

  func videoControllerDidUnmuteVideo(_ videoController: VideoController) {
    // Implement this method to receive a notification when the video controller
    // unmutes the ad.
  }
}

উদ্দেশ্য-সি

@interface ViewController () <GADNativeAdLoaderDelegate,
    GADVideoControllerDelegate>
@property(nonatomic, strong) GADAdLoader *adLoader;

@end

@implementation ViewController
- (void)viewDidLoad {
  [super viewDidLoad];

  GADVideoOptions *videoOptions = [[GADVideoOptions alloc] init];
  videoOptions.customControlsRequested = YES;
  self.adLoader =
      [[GADAdLoader alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/3986624511"
                         rootViewController:self
                                    adTypes:@[ GADAdLoaderAdTypeNative ]
                                    options:@[ videoOptions ]];
  self.adLoader.delegate = self;
  [self.adLoader loadRequest:[GAMRequest request]];

}

- (void)adLoader:(GADAdLoader *)adLoader
    didReceiveNativeAd:(GADNativeAd *)nativeAd {
  // Set the videoController's delegate to be notified of video events.
  nativeAd.mediaContent.videoController.delegate = self;
}

// GADVideoControllerDelegate methods
- (void)videoControllerDidPlayVideo:(nonnull GADVideoController *)videoController {
  // Implement this method to receive a notification when the video controller
  // begins playing the ad.
}

- (void)videoControllerDidPauseVideo:(nonnull GADVideoController *)videoController {
  // Implement this method to receive a notification when the video controller
  // pauses the ad.
}

- (void)videoControllerDidEndVideoPlayback:(nonnull GADVideoController *)videoController {
  // Implement this method to receive a notification when the video controller
  // stops playing the ad.
}

- (void)videoControllerDidMuteVideo:(nonnull GADVideoController *)videoController {
  // Implement this method to receive a notification when the video controller
  // mutes the ad.
}

- (void)videoControllerDidUnmuteVideo:(nonnull GADVideoController *)videoController {
  // Implement this method to receive a notification when the video controller
  // unmutes the ad.
}

@end

আপনার নেটিভ বিজ্ঞাপনগুলো কীভাবে রেন্ডার করবেন সে সম্পর্কে আরও নির্দেশনার জন্য নেটিভ বিজ্ঞাপন নীতিমালা ও নির্দেশিকা পড়ুন।