Search in sources :

Example 1 with RadioList

use of com.ximalaya.ting.android.opensdk.model.live.radio.RadioList in project NiceMusic by lizixian18.

the class SongListPresenter method requestLiveList.

@Override
public void requestLiveList(String title) {
    int mRadioType = 2;
    int mProvinceCode = 360000;
    Map<String, String> map = new HashMap<String, String>();
    map.put(DTransferConstants.RADIOTYPE, "" + mRadioType);
    map.put(DTransferConstants.PROVINCECODE, "" + mProvinceCode);
    CommonRequest.getRadios(map, new IDataCallBack<RadioList>() {

        @Override
        public void onSuccess(RadioList object) {
            if (object != null && object.getRadios() != null) {
                List<SongInfo> musicInfos = new ArrayList<>();
                for (int i = 0; i < object.getRadios().size(); i++) {
                    Radio radio = object.getRadios().get(i);
                    SongInfo info = new SongInfo();
                    // 音乐id
                    info.setSongId(String.valueOf(radio.getDataId()));
                    // 音乐标题
                    info.setSongName(radio.getRadioName());
                    // 音乐封面
                    info.setSongCover(radio.getCoverUrlLarge());
                    // 音乐播放地址
                    info.setSongUrl(radio.getRate64AacUrl());
                    // 类型(流派)
                    info.setGenre(radio.getKind());
                    // 类型
                    info.setType(radio.getKind());
                    // 音乐大小
                    info.setSize("");
                    // 音乐长度
                    info.setDuration(0);
                    // 音乐艺术家
                    info.setArtist(radio.getRadioName());
                    // 媒体的曲目号码(序号:1234567……)
                    info.setTrackNumber(i);
                    AlbumInfo albumInfo = new AlbumInfo();
                    // 专辑id
                    albumInfo.setAlbumId(String.valueOf(radio.getDataId()));
                    // 专辑名称
                    albumInfo.setAlbumName(radio.getProgramName());
                    // 专辑封面
                    albumInfo.setAlbumCover(radio.getCoverUrlLarge());
                    // 专辑音乐数
                    albumInfo.setSongCount(0);
                    // 专辑播放数
                    albumInfo.setPlayCount(0);
                    info.setAlbumInfo(albumInfo);
                    musicInfos.add(info);
                }
                mView.onGetSongListSuccess(musicInfos, title);
                mView.onGetLiveSongSuccess(musicInfos);
            }
        }

        @Override
        public void onError(int code, String message) {
            LogUtil.i("直播 = " + message);
            Toast.makeText(mContext, "获取直播数据失败", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : RadioList(com.ximalaya.ting.android.opensdk.model.live.radio.RadioList) HashMap(java.util.HashMap) AlbumInfo(com.lzx.musiclibrary.aidl.model.AlbumInfo) ArrayList(java.util.ArrayList) RadioList(com.ximalaya.ting.android.opensdk.model.live.radio.RadioList) List(java.util.List) Radio(com.ximalaya.ting.android.opensdk.model.live.radio.Radio) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Aggregations

AlbumInfo (com.lzx.musiclibrary.aidl.model.AlbumInfo)1 SongInfo (com.lzx.musiclibrary.aidl.model.SongInfo)1 Radio (com.ximalaya.ting.android.opensdk.model.live.radio.Radio)1 RadioList (com.ximalaya.ting.android.opensdk.model.live.radio.RadioList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1