Skip to content

Use AriaContorlLayer

changsanjiang edited this page Nov 22, 2019 · 3 revisions

In this page:

files

AriaContorlLayer.zip

OC

桥接设置-Build Setting

  • 设置Product Name为工程名称
  • 设置Product Model Name名称
  • 创建工程名-Swift.h文件
  • 创建工程名-Bridging.h文件
  • 设置Objective-C Generated Interface Header Name
  • 设置Defines ModelYES
  • AriaVideoControlLayer文件夹整个拖入工程

工程名-Bridging.h

#import "SJVideoPlayer.h"
#import "SJUIKit.h"
#import "SJEdgeControlLayerAdapters.h"
#import "SJReachability.h"
#import "SJProgressSlider.h"
#import "UIView+SJAnimationAdded.h"
#import "SJEdgeControlLayerSettings.h"
#import "SJNetworkLoadingView.h"
#import "SJBarrageItem.h"
#import "SJVideoPlayerDraggingProgressView.h"
#import "SJTimerControl.h"

依赖库-Pod

pod 'Then'
pod 'SnapKit'
pod 'RxSwift'
pod 'RxDataSources'

开始使用

// 在需要使用控制层的地方引入该头文件
// ${Product Model Name}为第一步设置的名称
#import "${Product Model Name}-Swift.h"

// 添加控制层
[_player.switcher addControlLayerForIdentifier:${Identifier} lazyLoading:^id<SJControlLayer> _Nonnull(SJControlLayerIdentifier identifier) {
        AriaVideoControlLayer *controlLayer = [[AriaVideoControlLayer alloc] init];
        return controlLayer;
    }];

// 切换控制层
// ${Identifier} 如果为 LONG_MAX - 1 则为直接替换默认控制层无需切换
[_player.switcher switchControlLayerForIdentitfier:${Identifier}];

Swift

  • AriaVideoControlLayer文件夹整个拖入工程
// 添加控制层
player.switcher.addControlLayer(forIdentifier: ${Identifier}) { (id) -> SJControlLayer in
    return AriaVideoControlLayer()
}

// 切换控制层
// ${Identifier} 如果为 LONG_MAX - 1 则为直接替换默认控制层无需切换
player.switcher.switchControlLayer(forIdentitfier: ${Identifier})

依赖库-Pod

pod 'Then'
pod 'SnapKit'
pod 'RxSwift'
pod 'RxDataSources'

目前可设置内容

  • currentPlayIndex: 当前播放索引,默认为0
  • playListCount: 当前播放列表总数
  • playTheIndexBlock: 点击选集控制层选择对应集数后的回调,返回Int索引
  • shareBlock: 全屏时右上角分享按钮回调

当不设置playTheIndexBlock时设置currentPlayIndex与playListCount无任何意义 currentPlayIndex与playListCount设置后在播放下一集时需要手动更新一下currentPlayIndex