|
|
@ -174,28 +174,30 @@ void CMusicPlayer::playSongs (const std::vector<std::string> &filenames)
|
|
|
|
|
|
|
|
|
|
|
|
// If pause, stop, else play will resume
|
|
|
|
// If pause, stop, else play will resume
|
|
|
|
if (_State == Paused || _Songs.empty())
|
|
|
|
if (_State == Paused || _Songs.empty())
|
|
|
|
_State = Stopped;
|
|
|
|
stop();
|
|
|
|
|
|
|
|
|
|
|
|
// get song title/duration using worker thread
|
|
|
|
// get song title/duration using worker thread
|
|
|
|
MusicPlayerWorker.getSongsInfo(filenames);
|
|
|
|
MusicPlayerWorker.getSongsInfo(filenames);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CMusicPlayer::updatePlaylist(sint prevIndex)
|
|
|
|
void CMusicPlayer::updatePlaylist(uint index, bool state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CInterfaceElement *pIE;
|
|
|
|
if (index >= _Songs.size()) return;
|
|
|
|
std::string rowId;
|
|
|
|
|
|
|
|
|
|
|
|
std::string rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, index);
|
|
|
|
|
|
|
|
CInterfaceElement *pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
|
|
|
|
|
|
|
|
if (pIE) pIE->setActive(state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CMusicPlayer::updatePlaylist(sint prevIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (prevIndex >= 0 && prevIndex < _Songs.size())
|
|
|
|
if (prevIndex >= 0 && prevIndex < _Songs.size())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, prevIndex);
|
|
|
|
updatePlaylist(prevIndex, false);
|
|
|
|
pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
|
|
|
|
|
|
|
|
if (pIE) pIE->setActive(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rowId = toString("%s:s%d:bg", MP3_PLAYER_PLAYLIST_LIST, _CurrentSongIndex);
|
|
|
|
updatePlaylist(_CurrentSongIndex, true);
|
|
|
|
pIE = dynamic_cast<CInterfaceElement*>(CWidgetManager::getInstance()->getElementFromId(rowId));
|
|
|
|
|
|
|
|
if (pIE) pIE->setActive(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
@ -361,7 +363,7 @@ void CMusicPlayer::play (sint index)
|
|
|
|
|
|
|
|
|
|
|
|
if (_Songs.empty())
|
|
|
|
if (_Songs.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_State = Stopped;
|
|
|
|
stop();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -437,6 +439,8 @@ void CMusicPlayer::stop ()
|
|
|
|
_PlayStart = 0;
|
|
|
|
_PlayStart = 0;
|
|
|
|
_PauseTime = 0;
|
|
|
|
_PauseTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clearPlayingInfo();
|
|
|
|
|
|
|
|
|
|
|
|
NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MP3_PLAYING")->setValueBool(false);
|
|
|
|
NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:MP3_PLAYING")->setValueBool(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -472,12 +476,38 @@ void CMusicPlayer::next ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CMusicPlayer::updatePlayingInfo(const std::string info)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
|
|
|
|
|
|
|
|
if (pVT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pVT->setText(ucstring::makeFromUtf8(info));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CMusicPlayer::clearPlayingInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_Songs.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
updatePlayingInfo(CI18N::get("uiNoFiles").toUtf8());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
updatePlayingInfo("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
void CMusicPlayer::update ()
|
|
|
|
void CMusicPlayer::update ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!SoundMngr)
|
|
|
|
if(!SoundMngr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_State != Stopped)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_State = Stopped;
|
|
|
|
_State = Stopped;
|
|
|
|
|
|
|
|
clearPlayingInfo();
|
|
|
|
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -488,8 +518,6 @@ void CMusicPlayer::update ()
|
|
|
|
|
|
|
|
|
|
|
|
if (_State == Playing)
|
|
|
|
if (_State == Playing)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CViewText *pVT = dynamic_cast<CViewText*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
|
|
|
|
|
|
|
|
if (pVT)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TTime dur = (CTime::getLocalTime() - _PlayStart) / 1000;
|
|
|
|
TTime dur = (CTime::getLocalTime() - _PlayStart) / 1000;
|
|
|
|
uint min = (dur / 60) % 60;
|
|
|
|
uint min = (dur / 60) % 60;
|
|
|
@ -499,7 +527,7 @@ void CMusicPlayer::update ()
|
|
|
|
std::string title(toString("%02d:%02d", min, sec));
|
|
|
|
std::string title(toString("%02d:%02d", min, sec));
|
|
|
|
if (hour > 0) title = toString("%02d:", hour) + title;
|
|
|
|
if (hour > 0) title = toString("%02d:", hour) + title;
|
|
|
|
title += " " + _CurrentSong.Title;
|
|
|
|
title += " " + _CurrentSong.Title;
|
|
|
|
pVT->setText(ucstring::makeFromUtf8(title));
|
|
|
|
updatePlayingInfo(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (SoundMngr->isMusicEnded ())
|
|
|
|
if (SoundMngr->isMusicEnded ())
|
|
|
@ -520,8 +548,13 @@ void CMusicPlayer::update ()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SoundMngr->stopMusic(0);
|
|
|
|
// remove active highlight from playlist
|
|
|
|
_State = Stopped;
|
|
|
|
updatePlaylist(_CurrentSongIndex, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// restart from top on next 'play'
|
|
|
|
|
|
|
|
_CurrentSongIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|