use of com.lzx.musiclibrary.aidl.model.SongInfo in project MusicLibrary by lizixian18.
the class QueueManager method updateSongCoverBitmap.
/**
* 更新音乐艺术家信息
*
* @param musicId
* @param bitmap
* @param icon
*/
public void updateSongCoverBitmap(String musicId, Bitmap bitmap, Bitmap icon) {
SongInfo musicInfo = QueueHelper.getMusicInfoById(mPlayingQueue, musicId);
if (musicInfo == null) {
return;
}
musicInfo.setSongCoverBitmap(bitmap);
int index = mPlayingQueue.indexOf(musicInfo);
mPlayingQueue.set(index, musicInfo);
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project MusicLibrary by lizixian18.
the class PlayController method playMusicByIndex.
void playMusicByIndex(int index, boolean isJustPlay) {
if (mQueueManager.getPlayingQueue().size() == 0) {
return;
}
if (!QueueHelper.isIndexPlayable(index, mQueueManager.getPlayingQueue())) {
return;
}
SongInfo playInfo = mQueueManager.getPlayingQueue().get(index);
setCurrentQueueItem(playInfo, isJustPlay);
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class DialogMusicListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ItemHolder holder, int position) {
SongInfo info = mMusicInfos.get(position);
holder.mMusicTitle.setText(info.getSongName() + "(" + info.getAlbumInfo().getAlbumName() + ")" + " - " + info.getArtist());
AnimationDrawable animationDrawable = (AnimationDrawable) holder.mImageAnim.getDrawable();
if (MusicManager.isCurrMusicIsPlayingMusic(info)) {
holder.mMusicTitle.setTextColor(Color.parseColor("#BE0D36"));
holder.mImageAnim.setVisibility(View.VISIBLE);
if (MusicManager.isPlaying()) {
animationDrawable.start();
} else {
animationDrawable.stop();
}
} else {
holder.mMusicTitle.setTextColor(ContextCompat.getColor(mContext, R.color.font_color));
animationDrawable.stop();
holder.mImageAnim.setVisibility(View.INVISIBLE);
}
holder.mBtnDelete.setOnClickListener(v -> {
mDbManager.asyDeleteInfoInPlayList(info).subscribe(aBoolean -> {
boolean isPlayNext = MusicManager.isCurrMusicIsPlayingMusic(info);
MusicManager.get().deleteSongInfoOnPlayList(info, isPlayNext);
mMusicInfos.remove(info);
notifyItemRemoved(position);
if (position != mMusicInfos.size()) {
notifyItemRangeChanged(position, mMusicInfos.size() - position);
}
if (mMusicInfos.size() == 0) {
mContext.sendBroadcast(new Intent(Constans.ACTION_STOP_MUSIC));
}
}, throwable -> {
Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
});
});
holder.itemView.setOnClickListener(v -> {
SpUtil.getInstance().putString(Constans.LAST_PLAYING_MUSIC, info.getSongId());
MusicManager.get().playMusicByInfo(info);
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class DbManager method queryPlayList.
/**
* 获取播放列表
*
* @return
*/
private List<SongInfo> queryPlayList() {
Uri uri = MusicContentProvider.SONG_LIST_URI;
Cursor cursor = mResolver.query(uri, null, null, null, null);
if (cursor == null) {
return new ArrayList<>();
}
List<SongInfo> musicInfos = new ArrayList<>();
while (cursor.moveToNext()) {
String musicId = cursor.getString(cursor.getColumnIndex(DbConstants.MUSIC_ID));
String artist = cursor.getString(cursor.getColumnIndex(DbConstants.ARTIST));
String musicTitle = cursor.getString(cursor.getColumnIndex(DbConstants.MUSIC_TITLE));
String albumTitle = cursor.getString(cursor.getColumnIndex(DbConstants.ALBUM_TITLE));
long duration = cursor.getLong(cursor.getColumnIndex(DbConstants.DURATION));
String cover = cursor.getString(cursor.getColumnIndex(DbConstants.COVER));
String url = cursor.getString(cursor.getColumnIndex(DbConstants.URL));
SongInfo info = new SongInfo();
info.setSongId(musicId);
info.setArtist(artist);
info.setSongName(musicTitle);
info.setDuration(duration);
info.setSongCover(cover);
info.setSongUrl(url);
AlbumInfo albumInfo = new AlbumInfo();
albumInfo.setAlbumName(albumTitle);
info.setAlbumInfo(albumInfo);
musicInfos.add(info);
}
cursor.close();
return musicInfos;
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class DbManager method savePlayList.
/**
* 保存播放列表
*
* @param list
*/
private void savePlayList(List<SongInfo> list) {
clearPlayList();
Uri uri = MusicContentProvider.SONG_LIST_URI;
for (SongInfo info : list) {
if (info.getAlbumInfo() == null) {
throw new RuntimeException("albumInfo must not be null.");
}
ContentValues values = new ContentValues();
values.put(DbConstants.MUSIC_ID, info.getSongId());
values.put(DbConstants.ARTIST, info.getArtist());
values.put(DbConstants.MUSIC_TITLE, info.getSongName());
values.put(DbConstants.ALBUM_TITLE, info.getAlbumInfo().getAlbumName());
values.put(DbConstants.DURATION, info.getDuration());
values.put(DbConstants.COVER, info.getSongCover());
values.put(DbConstants.URL, info.getSongUrl());
mResolver.insert(uri, values);
}
}
Aggregations