类 TsPlayer.Builder
- java.lang.Object
-
- com.ts.lib.player.TsPlayer.Builder
-
- 封闭接口:
- TsPlayer
@AnyThread public static final class TsPlayer.Builder extends Object
播放器实例构建类
-
-
构造器概要
构造器 构造器 说明 Builder(Context context)播放器构造BuilderBuilder(Context context, LifecycleOwner lifecycleOwner)播放器构造BuilderBuilder(Context context, LifecycleOwner lifecycleOwner, CacheProxyFactory cacheProxyFactory)播放器构造BuilderBuilder(Context context, CacheProxyFactory cacheProxyFactory)播放器构造Builder
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 TsPlayerbuild()构建播放器 优先级: 1.TsPlayerbuildTsExoPlayer()构建以 ExoPlayer 作为播放引擎的播放器。TsPlayerbuildTsIjkPlayer()构建以 IjkPlayer 作为播放引擎的播放器TsPlayer.BuilderenableCache()开启网络视频缓存,边下边播。TsPlayer.BuildersetCacheProxyFactory(CacheProxyFactory cacheProxyFactory)自己制定缓存代理TsPlayer.BuildersetLifecycleOwner(LifecycleOwner lifecycleOwner)设置生命周期ownerTsPlayer.BuildersetLooper(Looper looper)设置player播放事件的回调所在的Looper
-
-
-
构造器详细资料
-
Builder
public Builder(@NonNull Context context, @Nullable LifecycleOwner lifecycleOwner)
播放器构造Builder- 参数:
context-ContextlifecycleOwner-lifecycleOwner非必选,可为 null,暂时无用
-
Builder
public Builder(@NonNull Context context, @NonNull CacheProxyFactory cacheProxyFactory)
播放器构造Builder- 参数:
context-ContextcacheProxyFactory-CacheProxyFactory,如需改变默认缓存配置策略,或者使用自定义缓存代理,可实现此Factory
-
Builder
public Builder(@NonNull Context context, @Nullable LifecycleOwner lifecycleOwner, @NonNull CacheProxyFactory cacheProxyFactory)
播放器构造Builder- 参数:
context-ContextlifecycleOwner-LifecycleOwner非必选,可为 null,暂时无用cacheProxyFactory-CacheProxyFactory,如需改变默认缓存配置策略,或者使用自定义缓存代理,可实现此Factory
-
-
方法详细资料
-
setLooper
public TsPlayer.Builder setLooper(@Nullable Looper looper)
设置player播放事件的回调所在的LooperNote: 如果未设置,默认使用调用线程的Looper,如果调用线程的Looper为空, 则使用主线程的Looper,意味着播放器事件将在主线程回调
- 参数:
looper-Looper- 返回:
TsPlayer.Builder
-
setLifecycleOwner
public TsPlayer.Builder setLifecycleOwner(@Nullable LifecycleOwner lifecycleOwner)
设置生命周期owner- 参数:
lifecycleOwner-LifecycleOwner- 返回:
TsPlayer.Builder
-
setCacheProxyFactory
public TsPlayer.Builder setCacheProxyFactory(@NonNull CacheProxyFactory cacheProxyFactory)
自己制定缓存代理- 参数:
cacheProxyFactory-CacheProxyFactory,如需改变默认缓存配置策略,或者使用自定义缓存代理,可实现此Factory- 返回:
TsPlayer.Builder
-
enableCache
public TsPlayer.Builder enableCache()
开启网络视频缓存,边下边播。默认未开启- 返回:
TsPlayer.Builder
-
build
@AnyThread public TsPlayer build()
构建播放器- 优先级:
- 1. 如果有集成 engine-exo module 则会使用ExoPlayer
- 2. 如果无 engine-exo module,而有engine-ijk module则会使用IjkPlayer
- 返回:
TsPlayer
-
buildTsExoPlayer
@AnyThread @Nullable @CheckResult public TsPlayer buildTsExoPlayer()
构建以 ExoPlayer 作为播放引擎的播放器。注意: 必须集成engine-exo module,否则返回
null- 返回:
TsPlayer
-
buildTsIjkPlayer
@AnyThread @Nullable @CheckResult public TsPlayer buildTsIjkPlayer()
构建以 IjkPlayer 作为播放引擎的播放器注意: 必须集成engine-ijk module,否则返回
null- 返回:
TsPlayer
-
-