Help Center/Details/

Self-rendering Draw Video

Introduction

Self-rendering Draw:: Suitable for use in vertical full-screen video streams. The access party can control the video to pause or continue to play. By default, video playback cannot be intervened. The configuration of video advertisements can be set on the platform.

Supported ad size: portrait video (aspect ratio 16:9)

Permission

Self-rendering Draw ads: Reclaimed and no longer available for creation

Self-rendering Draw request method

Create TTAdNative object

//创建TTAdNative对象,createAdNative(Context context) context需要传入Activity对象
TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(this);

Create ad request type parameter AdSlot

AdSlot adSlot = new AdSlot.Builder()
        .setCodeId(codeId)
        .setImageAcceptedSize(640, 320) // 单位px
        .setAdCount(3) //请求广告数量为1到3条
        .build();

Parameter Description

Parameters Description
setCodeId The code bit ID created by the platform starts with 9 and 9 digits
setAdCount The number of requests is 1-3, it is recommended to set 1
setImageAcceptedSize Set the size of the requested ad Unit: px

Request ads

The access party can call loadDrawFeedAd(AdSlot adSlot, @NonNull DrawFeedAdListener listener) to load ads asynchronously

mTTAdNative.loadDrawFeedAd(adSlot, new TTAdNative.DrawFeedAdListener() {
	//请求广告失败
    @Override
    public void onError(int code, String message) {

    }
	//请求广告成功
    @Override
    public void onDrawFeedAdLoad(List<TTDrawFeedAd> ads) {
      
});

DrawFeedAdListener description

Callback Description
onError() The error code returned by the ad request failed callback indicates the reason for the ad request failure. For details, please see [link](https://www.pangle.cn/help/doc/5de4cc6d78c8690012a90aa5?from=ad. oceanengine.com&id=5de4cc6d78c8690012a90aa5)
onDrawFeedAdLoad() Callback for successful ad request, get the view of ad video playback and put it into the ad container

TTFeedAd interface description

Get the view of the advertising video part through getAdView() and put it into the specified container. The access party can also obtain other advertising information, such as title, buttonText and other information, and customize the drawing of the entire advertising area, which can be in accordance with the style of your own application. Style as close as possible

public interface TTFeedAd {

    /**
     * 获取穿山甲logo,图片大小:80*80
     *
     * @return bitmap对象
     */
    Bitmap getAdLogo();

    /**
     * 广告标题
     *
     * @return
     */
    String getTitle();

    /**
     * 广告描述
     *
     * @return
     */
    String getDescription();

    /**
     * 广告来源
     *
     * @return
     */
    String getSource();

    /**
     * 广告图标Image
     *
     * @return
     */
    TTImage getIcon();

    /**
     * 广告图片Image list
     *
     * @return
     */
    List<TTImage> getImageList();

    /**
     * 得到Feed广告交互类型
     *
     * @return 2:在浏览器打开网页,3:在app中打开,4:下载应用,5:拨打电话 其它:未知类型
     */
    int getInteractionType();


    /**
     * 得到Feed广告图片模式
     *
     * @return 3 大图 2小图 4 组图 5 视频 其它:未知类型
     */
    int getImageMode();

    /**
     * 获取下载状态控制器
     */
    DownloadStatusController getDownloadStatusController();

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container 渲染广告最外层的ViewGroup
     * @param clickView 可点击的View
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull View clickView, AdInteractionListener listener);

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container     渲染广告最外层的ViewGroup
     * @param clickViews    可点击的View的列表
     * @param creativeViews 用于下载或者拨打电话的View
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull List<View> clickViews, @Nullable List<View> creativeViews, AdInteractionListener listener);

    /**
     * 注册可点击的View,click/show会在内部完成
     *
     * @param container     渲染广告最外层的ViewGroup
     * @param clickViews    可点击的View的列表
     * @param creativeViews 用于下载或者拨打电话的View
     * @param listener      点击回调
     */
    void registerViewForInteraction(@NonNull ViewGroup container, @NonNull List<View> clickViews, @Nullable List<View> creativeViews, @Nullable View dislikeView, AdInteractionListener listener);

    /**
     * 设置下载监听器
     */
    void setDownloadListener(TTAppDownloadListener downloadListener);

    /**
     * 兼容下载类广告,使用activity申请权限
     */
    void setActivityForDownloadApp(@NonNull Activity activity);
    /**
     * 获取广告的view,如视频广告的view,在广告平台可设置是否自动播放、是否静音等。
     *
     * @return
     */
    View getAdView();

}

Draw advertising behavior monitoring

Important!!! AdInteractionListener involves advertising billing, convertView must be called correctly and ViewGroup must be used

//响应点击区域的设置,分为普通的区域clickViews和创意区域creativeViews
//clickViews中的view被点击会尝试打开广告落地页;creativeViews中的view被点击会根据广告类型
//响应对应行为,如下载类广告直接下载,打开落地页类广告直接打开落地页。
//注意:ad.getAdView()获取的view请勿放入这两个区域中。
List<View> clickViews = new ArrayList<>();
clickViews.add(title);
clickViews.add(desc);
List<View> creativeViews = new ArrayList<>();
creativeViews.add(action);
ad.registerViewForInteraction(container, clickViews, creativeViews, new TTNativeAd.AdInteractionListener() {

	//广告点击回调
    @Override
    public void onAdClicked(View view, TTNativeAd ad) {
    }
    
	//广告创意区间回调
    @Override
    public void onAdCreativeClick(View view, TTNativeAd ad) {
    }
    
	//广告展示回调
    @Override
    public void onAdShow(TTNativeAd ad) {

}
}

AdInteractionListener description

Callback Description
onAdClicked() Click the common area callback
onAdCreativeClick() Click on creative area callback
onAdShow() Advertising display callback

TTDrawFeedAd advertising object description

/**
* 设置是否允许视频区域响应点击,并且暂停/继续播放
*
* @param canInterruptVideoPlay true 可以影响点击, 默认为false
*/
void setCanInterruptVideoPlay(boolean canInterruptVideoPlay);

/**
* 设置暂停图标和大小
*
* @param pauseIcon
* @param size  单位为dp, 20 到 200之间,默认为 50
*/
void setPauseIcon(Bitmap pauseIcon, int size);

Draw video monitoring

//点击监听器必须在getAdView之前调用
ad.setDrawVideoListener(new TTDrawFeedAd.DrawVideoListener() {
	/**
     * 点击重试按钮
     */
    @Override
    public void onClickRetry() {

    }
	/**
    * 点击查看详情或下载按钮
    */
    @Override
    public void onClick() {

    }
});

DrawVideoListener description

Method Description
onClickRetry() Callback for ad click retry
onClick() Click on the ad to view details or download callbacks

Destroy advertising objects

Destroy the ad view in the onDestroy callback method of Activity

//在Activity的onDestroy方法中清空广告对象
@Override
protected void onDestroy() {
    super.onDestroy();
    if (ad != null) {
        ad = null;
    }
}

Reference Demo

For native Draw ads, please refer to the DrawNativeVideoActivity example in Demo

Self-rendering Draw Note:

  1. AdInteractionListener involves advertising billing, and convertView must be called correctly. **ViewGroup must be used.

  2. Draw video does not support TTAdDislike logic

Did the content solve your problem?
Contact us