短剧

短剧

短剧API说明

ZJTubePageAd说明

@interface ZJTubePageAd : ZJAd

@property (nonatomic, strong,nullable) ZJTubePageAdapter *currentAdapter;
///视频状态代理
@property (nonatomic, weak) id <ZJContentPageVideoStateDelegate> videoStateDelegate;
///页面状态代理
@property (nonatomic, weak) id <ZJContentPageStateDelegate> stateDelegate;
/// 短剧内容加载结果代理
@property (nonatomic, weak) id <ZJContentPageLoadCallBackDelegate> loadCallBackDelegate;
/// 短剧播放器回调
@property (nonatomic, weak) id <ZJShortPlayPlayerDelegate> playerCallbackDelegate;
/// 广告回调
@property (nonatomic, weak) id <ZJShortPlayAdDelegate> adCallbackDelegate;
/// 业务接口回调
@property (nonatomic, weak) id <ZJShortPlayInterfaceDelegate> interfaceCallbackDelegate;
/// 自定义详情页cell试图回调
@property (nonatomic, weak) id <ZJShortPlayCustomViewDelegate> customViewCallBackDelegate;
/// 自定义Draw流的subview回调
@property (nonatomic, weak) id <ZJShortPlayCustomDrawAdViewDelegate> customDrawAdViewCallBackDelegate;
/// 滑滑溜底部自定义Banner广告
@property (nonatomic, weak) id <ZJShortPlayDrawVideoViewControllerBannerDelegate> drawVideoViewBannerCallbackDelegate;
/// 短剧相关配置
@property (nonatomic, strong) ZJTubePageConfig *tubePageConfig;

/// 短剧内容的控制器,媒体可以在广告加载成功之后,直接获取并展示
- (UIViewController *)tubePageViewController;

@end

ZJTubePageConfig说明

typedef NS_ENUM(NSInteger, ZJTubePageVideoProgressBarStyle) {//进度条样式
    ZJTubePageVideoProgressBarStyleLightContent     = 0,  // 浅色系
    ZJTubePageVideoProgressBarStyleDarkContent      = 1   // 深色系
};

// 需要展示的tab,默认全部展示
typedef NS_ENUM(NSInteger, ZJTubePageDrawVideoVCTabOptions) {
    ZJTubePageDrawVideoVCTabOptions_playlet       = 1 << 0, // 详情页Tab
    ZJTubePageDrawVideoVCTabOptions_playlet_feed  = 1 << 1, // 推荐Tab
    ZJTubePageDrawVideoVCTabOptions_theater       = 1 << 2, // 剧场Tab
};

// 广告类型
typedef NS_ENUM(NSInteger, ZJTubePageADType) {
    ZJTubePageADTypeInterstitial = 0,
    ZJTubePageADTypeRewardVideo = 1,
};

@interface ZJTubePageConfig : NSObject

/// 用户在穿山甲平台注册的应用,填写包名之后,下载的SDK参数配置的json文件,放在包中的路径
/// 申请流程:穿山甲管理平台->接入管理->内容输出->找到自己添加的应用->包名录入->下载SDK参数配置,添加到项目里,申请流程会有所变化
/// [[NSBundle mainBundle] pathForResource:@"SDK_Setting_5434885" ofType:@"json"]; 传这个路径
@property (nonatomic, copy) NSString *JSONConfigPath;

/*! @abstract 是否需要展示左上角的关闭按钮。 默认不展示 */
@property (nonatomic, assign) BOOL showCloseButton;

/*! @abstract 是否需要隐藏首次安装出现的引导手势图。 默认展示 */
@property (nonatomic, assign) BOOL hiddenGuideGeste;

/*! @abstract 展示VC的大小。 默认屏幕大小 */
@property (nonatomic, assign) CGSize viewSize;

/*! @abstract 外流进度条距离最低部的距离 */
@property (nonatomic, assign) CGFloat out_bottomOffset;
/*! @abstract 短剧内流进度条距离最低部的距离 */
@property (nonatomic, assign) CGFloat inner_playPlet_bottomOffset;
/*! @abstract 进度条的样式。 默认浅色系 */
@property (nonatomic, assign) ZJTubePageVideoProgressBarStyle progressBarStyle;
/// 隐藏底部跳转区域
@property (nonatomic, assign) BOOL hiddenPlayletEnterView;
/// 进入详情页方式 强制使用push 默认使用present
@property (nonatomic, assign) BOOL enterPlayPageUsePush;
//免费观看的集数n
@property (nonatomic, assign) NSInteger freeEpisodesCount;
//观看一次激励视频解锁的集数m
@property (nonatomic, assign) NSInteger unlockEpisodesCountUsingAD;
/// 隐藏点赞
@property (nonatomic) BOOL hideLikeIcon;
/// 隐藏收藏
@property (nonatomic) BOOL hideCollectIcon;
/// 短剧混排流中的免费短剧集数,默认为1集混排
@property (nonatomic, assign) NSInteger playletFreeCount;
/// 禁用双击点赞
@property (nonatomic) BOOL disableDoubleClickLike;
/// 禁用长按倍速
@property (nonatomic) BOOL disableLongPressSpeed;
/// 短剧播放详情页,表示在第几集后面插入自定义Draw广告, 如果没有设置短剧播放详情页,不需要设置
@property (nonatomic, copy, nullable) NSArray<NSNumber *> *customAdIndex;
/// 需要展示的tab,默认全部展示
@property (nonatomic, assign) ZJTubePageDrawVideoVCTabOptions drawVCTabOptions;
/// 是否隐藏频道tab,仅有一个tab时这个开关才生效
@property (nonatomic, assign) BOOL shouldHideTabBarView;

// ---------------是否配置代理,如果需要配置代理就要设置True,否则默认代理设置不生效-------------
/// 是否配置自定义详情页cell视图回调
@property (nonatomic, assign) BOOL configOrNotCustomViewDelegate;
/// 是否配置自定义详情页Draw广告
@property (nonatomic, assign) BOOL configOrNotCustomDrawAdViewDelegate;
/// 是否配置滑滑溜底部自定义Banner广告
@property (nonatomic, assign) BOOL configOrNotCustomBannerDelegate;

// ---------------自定义广告,--------------------------
/// 指定广告类型,目前支持自定义广告,插屏和激励视频两种
@property (nonatomic, assign) ZJTubePageADType adType;
/// 指定广告位ID
@property (nonatomic, copy) NSString *posId;

@end

代理事件说明

  1. 视频状态代理 ZJContentPageVideoStateDelegate videoStateDelegate;
@optional
/**
 * 视频开始播放
 * @param videoContent 内容模型
 */
- (void)zj_videoDidStartPlay:(id<ZJContentInfo>)videoContent;
/**
* 视频暂停播放
* @param videoContent 内容模型
*/
- (void)zj_videoDidPause:(id<ZJContentInfo>)videoContent;
/**
* 视频恢复播放
* @param videoContent 内容模型
*/
- (void)zj_videoDidResume:(id<ZJContentInfo>)videoContent;
/**
* 视频停止播放
* @param videoContent 内容模型
* @param finished     是否播放完成
*/
- (void)zj_videoDidEndPlay:(id<ZJContentInfo>)videoContent isFinished:(BOOL)finished;
/**
* 视频播放失败
* @param videoContent 内容模型
* @param error        失败原因
*/
- (void)zj_videoDidFailedToPlay:(id<ZJContentInfo>)videoContent withError:(NSError *)error;

  1. 页面状态代理 ZJContentPageStateDelegate stateDelegate
/**
* 内容展示
* @param content 内容模型
*/
- (void)zj_contentDidFullDisplay:(id<ZJContentInfo>)content;
/**
* 内容隐藏
* @param content 内容模型
*/
- (void)zj_contentDidEndDisplay:(id<ZJContentInfo>)content;
/**
* 内容暂停显示,ViewController disappear或者Application resign active
* @param content 内容模型
*/
- (void)zj_contentDidPause:(id<ZJContentInfo>)content;
/**
* 内容恢复显示,ViewController appear或者Application become active
* @param content 内容模型
*/
- (void)zj_contentDidResume:(id<ZJContentInfo>)content;

/// 任务完成回调
- (void)zjAdapter_contentTaskComplete:(id<ZJContentInfo>)content;
  1. 短剧播放器回调 ZJShortPlayPlayerDelegate playerCallbackDelegate
/*! @abstract 视频切换时的回调 */
- (void)zj_shortplayDrawVideoCurrentVideoChanged:(NSInteger)index adapter:(id<ZJContentInfo>)content;

/*! @abstract 加载失败按钮点击重试回调 */
- (void)zj_shortplayDrawVideoDidClickedErrorButtonRetry:(id<ZJContentInfo>)content;

/*! @abstract 默认关闭按钮被点击的回调 */
- (void)zj_shortplayDrawVideoCloseButtonClicked:(id<ZJContentInfo>)content;

/*! @abstract 数据刷新完成回调 */
- (void)zj_shortplayDrawVideoDataRefreshCompletion:(NSError *)error content:(id<ZJContentInfo>)content;

/*! @abstract tab栏切换控制器的回调*/
- (void)zj_shortplayPageViewControllerSwitchToIndex:(NSInteger)index content:(id<ZJContentInfo>)content;

/**! @abstract 推荐页面底部banner视图**/
- (UIView *)zj_shortplayDrawVideoVCBottomBannerView:(UIViewController *)vc content:(id<ZJContentInfo>)content;
  1. 广告回调 ZJShortPlayAdDelegate adCallbackDelegate
/*! @abstract 发起广告请求 */
- (void)zj_shortplaySendAdRequest:(id<ZJContentInfo>)content;

/*! @abstract 广告加载成功 */
- (void)zj_shortplayAdLoadSuccess:(id<ZJContentInfo>)content;

/*! @abstract 广告加载失败 */
- (void)zj_shortplayAdLoadFail:(id<ZJContentInfo>)content error:(NSError *)error;

/*! @abstract 广告填充失败 */
- (void)zj_shortplayAdFillFail:(id<ZJContentInfo>)content;

/*! @abstract 广告曝光 */
- (void)zj_shortplayAdWillShow:(id<ZJContentInfo>)content;

/*! @abstract 视频广告开始播放 */
- (void)zj_shortplayVideoAdStartPlay:(id<ZJContentInfo>)content;

/*! @abstract 视频广告暂停播放 */
- (void)zj_shortplayVideoAdPause:(id<ZJContentInfo>)content;

/*! @abstract 视频广告继续播放 */
- (void)zj_shortplayVideoAdContinue:(id<ZJContentInfo>)content;

/*! @abstract 视频广告停止播放 */
- (void)zj_shortplayVideoAdOverPlay:(id<ZJContentInfo>)content;

/*! @abstract 点击广告 */
- (void)zj_shortplayClickAdViewEvent:(id<ZJContentInfo>)content;
/*! @abstract 广告缓冲 */
- (void)zj_shortplayVideoBufferEvent:(id<ZJContentInfo>)content;

/*! @abstract 激励视频广告结束 */
- (void)zj_shortplayVideoRewardFinishEvent:(id<ZJContentInfo>)content;

/*! @abstract 激励视频广告跳过 */
- (void)zj_shortplayVideoRewardSkipEvent:(id<ZJContentInfo>)content;
  1. 业务接口回调 ZJShortPlayInterfaceDelegate interfaceCallbackDelegate
/*! @abstract 解锁流程开始 */
- (void)zj_shortplayPlayletDetailUnlockFlowStart:(id<ZJContentInfo>)content;

/*! @abstract 解锁流程取消 */
- (void)zj_shortplayPlayletDetailUnlockFlowCancel:(id<ZJContentInfo>)content;

/**设置是否需要自定义解锁视图,返回NO即为不需要自定义解锁视图 */
- (BOOL)zj_shortplayPlayletDetailCustomUnlockView;

/*! @abstract 解锁流程结束,回调解锁结果
 *  - success: 是否解锁成功
 *   - error: 解锁失败错误信息
 */
- (void)zj_shortplayPlayletDetailUnlockFlowEnd:(id<ZJContentInfo>)content
                           success:(BOOL)success
                             error:(NSError * _Nullable)error;

/*! @abstract 点击混排中进入跳转播放页的按钮 */
- (void)zj_shortplayClickEnterView:(id<ZJContentInfo>)content;

/*! @abstract 本剧集观看完毕,切到下一部短剧回调 */
- (void)zj_shortplayNextPlayletWillPlay:(id<ZJContentInfo>)content;

- (UIView *)zj_shortplayPlayletDetailBottomBanner:(id<ZJContentInfo>)content;
  1. 自定义详情页cell试图回调 ZJShortPlayCustomViewDelegate customViewCallBackDelegate
/// 创建自定义View直接返回,外部不要持有,cell自己持有复用
/// @param cell 短剧的cell
- (UIView *)zj_shortplayPlayletDetailCellCustomView:(UITableViewCell *)cell;

/// 根据数据更新UI
/// @param cell 短剧的cell
/// @param customView `djx_playletDetailCellCustomView:`返回的自定义View,短剧的cell内部会持有
/// @param playletInfo 短剧的数据
- (void)zj_shortplayPlayletDetailCell:(UITableViewCell *)cell updateCustomView:(UIView *)customView withPlayletData:(id)playletInfo;

/// 当cell执行到layoutSubviews时会回调此协议方法
/// @param cell 短剧的cell
/// @param customView `djx_playletDetailCellCustomView:`返回的自定义View
- (void)zj_shortplayPlayletDetailCell:(UITableViewCell *)cell layoutSubviews:(UIView *)customView;

/// 当cell执行到layoutSubviews后会回调此协议方法
/// @param cell 短剧的cell
/// @param customView `djx_playletDetailCellCustomView:`返回的自定义View
- (void)zj_shortplayPlayletDetailCell:(UITableViewCell *)cell afterLayoutSubviews:(UIView *)customView;
  1. 自定义Draw流的subview回调 ZJShortPlayCustomDrawAdViewDelegate customDrawAdViewCallBackDelegate
- (UIView *)zj_shortplayDetailCellCreateAdView:(UITableViewCell *)cell adInputIndex:(NSUInteger)adIndex;

- (void)zj_shortplayDetailCell:(UITableViewCell *)cell bindDataToDrawAdView:(UIView *)drawAdView adInputIndex:(NSUInteger)adIndex;

- (void)zj_shortplayDetailCell:(UITableViewCell *)cell layoutSubview:(UIView *)drawAdView adInputIndex:(NSUInteger)adIndex;

- (void)zj_shortplayDetailCell:(UITableViewCell *)cell willDisplayDrawAdView:(UIView *)drawAdView adInputIndex:(NSUInteger)adIndex;

- (void)zj_shortplayDetailCell:(UITableViewCell *)cell didEndDisplayDrawAdView:(UIView *)drawAdView adInputIndex:(NSUInteger)adIndex;
  1. 滑滑溜底部自定义Banner广告 ZJShortPlayDrawVideoViewControllerBannerDelegate drawVideoViewBannerCallbackDelegate
- (UIView *)zj_shortplayDrawVideoVCBottomBannerView:(UIViewController *)vc;
  1. 短剧内容加载结果代理 ZJContentPageLoadCallBackDelegate loadCallBackDelegate
// 内容加载成功
- (void)zj_contentPageLoadSuccess;

// 内容加载失败
- (void)zj_contentPageLoadFailure:(NSError *)error;

加载短剧内容代码示例

// 加载广告
ZJTubePageConfig *config = [[ZJTubePageConfig alloc] init];
config.JSONConfigPath = [[NSBundle mainBundle] pathForResource:@"SDK_Setting_5434885" ofType:@"json"];
config.freeEpisodesCount = 5;
config.unlockEpisodesCountUsingAD = 5;
//用来指定加载ZJ广告,如果不设置,默认加载的穿山甲自带广告,如果要设置需要同时设置adType和posId两个字段的值,支持加载激励和插屏广告
//config.adType = ZJTubePageADTypeRewardVideo;
//config.posId = @"KS90010001";
config.adType = ZJTubePageADTypeInterstitial;
config.posId = @"J7311893871";
//config.hideLikeIcon = YES;
//config.hideCollectIcon = YES;
config.showCloseButton = YES;
//CGFloat contentY = [UIApplication sharedApplication].statusBarFrame.size.height+self.navigationController.navigationBar.frame.size.height;
//config.viewSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height - contentY);
//config.configOrNotCustomViewDelegate = YES;
//config.configOrNotCustomDrawAdViewDelegate = YES;
//config.configOrNotCustomBannerDelegate = YES;
//config.customAdIndex = @[@0, @1];
self.tubePageAd = [[ZJTubePageAd alloc]initWithPlacementId:adId];
self.tubePageAd.tubePageConfig = config;
self.tubePageAd.videoStateDelegate = self;
self.tubePageAd.stateDelegate = self;
self.tubePageAd.loadCallBackDelegate = self;
/// 短剧播放器回调
self.tubePageAd.playerCallbackDelegate = self;
/// 广告回调
self.tubePageAd.adCallbackDelegate = self;
/// 业务接口回调
self.tubePageAd.interfaceCallbackDelegate = self;
/// 自定义详情页cell试图回调
self.tubePageAd.customViewCallBackDelegate = self;
/// 自定义Draw流的subview回调
self.tubePageAd.customDrawAdViewCallBackDelegate = self;
/// 滑滑溜底部自定义Banner广告
self.tubePageAd.drawVideoViewBannerCallbackDelegate = self;
[self.tubePageAd loadAd];

// 展示广告
self.weakTubeVC = self.tubePageAd.tubePageViewController;
// 快手只能push
if (self.tubePageAd.currentAdapter.config.platformType == ZJAdPlatform_KS) {
    [self addChildViewController:self.weakTubeVC];
    [self.view addSubview:self.weakTubeVC.view];
} else {
    // 穿山甲目前用presentViewController的方式
    [self presentViewController:self.weakTubeVC animated:YES completion:^{
        
    }];
}