From: luozheng <1732036298@qq.com> Date: Sat, 7 Dec 2024 09:19:08 +0000 (+0800) Subject: 音乐播放器: X-Git-Tag: v1.3.113-repair_tp~143^2~16 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a064616c320a520d1856a564693b55f233d151ae;p=mirrors%2FFD230.git 音乐播放器: 1.解决applist音乐应用点击播放按钮播放音乐后,退出界面再进入,按钮变成暂停状态(通过设置按钮初值解决) 2.解决applist音乐应用点击播放按钮播放音乐后,退出界面再进入,音乐进度条未及时更新问题(通过设置进度条初值解决) --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h index 9710ac9da..fc2a79257 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-05 15:20:03 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-12-05 21:56:01 + * @LastEditTime: 2024-12-07 17:03:05 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h */ @@ -127,6 +127,7 @@ public: void showIdToMusicNameMapData(void); int getPreShowView(void); void setPreShowView(int index); + void updatePlayProgress(); // /* -------------------------------------------------------------------------- */ private: bool phonePlayButtonState{false}; 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 febe0e36e..6595ceb4b 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-12-05 20:38:46 + * @LastEditTime: 2024-12-07 17:06:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersView.h */ @@ -107,6 +107,7 @@ namespace OHOS void OnClickBackKeyToMainMusicPlayerView(void); void StopCurPlayingMusic(); void UpdateVolumeValue(void); + void initPlayProgress(void); VolumeSettingView *GetVolumeSettingView(); PlayerListDelSongView *GetPlayerListDelSongView(); 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 7dd2ad83f..bf5da77ba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -901,6 +901,25 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } } + //更新音乐进度条 + void PlayersModel::updatePlayProgress() + { + // 获取当前播放时间 + PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime_); + // 获取音乐总时长 + PlayersModel::GetInstance()->GetDuration(playerMusicDuration_); + if (playerMusicDuration_!= 0) { + playerProgressValue_ = (playerCurrentTime_ * 100) / playerMusicDuration_; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerProgressValue_ %lld", playerProgressValue_); + } else { + playerProgressValue_ = 0; // 100: max progress value + } + // 设置圆形进度条进度 + PlayersModel::GetInstance()->SetCircleProgress(playerProgressValue_); + // 设置播放进度显示 + PlayersPresenter::GetInstance()->SetPlaybackProgress(playerProgressValue_); + } + void PlayersModel::SetCircleProgress() { PlayersView *playersView = PlayersView::GetInstance(); @@ -932,19 +951,7 @@ bool PlayersModel::GetCurrentMusicIsPlaying(void) } if (state_ == UICheckBox::UICheckBoxState::SELECTED) { - PlayersModel::GetInstance()->GetPlayerCtr()->GetCurrentTime(playerCurrentTime_); - PlayersModel::GetInstance()->GetDuration(playerMusicDuration_); - if (playerMusicDuration_ != 0) - { - playerProgressValue_ = (playerCurrentTime_ * 100) / playerMusicDuration_; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "playerProgressValue_ %lld", playerProgressValue_); - } - else - { - playerProgressValue_ = 0; // 100: max progress value - } - PlayersModel::GetInstance()->SetCircleProgress(playerProgressValue_); - PlayersPresenter::GetInstance()->SetPlaybackProgress(playerProgressValue_); + updatePlayProgress();//更新音乐进度条 } } else //如果当前为手机音乐 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 aa2a8ee43..1c99bb55a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersView.cpp @@ -664,6 +664,9 @@ namespace OHOS } } play_or_pause_Button->SetPosition(195, 195, 80, 80); + uint8_t state = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; + bool isplayingflag = PlayersModel::GetInstance()->GetCurrentMusicIsPlaying();//获取当前音乐是否是在播放中 + play_or_pause_Button->SetState(isplayingflag?UICheckBox::UICheckBoxState::SELECTED:UICheckBox::UICheckBoxState::UNSELECTED); play_or_pause_Button->SetOnClickListener(clickListener); return true; } @@ -876,6 +879,12 @@ namespace OHOS } } + //初始化音乐播放器的进度条 + void PlayersView::initPlayProgress(void) + { + PlayersModel::GetInstance()->updatePlayProgress(); + } + /// @brief 设置音乐播放模式按钮是否可点击 /// @param musicSourceType 音乐来源类型 false:手表音乐 true 手机音乐 /// @param phoneMusicConnectStatus 手机音乐连接状态 @@ -1047,6 +1056,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ UpdatePlayerView(); + initPlayProgress(); /* -------------------------------------------------------------------------- */ // PlayersListGroup::GetInstance()->SetUpListCase();