ভিডিও ইভেন্টের উত্তর দেওয়া

প্ল্যাটফর্ম বেছে নিন: Android iOS Android (পুরনো)

পূর্বশর্ত

GADMediaContent

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

GADMediaContent অবজেক্টে ভিডিওর অ্যাস্পেক্ট রেশিও ও সময়সীমার মতো তথ্য থাকে। নিচের স্নিপেট থেকে জানতে পারবেন যে কীভাবে নেটিভ বিজ্ঞাপনের অ্যাস্পেক্ট রেশিও ও সময়সীমা পাওয়া যায়।

Swift

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

Objective-C

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

GADVideoController

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

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

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

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

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

Swift

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(Request())

  }

  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.
  }
}

Objective-C

@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:[GADRequest 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

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