public class PlaylistLiveData extends androidx.lifecycle.LiveData<Playlist> implements Player.OnPlaylistChangeListener
PlayerClient
的播放列表。
情况下,PlaylistLiveData
是惰性的,它只会在 onActive 时开始监听 PlayerClient
的播放列表,
并且会在 onInactive 时自动取消对 PlayerClient
的播放列表的监听。
构造器和说明 |
---|
PlaylistLiveData(PlayerClient playerClient,
Playlist value)
创建一个
PlaylistLiveData 对象。 |
PlaylistLiveData(PlayerClient playerClient,
Playlist value,
boolean lazy)
创建一个
PlaylistLiveData 对象。 |
限定符和类型 | 方法和说明 |
---|---|
boolean |
isLazy()
当前 LiveData 是否是惰性的。
|
protected void |
onActive() |
protected void |
onInactive() |
void |
onPlaylistChanged(PlaylistManager playlistManager,
int position)
播放队列被替换或修改时会调用该方法。
|
public PlaylistLiveData(@NonNull PlayerClient playerClient, Playlist value)
PlaylistLiveData
对象。
使用该构造器创建的 PlaylistLiveData
对象默认是惰性的,只会在 onActive 时开始监听
PlayerClient
的播放列表,并且会在 onInactive 时自动取消对 PlayerClient
的播放列表的监听。
playerClient
- PlayerClient
对象,不能为 nullvalue
- LiveData 的初始化值public PlaylistLiveData(@NonNull PlayerClient playerClient, Playlist value, boolean lazy)
PlaylistLiveData
对象。playerClient
- PlayerClient
对象,不能为 nullvalue
- LiveData 的初始化值lazy
- 当前 LiveData 是否是惰性的。如果是,则只会在 onActive 时开始监听
PlayerClient
的播放列表,并且会在 onInactive 时自动取消对
PlayerClient
的播放列表的监听。public boolean isLazy()
protected void onActive()
onActive
在类中 androidx.lifecycle.LiveData<Playlist>
protected void onInactive()
onInactive
在类中 androidx.lifecycle.LiveData<Playlist>
public void onPlaylistChanged(PlaylistManager playlistManager, int position)
Player.OnPlaylistChangeListener
onPlaylistChanged
在接口中 Player.OnPlaylistChangeListener
playlistManager
- 用于管理播放队列的 PlaylistManager 对象。可以通过该对象获取到最新的播放队列。position
- 播放队列的播放位置。