public class LiveProgress
extends java.lang.Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
LiveProgress.OnUpdateListener
用于监听播放器的实时播放进度更新。
|
| 构造器和说明 |
|---|
LiveProgress(PlayerClient playerClient,
LiveProgress.OnUpdateListener listener)
创建一个
LiveProgress 对象。 |
LiveProgress(PlayerClient playerClient,
LiveProgress.OnUpdateListener listener,
boolean countDown)
创建一个
LiveProgress 对象。 |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
subscribe()
开始监听播放器实时播放进度的更新。
|
void |
subscribe(androidx.lifecycle.LifecycleOwner owner)
开始监听播放器实时播放进度的更新。
|
void |
unsubscribe()
取消监听实时播放进度。
|
public LiveProgress(@NonNull
PlayerClient playerClient,
@NonNull
LiveProgress.OnUpdateListener listener)
LiveProgress 对象。playerClient - PlayerClient 对象,不能为 nulllistener - LiveProgress.OnUpdateListener 监听器,用于监听实时播放进度,不能为 nullpublic LiveProgress(@NonNull
PlayerClient playerClient,
@NonNull
LiveProgress.OnUpdateListener listener,
boolean countDown)
LiveProgress 对象。playerClient - PlayerClient 对象,不能为 nulllistener - LiveProgress.OnUpdateListener 监听器,用于监听实时播放进度,不能为 nullcountDown - 是否是倒计时的实时播放进度。如果你需要倒计时的实时播放进度,则可以将该参数设为 true(默认为 false)public void subscribe()
unsubscribe() 方法取消监听,否则可能
会造成内存泄漏public void subscribe(@Nullable
androidx.lifecycle.LifecycleOwner owner)
unsubscribe() 方法取消监听,否则可能
会造成内存泄漏owner - LifecycleOwner 对象。当实时播放进度改变时,只会在 Lifecycle 处于 atLeastState
参数指示的状态时通知监听器,该参数可为 null。如果该参数不为 null,则会在 Lifecycle
的 ON_DESTROYED 事件发生时自动调用 unsubscribe() 方法取消监听实时
播放进度。这样可以避免内存泄漏。如果该参数为 null,则必须手动调用
unsubscribe() 方法取消监听,否则可能会造成内存泄漏subscribe()public void unsubscribe()
注意!如果你使用了不带参数的 subscribe() 方法或者 subscribe 方法的 LifecycleOwner 参数
为 null,则你必须调用该方法取消监听实时播放进度,否则可能会造成内存泄漏。