From: luozheng <1732036298@qq.com> Date: Thu, 5 Dec 2024 13:19:46 +0000 (+0800) Subject: 解决音乐播放器中音乐列表播放状态UI显示问题:如,索引0的歌曲若在播放中,在删除其他音乐后,当前音乐播放状态会变成未播放状态。 X-Git-Tag: v1.3.113-repair_tp~143^2~24 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1494%2Fhead;p=mirrors%2FFD230.git 解决音乐播放器中音乐列表播放状态UI显示问题:如,索引0的歌曲若在播放中,在删除其他音乐后,当前音乐播放状态会变成未播放状态。 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h index e01aa52f5..9e8c3c976 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-12 18:24:31 + * @LastEditTime: 2024-12-05 21:03:56 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h */ @@ -44,7 +44,7 @@ namespace OHOS virtual ~PlayerListDelSongView(); static PlayerListDelSongView *GetInstance(void); UIViewGroup *CreatePlayerListDelSongView(); - void SetTheDelSongLabelStyle(const char *songName); + void SetTheDelSongLabelStyle(const char *songName,int index); void DeleteSongNameFile(void); UIButton *GetEnsureDeleteButton(void); UIButton *GetCancelDeleteButton(void); @@ -65,6 +65,7 @@ namespace OHOS UIButton *cancelDeleteButton{nullptr}; std::string delSongName; + int deleteSongIndex{0}; UIView::OnDragListener *dragListener{nullptr}; UIView::OnClickListener *buttonClickListener{nullptr}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h index 3d2eba03f..febe0e36e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-19 14:38:21 + * @LastEditTime: 2024-12-05 20:38:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -98,6 +98,7 @@ namespace OHOS PlayersCaseListAdapter *GetMusicListAdapter(void); UIList *GetMusicListList(void); + void RefreshMusicListList(void); UICircleProgress *GetPlaybackProgress(void); UICheckBox::UICheckBoxState GetPlayerButtonState(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp index 26e96a37a..37508333a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayerListDelSongView.cpp @@ -85,9 +85,10 @@ namespace OHOS /// @brief 设置歌曲名标签样式 /// @param songName 歌曲名 - void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName) + void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName,int index) { delSongName = songName; + deleteSongIndex = index; if (songNameLabel != nullptr) { songNameLabel->SetText(PlayersModel::GetInstance()->getHexMusicNameFromMusicName(songName).c_str()); @@ -103,7 +104,20 @@ namespace OHOS if (uapi_delete_files(path.c_str())) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", path.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Deleted file: %s successed!", path.c_str()); + int index = PlayersModel::GetInstance()->GetCurrentIndex(); + if(deleteSongIndex < index) + { + if(index - 1 < 0) + { + index = 0; + } + else + { + index--; + } + PlayersModel::GetInstance()->SetCurrentIndex(index); + } } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp index 3dfd4f59c..9fc2d1280 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersCaseListAdapter.cpp @@ -56,7 +56,7 @@ namespace OHOS playersView->ChangeView(PlayersView::MUSIC_LIST_VIEW, PlayersView::MUSIC_DELETE_VIEW); if (playersView->GetPlayerListDelSongView()) { - playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName); + playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName, view.GetViewIndex()); } return true; } @@ -105,6 +105,7 @@ namespace OHOS } PlayersModel::GetInstance()->PlayerStat(); } + playersView->RefreshMusicListList();//刷新音乐列表 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index = %d ,uri = %s.", PlayersModel::GetInstance()->GetCurrentIndex(), PlayersModel::GetInstance()->GetPlayerUri().c_str()); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp index 041edf4f8..1cde3a627 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -181,16 +181,6 @@ void PlayersModel::SetCurrentIndex(int16_t value) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayersModel::SetCurrentIndex,value = %d",value); currentIndex = value; - /* --------------------------------- 刷新音乐列表 --------------------------------- */ - PlayersView *playersView = PlayersView::GetInstance(); - if (playersView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "playersView null!"); - return; - } - if(playersView->GetMusicListList()!=nullptr){ - playersView->GetMusicListList()->RefreshList(); - } - /* -------------------------------------------------------------------------- */ } int16_t PlayersModel::GetPlayerModel(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp index 2450e8042..987d0062d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersPresenter.cpp @@ -460,7 +460,7 @@ void PlayersListGroup::SetUpListCase() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "musicName = %s,index = %d",playerCaseInfo.sliceId,playerCaseInfo.index); playersCaseList_->PushBack(playerCaseInfo); } - PlayersModel::GetInstance()->showIdToMusicNameMapData(); + // PlayersModel::GetInstance()->showIdToMusicNameMapData();//关闭打印 } List& PlayersListGroup::GetCase() diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp index 3503e3393..8f2a9a7e4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -127,6 +127,15 @@ namespace OHOS return musicList; } + /*刷新音乐列表*/ + void PlayersView::RefreshMusicListList(void) + { + if(musicList) + { + musicList->RefreshList(); + } + } + /*获取音乐列表的适配器*/ PlayersCaseListAdapter *PlayersView::GetMusicListAdapter(void) {