/** 获取音乐状态 */ private void getstate() { LogManager.e("request state and volume"); mWifiCRUDForMusic.playState( new ResultForMusicListener() { @Override public void onResult(String errorCode, List<WifiMusicInfo> infos) { if (infos != null) { LogManager.e( "state and volume result errorCode :" + errorCode + "data:" + new Gson().toJson(infos)); } else { LogManager.e("state and volume result errorCode :" + errorCode + "data:" + infos); } if (WifiCRUDUtil.isSuccess(errorCode) && infos != null && !infos.isEmpty()) { Message msg = new Message(); msg.obj = infos.get(0); msg.what = HANDLE_GET_STATE_SUCCESS; mHandler.sendMessage(msg); } else { mHandler.sendEmptyMessage(HANDLE_GET_STATE_FAIL); } } }); }
private void handleResult(String errorCode, List<WifiMusicInfo> infos) { LogManager.e("音乐操作结果errorCode:" + errorCode); if (!WifiCRUDUtil.isSuccessAll(errorCode)) { mHandler.sendEmptyMessage(HANDLE_OPERATION_FAIL); } }
protected void updateView(WifiMusicInfo info) { currMusicInfo = info; if (System.currentTimeMillis() - collectTime > changeButtonStateDelayed) { if (currMusicInfo.is_isCollected()) { goodMusicBtn.setImageResource(R.drawable.player_good_music_pressed); } else { goodMusicBtn.setImageResource(R.drawable.player_good_music_selector); } } String currState = info.getPlayStatus(); if (MUSIC_STATE_DLAN.equals(currState)) { isDlanPlay = true; music_player_dlan.setVisibility(View.VISIBLE); music_player_normal.setVisibility(View.GONE); } else { isDlanPlay = false; music_player_dlan.setVisibility(View.GONE); music_player_normal.setVisibility(View.VISIBLE); String currMusicName = info.getName() != null ? info.getName() : ""; String currSinger = info.getAuthor() != null ? info.getAuthor() : ""; int currVolume = info.getMusicCurrVolume() - 1; int maxVolume = info.getMusicMaxVolume() - 1; LogManager.e("volume :" + currVolume + "," + maxVolume); if (maxVolume != seekBar.getMax()) { seekBar.setMax(maxVolume); } if (System.currentTimeMillis() - volumeChangeTime > changeButtonStateDelayed) { if (currVolume != seekBar.getProgress()) { seekBar.setTag("unchange"); seekBar.setProgress(currVolume); } } if (!isOperateButton) { if (MUSIC_STATE_STOP.equals(currState) || MUSIC_STATE_PAUSE.equals(currState)) { if (!"".equals(getPrefString(KeyList.PKEY_SELECT_MUSIC_ID))) { setPrefString(KeyList.PKEY_SELECT_MUSIC_ID, ""); } playerRoundIv.pauseRound(); playerOperate.release(); playOrPause.setBackgroundResource(R.drawable.player_play_btn_selector); } else if (MUSIC_STATE_PLAYING.equals(currState)) { if (info.getMusicId() != null && !info.getMusicId().equals(getPrefString(KeyList.PKEY_SELECT_MUSIC_ID))) { setPrefString(KeyList.PKEY_SELECT_MUSIC_ID, info.getMusicId()); } playerOperate.startRound(); playerRoundIv.startRound(); playOrPause.setBackgroundResource(R.drawable.player_pause_btn_selector); } } // } if (!currMusicName.equals(musicName)) { playerMainLayout.setBackgroundDrawable(getBgRandom(playerMainLayout)); songTv.setText(currMusicName); } if (!currSinger.equals(singer)) { singerTv.setText(currSinger); } musicName = currMusicName; singer = currSinger; } }