Search in sources :

Example 31 with SongInfo

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));
                    }
                }
            }
        });
    }
}
Also used : Bitmap(android.graphics.Bitmap) AlbumArtCache(com.lzx.musiclibrary.utils.AlbumArtCache) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Aggregations

SongInfo (com.lzx.musiclibrary.aidl.model.SongInfo)31 ArrayList (java.util.ArrayList)9 AlbumInfo (com.lzx.musiclibrary.aidl.model.AlbumInfo)6 List (java.util.List)5 JSONObject (org.json.JSONObject)5 Uri (android.net.Uri)4 RetrofitHelper (com.lzx.nicemusic.network.RetrofitHelper)4 JSONArray (org.json.JSONArray)4 Cursor (android.database.Cursor)3 Gson (com.google.gson.Gson)3 LogUtil (com.lzx.musiclibrary.utils.LogUtil)3 BasePresenter (com.lzx.nicemusic.base.mvp.factory.BasePresenter)3 DataHelper (com.lzx.nicemusic.helper.DataHelper)3 Observable (io.reactivex.Observable)3 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)3 Disposable (io.reactivex.disposables.Disposable)3 Schedulers (io.reactivex.schedulers.Schedulers)3 Bitmap (android.graphics.Bitmap)2 AnimationDrawable (android.graphics.drawable.AnimationDrawable)2 Bundle (android.os.Bundle)2