Skip to content

Commit

Permalink
Add current playing time on LCD displays with 4 rows or more
Browse files Browse the repository at this point in the history
Patch from #9391, slightly massaged to fit master.

On LCD displays with 4 rows or more mythlcdserver uses only 3 rows (1, 2 and 4)
when watching a show (Channel, Title and a progress bar). This commit fills row
3 with "elapsed time / total time". I kept consistency with how mythmusic shows
the elapsed time. The time is only written when 4 or more rows are available.

Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information
mzanetti authored and Beirdo committed Jan 30, 2011
1 parent 22e48c4 commit 5c54c54
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
5 changes: 3 additions & 2 deletions mythtv/libs/libmythbase/lcddevice.cpp
Expand Up @@ -473,13 +473,14 @@ void LCD::setTunerLEDs(enum LCDTunerSet tuner, bool on)
sendToServer(QString("UPDATE_LEDS %1").arg(lcd_ledmask)); sendToServer(QString("UPDATE_LEDS %1").arg(lcd_ledmask));
} }


void LCD::setChannelProgress(float value) void LCD::setChannelProgress(const QString time, float value)
{ {
if (!lcd_ready || !lcd_showchannel) if (!lcd_ready || !lcd_showchannel)
return; return;


value = std::min(std::max(0.0f, value), 1.0f); value = std::min(std::max(0.0f, value), 1.0f);
sendToServer(QString("SET_CHANNEL_PROGRESS %1").arg(value)); sendToServer(QString("SET_CHANNEL_PROGRESS %1 %2").arg(quotedString(time))
.arg(value));
} }


void LCD::setGenericProgress(float value) void LCD::setGenericProgress(float value)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/lcddevice.h
Expand Up @@ -236,7 +236,7 @@ class MPUBLIC LCD : public QObject, public MythSocketCBs
// While watching Live/Recording/Pause Buffer, occasionaly describe how // While watching Live/Recording/Pause Buffer, occasionaly describe how
// much of the program has been seen (between 0.0 and 1.0) // much of the program has been seen (between 0.0 and 1.0)
// (e.g. [current time - start time] / [end time - start time] ) // (e.g. [current time - start time] / [end time - start time] )
void setChannelProgress(float percentViewed); void setChannelProgress(const QString time, float percentViewed);


// Show the Menu // Show the Menu
// QPtrList is a pointer to a bunch of menu items // QPtrList is a pointer to a bunch of menu items
Expand Down
11 changes: 9 additions & 2 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -2930,6 +2930,7 @@ bool TV::HandleLCDTimerEvent(void)
if (lcd) if (lcd)
{ {
float progress = 0.0f; float progress = 0.0f;
QString lcd_time_string;
bool showProgress = true; bool showProgress = true;


if (StateIsLiveTV(GetState(actx))) if (StateIsLiveTV(GetState(actx)))
Expand All @@ -2944,10 +2945,16 @@ bool TV::HandleLCDTimerEvent(void)
if (showProgress) if (showProgress)
{ {
osdInfo info; osdInfo info;
if (actx->CalcPlayerSliderPosition(info)) if (actx->CalcPlayerSliderPosition(info)) {
progress = info.values["position"] * 0.001f; progress = info.values["position"] * 0.001f;

lcd_time_string = info.text["playedtime"] + " / " + info.text["totaltime"];
// if the string is longer than the LCD width, remove all spaces
if (lcd_time_string.length() > (int)lcd->getLCDWidth())
lcd_time_string.remove(' ');
}
} }
lcd->setChannelProgress(progress); lcd->setChannelProgress(lcd_time_string, progress);
} }
ReturnPlayerLock(actx); ReturnPlayerLock(actx);


Expand Down
9 changes: 8 additions & 1 deletion mythtv/programs/mythlcdserver/lcdprocclient.cpp
Expand Up @@ -473,6 +473,7 @@ void LCDProcClient::init()
setPriority("Channel", LOW); setPriority("Channel", LOW);
sendToServer("widget_add Channel topWidget string"); sendToServer("widget_add Channel topWidget string");
sendToServer("widget_add Channel botWidget string"); sendToServer("widget_add Channel botWidget string");
sendToServer("widget_add Channel timeWidget string");
sendToServer("widget_add Channel progressBar hbar"); sendToServer("widget_add Channel progressBar hbar");


// The Generic Screen // The Generic Screen
Expand Down Expand Up @@ -1124,6 +1125,7 @@ void LCDProcClient::startChannel(QString channum, QString title, QString subtitl
formatScrollingWidgets(); formatScrollingWidgets();
} }


channel_time = "";
progress = 0.0; progress = 0.0;
outputChannel(); outputChannel();
} }
Expand Down Expand Up @@ -1679,12 +1681,13 @@ void LCDProcClient::setLevels(int numbLevels, float *values)
} }
} }


void LCDProcClient::setChannelProgress(float value) void LCDProcClient::setChannelProgress(const QString &time, float value)
{ {
if (!lcd_ready) if (!lcd_ready)
return; return;


progress = value; progress = value;
channel_time = time;


if (progress < 0.0) if (progress < 0.0)
progress = 0.0; progress = 0.0;
Expand Down Expand Up @@ -2160,6 +2163,9 @@ void LCDProcClient::outputChannel()
aString += " "; aString += " ";
aString += QString::number((int)rint(progress * lcdWidth * cellWidth)); aString += QString::number((int)rint(progress * lcdWidth * cellWidth));
sendToServer(aString); sendToServer(aString);

if (lcdHeight >= 4)
outputCenteredText("Channel", channel_time, "timeWidget", 3);
} }
else else
sendToServer("widget_set Channel progressBar 1 1 0"); sendToServer("widget_set Channel progressBar 1 1 0");
Expand Down Expand Up @@ -2313,6 +2319,7 @@ void LCDProcClient::removeWidgets()
{ {
sendToServer("widget_del Channel progressBar"); sendToServer("widget_del Channel progressBar");
sendToServer("widget_del Channel topWidget"); sendToServer("widget_del Channel topWidget");
sendToServer("widget_del Channel timeWidget");
sendToServer("screen_del Channel"); sendToServer("screen_del Channel");


sendToServer("widget_del Generic progressBar"); sendToServer("widget_del Generic progressBar");
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythlcdserver/lcdprocclient.h
Expand Up @@ -43,7 +43,7 @@ class LCDProcClient : public QObject
void setLevels(int numbLevels, float *values); void setLevels(int numbLevels, float *values);
void switchToChannel(QString channum = "", QString title = "", void switchToChannel(QString channum = "", QString title = "",
QString subtitle = ""); QString subtitle = "");
void setChannelProgress(float percentViewed); void setChannelProgress(const QString &time, float percentViewed);
void switchToMenu(QList<LCDMenuItem> *menuItems, QString app_name = "", void switchToMenu(QList<LCDMenuItem> *menuItems, QString app_name = "",
bool popMenu = true); bool popMenu = true);
void switchToGeneric(QList<LCDTextItem> *textItems); void switchToGeneric(QList<LCDTextItem> *textItems);
Expand Down Expand Up @@ -169,6 +169,7 @@ class LCDProcClient : public QObject


float EQlevels[10]; float EQlevels[10];
float progress; float progress;
QString channel_time;
/** true if the generic progress indicator is a busy /** true if the generic progress indicator is a busy
(ie. doesn't have a known total steps */ (ie. doesn't have a known total steps */
bool busy_progress; bool busy_progress;
Expand Down
6 changes: 3 additions & 3 deletions mythtv/programs/mythlcdserver/lcdserver.cpp
Expand Up @@ -579,7 +579,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket


QString flat = tokens.join(" "); QString flat = tokens.join(" ");


if (tokens.count() != 2) if (tokens.count() != 3)
{ {
VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_CHANNEL_PROGRESS command: " VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_CHANNEL_PROGRESS command: "
<< flat); << flat);
Expand All @@ -588,7 +588,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket
} }


bool bOK; bool bOK;
float progress = tokens[1].toFloat(&bOK); float progress = tokens[2].toFloat(&bOK);
if (!bOK) if (!bOK)
{ {
VERBOSE(VB_IMPORTANT, "LCDServer: bad float value in " VERBOSE(VB_IMPORTANT, "LCDServer: bad float value in "
Expand All @@ -598,7 +598,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket
} }


if (m_lcd) if (m_lcd)
m_lcd->setChannelProgress(progress); m_lcd->setChannelProgress(tokens[1], progress);


sendMessage(socket, "OK"); sendMessage(socket, "OK");
} }
Expand Down

0 comments on commit 5c54c54

Please sign in to comment.