use of com.lzx.musiclibrary.aidl.model.SongInfo in project MusicLibrary by lizixian18.
the class QueueManager method updateMetadata.
/**
* 更新媒体信息
*/
public void updateMetadata() {
SongInfo currentMusic = getCurrentMusic();
if (currentMusic == null) {
if (mListener != null) {
mListener.onMetadataRetrieveError();
}
return;
}
final String musicId = currentMusic.getSongId();
SongInfo metadata = QueueHelper.getMusicInfoById(mPlayingQueue, musicId);
if (metadata == null) {
throw new IllegalArgumentException("Invalid musicId " + musicId);
}
if (!TextUtils.isEmpty(metadata.getSongCover())) {
String coverUri = metadata.getSongCover();
// 获取图片bitmap
AlbumArtCache.getInstance().fetch(coverUri, new AlbumArtCache.FetchListener() {
@Override
public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
updateSongCoverBitmap(musicId, bitmap, icon);
SongInfo currentMusic = getCurrentMusic();
if (currentMusic == null) {
return;
}
String currentPlayingId = currentMusic.getSongId();
if (musicId.equals(currentPlayingId)) {
if (mListener != null) {
mListener.onMetadataChanged(QueueHelper.getMusicInfoById(mPlayingQueue, currentPlayingId));
}
}
}
});
}
}
Aggregations