নেটিভ ভিডিও বিজ্ঞাপন

মিডিয়া কন্টেন্ট

নেটিভ বিজ্ঞাপনগুলি একটি MediaContent অবজেক্টে অ্যাক্সেস প্রদান করে যা মিডিয়া বিষয়বস্তু সম্পর্কে তথ্য পেতে ব্যবহৃত হয়, যা ভিডিও বা ছবি হতে পারে। এটি ভিডিও বিজ্ঞাপন প্লেব্যাক নিয়ন্ত্রণ করতে এবং প্লেব্যাক ইভেন্টগুলি শুনতেও ব্যবহৃত হয়। আপনি NativeAd.getMediaContent() কল করে MediaContent অবজেক্ট পেতে পারেন।

MediaContent অবজেক্টে তথ্য থাকে যেমন একটি ভিডিওর আকৃতির অনুপাত এবং সময়কাল। নিম্নলিখিত স্নিপেট দেখায় কিভাবে একটি নেটিভ বিজ্ঞাপনের আকৃতির অনুপাত এবং সময়কাল পেতে হয়।

জাভা

if (myNativeAd.getMediaContent().hasVideoContent()) {
  float mediaAspectRatio = myNativeAd.getMediaContent().getAspectRatio();
  float duration = myNativeAd.getMediaContent().getDuration();
  ...
}

কোটলিন

if (myNativeAd.getMediaContent().hasVideoContent()) {
  val mediaAspectRatio: Float = myNativeAd.getMediaContent().getAspectRatio()
  val duration: Float = myNativeAd.getMediaContent().getDuration()
  ...
}

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

নির্দিষ্ট ভিডিও ইভেন্টগুলি পরিচালনা করতে, একটি ক্লাস লিখুন যা বিমূর্ত VideoLifecycleCallbacks ক্লাস প্রসারিত করে এবং VideoControllersetVideoLifecycleCallbacks() কল করুন। তারপর, শুধুমাত্র আপনার পছন্দের কলব্যাকগুলিকে ওভাররাইড করুন৷

জাভা

myNativeAd.getMediaContent().getVideoController()
        .setVideoLifecycleCallbacks(new VideoLifecycleCallbacks() {

  /** Called when video playback first begins. */
  @Override
  public void onVideoStart() {
    // Do something when the video starts the first time.
    Log.d("MyApp", "Video Started");
  }

  /** Called when video playback is playing. */
  @Override
  public void onVideoPlay() {
    // Do something when the video plays.
    Log.d("MyApp", "Video Played");
  }

  /** Called when video playback is paused. */
  @Override
  public void onVideoPause() {
    // Do something when the video pauses.
    Log.d("MyApp", "Video Paused");
  }

  /** Called when video playback finishes playing. */
  @Override
  public void onVideoEnd() {
    // Do something when the video ends.
    Log.d("MyApp", "Video Ended");
  }

  /** Called when the video changes mute state. */
  @Override
  public void onVideoMute(boolean isMuted) {
    // Do something when the video is muted.
    Log.d("MyApp", "Video Muted");
  }
});

কোটলিন

myNativeAd.getMediaContent().getVideoController().setVideoLifecycleCallbacks {

  /** Called when video playback first begins. */
  override fun onVideoStart() {
    // Do something when the video starts the first time.
    Log.d("MyApp", "Video Started")
  }

  /** Called when video playback is playing. */
  override fun onVideoPlay() {
    // Do something when the video plays.
    Log.d("MyApp", "Video Played")
  }

  /** Called when video playback is paused. */
  override fun onVideoPause() {
    // Do something when the video pauses.
    Log.d("MyApp", "Video Paused")
  }

  /** Called when video playback finishes playing. */
  override fun onVideoEnd() {
    // Do something when the video ends.
    Log.d("MyApp", "Video Ended")
  }

  /** Called when the video changes mute state. */
  override fun onVideoMute(boolean isMuted) {
    // Do something when the video is muted.
    Log.d("MyApp", "Video Muted")
  }
}