* @Author: luozheng 1732036298@qq.com
* @Date: 2024-08-05 15:20:03
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-12-05 21:03:56
+ * @LastEditTime: 2024-12-05 21:50:19
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayerListDelSongView.h
*/
virtual ~PlayerListDelSongView();
static PlayerListDelSongView *GetInstance(void);
UIViewGroup *CreatePlayerListDelSongView();
- void SetTheDelSongLabelStyle(const char *songName,int index);
+ void SetTheDelSongLabelStyle(const char *songName);
void DeleteSongNameFile(void);
UIButton *GetEnsureDeleteButton(void);
UIButton *GetCancelDeleteButton(void);
UIButton *cancelDeleteButton{nullptr};
std::string delSongName;
- int deleteSongIndex{0};
UIView::OnDragListener *dragListener{nullptr};
UIView::OnClickListener *buttonClickListener{nullptr};
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-08-05 15:20:03
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-11-28 11:04:43
+ * @LastEditTime: 2024-12-05 21:56:01
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/player/include/PlayersModel.h
*/
bool get_a2dp_sink_playing_state(void);
void HandPausePhoneMusic(void);
void HandPlayPhoneMusic(void);
+ std::string getcurrentplayingmusicname(void);
+ void setcurrentplayingmusicname(std::string name);
// /* -------------------------------------------------------------------------- */
std::unordered_map<uint16_t, std::pair<std::string,std::string>> &getIdToMusicNameMap(void);
std::string getRealMusicNameById(int id);
std::string getShowMusicNameById(int id);
uint16_t getIdFromMusicName(const std::string &musicName);
std::string getHexMusicNameFromMusicName(const std::string &musicName);
+ std::string getMusicNameFromHexMusicName(const std::string &musicName);
int getIdToMusicNameMapNumber(void);
void showIdToMusicNameMapData(void);
int getPreShowView(void);
void RandomPlayout(void);
void NextSong(int16_t index);
int16_t currentIndex{0}; //当前在播哪一首歌的索引
+ std::string currentplayingmusicname; //当前在播哪一首歌的名称
int16_t playerModel{0};
char *currentSongName{nullptr};
bool isStopAndReset{false};
/// @brief 设置歌曲名标签样式
/// @param songName 歌曲名
- void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName,int index)
+ void PlayerListDelSongView::SetTheDelSongLabelStyle(const char *songName)
{
delSongName = songName;
- deleteSongIndex = index;
if (songNameLabel != nullptr)
{
songNameLabel->SetText(PlayersModel::GetInstance()->getHexMusicNameFromMusicName(songName).c_str());
if (uapi_delete_files(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
{
playersView->ChangeView(PlayersView::MUSIC_LIST_VIEW, PlayersView::MUSIC_DELETE_VIEW);\r
if (playersView->GetPlayerListDelSongView())\r
{\r
- playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName, view.GetViewIndex());\r
+ playersView->GetPlayerListDelSongView()->SetTheDelSongLabelStyle(musicPlayName);\r
}\r
return true;\r
}\r
std::string strSrcMusic(APP_MUSIC_PATH);\r
std::string tempStr("/");\r
std::string strName = musicPlayName;\r
+ PlayersModel::GetInstance()->setcurrentplayingmusicname(musicPlayName); \r
PlayersModel::GetInstance()->SetPlayerUri(strSrcMusic + tempStr + strName); // 设置播放路径Uri\r
\r
state = playersView->GetPlayerButtonState();\r
{\r
item = static_cast<PlayerListItemView *>(inView);\r
}\r
- if (PlayersModel::GetInstance()->GetCurrentIndex() == index && PlayersModel::GetInstance()->GetCurrentMusicIsPlaying())\r
+ if (PlayersModel::GetInstance()->getcurrentplayingmusicname() == node->data_.sliceId && PlayersModel::GetInstance()->GetCurrentMusicIsPlaying())\r
{\r
item->UpdateItemViewStyle(true);\r
}\r
char strFile[BUFFER_SIZE] = "No music files";
sliceId = strFile;
}
+ currentplayingmusicname = sliceId;//记录当前播放的歌曲的名称
std::string strSongName = sliceId;
std::string pureName = strSongName.substr(0, strSongName.rfind("."));
const char *songName = pureName.c_str();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCase %d sliceId err!!!", index);
return;
}
+ currentplayingmusicname = sliceId;//记录当前播放的歌曲的名称
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetCase sliceId %s.", sliceId);
std::string strSrcMusic(APP_MUSIC_PATH);
std::string tempStr("/");
}
return "";
}
+
+ //根据UTF-8文件名查找对应的16进制文件名
+ std::string PlayersModel::getMusicNameFromHexMusicName(const std::string &musicName)
+ {
+ for (const auto &entry : idToMusicNameMap)
+ {
+ if (entry.second.second == musicName)
+ {
+ return entry.second.first; // 返回对应音乐名
+ }
+ }
+ return "";
+ }
//获取 idToMusicNameMap 的 zize 大小
int PlayersModel::getIdToMusicNameMapNumber(void)
{
preshowView = index;
}
+ //获取当前播放的音乐名字
+ std::string PlayersModel::getcurrentplayingmusicname()
+ {
+ return currentplayingmusicname;
+ }
+ //设置当前播放的音乐名字
+ void PlayersModel::setcurrentplayingmusicname(std::string name)
+ {
+ currentplayingmusicname = name;
+ }
}
#ifdef __cplusplus