added: show the track progress by making the line between the visualizer and the now playing text increasingly orange
This commit is contained in:
parent
0c826cbe7b
commit
c5309c6ec9
3 changed files with 62 additions and 3 deletions
|
@ -452,11 +452,15 @@ void CBitVis::SendData(int64_t time)
|
||||||
bool playingchanged;
|
bool playingchanged;
|
||||||
bool isplaying = false;
|
bool isplaying = false;
|
||||||
int volume = 0;
|
int volume = 0;
|
||||||
|
int elapsed = 0;
|
||||||
if (m_mpdclient)
|
if (m_mpdclient)
|
||||||
{
|
{
|
||||||
isplaying = m_mpdclient->IsPlaying(playingchanged);
|
isplaying = m_mpdclient->IsPlaying(playingchanged);
|
||||||
if (m_mpdclient->GetVolume(volume))
|
if (m_mpdclient->GetVolume(volume))
|
||||||
m_volumetime = GetTimeUs();
|
m_volumetime = GetTimeUs();
|
||||||
|
|
||||||
|
if (isplaying)
|
||||||
|
elapsed = Round32(m_mpdclient->GetElapsedState() * m_nrcolumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isplaying)
|
if (isplaying)
|
||||||
|
@ -486,6 +490,8 @@ void CBitVis::SendData(int64_t time)
|
||||||
if (y == nrlines - 1)
|
if (y == nrlines - 1)
|
||||||
{
|
{
|
||||||
line[x / 4] |= 1 << (pixelcounter * 2 + 1);
|
line[x / 4] |= 1 << (pixelcounter * 2 + 1);
|
||||||
|
if (x < elapsed)
|
||||||
|
line[x / 4] |= 1 << (pixelcounter * 2);
|
||||||
}
|
}
|
||||||
else if (x < m_displayvolume * m_nrcolumns / 100)
|
else if (x < m_displayvolume * m_nrcolumns / 100)
|
||||||
{
|
{
|
||||||
|
@ -524,10 +530,20 @@ void CBitVis::SendData(int64_t time)
|
||||||
|
|
||||||
pixel <<= 2;
|
pixel <<= 2;
|
||||||
|
|
||||||
if (Round32(currpeak.value) == y || y == 0)
|
if (y == 0)
|
||||||
|
{
|
||||||
pixel |= 2;
|
pixel |= 2;
|
||||||
|
if (x * 4 + i < elapsed)
|
||||||
|
pixel |= 1;
|
||||||
|
}
|
||||||
|
else if (Round32(currpeak.value) == y)
|
||||||
|
{
|
||||||
|
pixel |= 2;
|
||||||
|
}
|
||||||
else if (value > y)
|
else if (value > y)
|
||||||
|
{
|
||||||
pixel |= 1;
|
pixel |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (time - currpeak.time > 500000 && Round32(currpeak.value) > 0)
|
if (time - currpeak.time > 500000 && Round32(currpeak.value) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ CMpdClient::CMpdClient(std::string address, int port)
|
||||||
m_playingchanged = false;
|
m_playingchanged = false;
|
||||||
m_volume = 0;
|
m_volume = 0;
|
||||||
m_volumechanged = false;
|
m_volumechanged = false;
|
||||||
|
m_elapsedstate = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMpdClient::~CMpdClient()
|
CMpdClient::~CMpdClient()
|
||||||
|
@ -147,8 +148,10 @@ bool CMpdClient::GetPlayStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Clear();
|
data.Clear();
|
||||||
bool isplaying = false;
|
bool isplaying = false;
|
||||||
int volume = -1;
|
int volume = -1;
|
||||||
|
double elapsed = -1.0;
|
||||||
|
double total = 0.0;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if (m_socket.Read(data) != SUCCESS)
|
if (m_socket.Read(data) != SUCCESS)
|
||||||
|
@ -182,6 +185,33 @@ bool CMpdClient::GetPlayStatus()
|
||||||
if (GetWord(tmpline, word) && StrToInt(word, parsevolume))
|
if (GetWord(tmpline, word) && StrToInt(word, parsevolume))
|
||||||
volume = parsevolume;
|
volume = parsevolume;
|
||||||
}
|
}
|
||||||
|
else if (word == "time:")
|
||||||
|
{
|
||||||
|
if (GetWord(tmpline, word))
|
||||||
|
{
|
||||||
|
size_t colon = word.find(':');
|
||||||
|
if (colon != string::npos && colon > 0 && colon < word.size() - 1)
|
||||||
|
{
|
||||||
|
double tmpelapsed;
|
||||||
|
double tmptotal;
|
||||||
|
|
||||||
|
if (elapsed < 0.0 && StrToFloat(word.substr(0, colon), tmpelapsed))
|
||||||
|
elapsed = tmpelapsed;
|
||||||
|
|
||||||
|
if (StrToFloat(word.substr(colon + 1), tmptotal) && tmptotal > 0.0)
|
||||||
|
total = tmptotal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (word == "elapsed:")
|
||||||
|
{
|
||||||
|
if (GetWord(tmpline, word))
|
||||||
|
{
|
||||||
|
double tmpelapsed;
|
||||||
|
if (StrToFloat(word, tmpelapsed))
|
||||||
|
elapsed = tmpelapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line == "OK")
|
if (line == "OK")
|
||||||
|
@ -201,6 +231,11 @@ bool CMpdClient::GetPlayStatus()
|
||||||
m_volumechanged = true;
|
m_volumechanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (total > 0.0 && elapsed >= 0.0)
|
||||||
|
m_elapsedstate = elapsed / total;
|
||||||
|
else
|
||||||
|
m_elapsedstate = 0.0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,6 +292,12 @@ bool CMpdClient::GetVolume(int& volume)
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double CMpdClient::GetElapsedState()
|
||||||
|
{
|
||||||
|
CLock lock(m_condition);
|
||||||
|
return m_elapsedstate;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CMpdClient::StripFilename(const std::string& filename)
|
std::string CMpdClient::StripFilename(const std::string& filename)
|
||||||
{
|
{
|
||||||
//strip any preceding directories
|
//strip any preceding directories
|
||||||
|
|
|
@ -18,6 +18,7 @@ class CMpdClient : public CThread
|
||||||
bool CurrentSong(std::string& song);
|
bool CurrentSong(std::string& song);
|
||||||
bool IsPlaying(bool& playingchanged);
|
bool IsPlaying(bool& playingchanged);
|
||||||
bool GetVolume(int& volume);
|
bool GetVolume(int& volume);
|
||||||
|
double GetElapsedState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OpenSocket();
|
bool OpenSocket();
|
||||||
|
@ -37,6 +38,7 @@ class CMpdClient : public CThread
|
||||||
bool m_playingchanged;
|
bool m_playingchanged;
|
||||||
int m_volume;
|
int m_volume;
|
||||||
bool m_volumechanged;
|
bool m_volumechanged;
|
||||||
|
double m_elapsedstate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue