Skip to content
Browse files

Add current playing time on LCD displays with 4 rows or more

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...
1 parent 22e48c4 commit 5c54c549abf993cc2476f2859d995536720e97ed @mzanetti mzanetti committed with Beirdo Jan 30, 2011
View
5 mythtv/libs/libmythbase/lcddevice.cpp
@@ -473,13 +473,14 @@ void LCD::setTunerLEDs(enum LCDTunerSet tuner, bool on)
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)
return;
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)
View
2 mythtv/libs/libmythbase/lcddevice.h
@@ -236,7 +236,7 @@ class MPUBLIC LCD : public QObject, public MythSocketCBs
// While watching Live/Recording/Pause Buffer, occasionaly describe how
// much of the program has been seen (between 0.0 and 1.0)
// (e.g. [current time - start time] / [end time - start time] )
- void setChannelProgress(float percentViewed);
+ void setChannelProgress(const QString time, float percentViewed);
// Show the Menu
// QPtrList is a pointer to a bunch of menu items
View
11 mythtv/libs/libmythtv/tv_play.cpp
@@ -2930,6 +2930,7 @@ bool TV::HandleLCDTimerEvent(void)
if (lcd)
{
float progress = 0.0f;
+ QString lcd_time_string;
bool showProgress = true;
if (StateIsLiveTV(GetState(actx)))
@@ -2944,10 +2945,16 @@ bool TV::HandleLCDTimerEvent(void)
if (showProgress)
{
osdInfo info;
- if (actx->CalcPlayerSliderPosition(info))
+ if (actx->CalcPlayerSliderPosition(info)) {
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);
View
9 mythtv/programs/mythlcdserver/lcdprocclient.cpp
@@ -473,6 +473,7 @@ void LCDProcClient::init()
setPriority("Channel", LOW);
sendToServer("widget_add Channel topWidget string");
sendToServer("widget_add Channel botWidget string");
+ sendToServer("widget_add Channel timeWidget string");
sendToServer("widget_add Channel progressBar hbar");
// The Generic Screen
@@ -1124,6 +1125,7 @@ void LCDProcClient::startChannel(QString channum, QString title, QString subtitl
formatScrollingWidgets();
}
+ channel_time = "";
progress = 0.0;
outputChannel();
}
@@ -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)
return;
progress = value;
+ channel_time = time;
if (progress < 0.0)
progress = 0.0;
@@ -2160,6 +2163,9 @@ void LCDProcClient::outputChannel()
aString += " ";
aString += QString::number((int)rint(progress * lcdWidth * cellWidth));
sendToServer(aString);
+
+ if (lcdHeight >= 4)
+ outputCenteredText("Channel", channel_time, "timeWidget", 3);
}
else
sendToServer("widget_set Channel progressBar 1 1 0");
@@ -2313,6 +2319,7 @@ void LCDProcClient::removeWidgets()
{
sendToServer("widget_del Channel progressBar");
sendToServer("widget_del Channel topWidget");
+ sendToServer("widget_del Channel timeWidget");
sendToServer("screen_del Channel");
sendToServer("widget_del Generic progressBar");
View
3 mythtv/programs/mythlcdserver/lcdprocclient.h
@@ -43,7 +43,7 @@ class LCDProcClient : public QObject
void setLevels(int numbLevels, float *values);
void switchToChannel(QString channum = "", QString title = "",
QString subtitle = "");
- void setChannelProgress(float percentViewed);
+ void setChannelProgress(const QString &time, float percentViewed);
void switchToMenu(QList<LCDMenuItem> *menuItems, QString app_name = "",
bool popMenu = true);
void switchToGeneric(QList<LCDTextItem> *textItems);
@@ -169,6 +169,7 @@ class LCDProcClient : public QObject
float EQlevels[10];
float progress;
+ QString channel_time;
/** true if the generic progress indicator is a busy
(ie. doesn't have a known total steps */
bool busy_progress;
View
6 mythtv/programs/mythlcdserver/lcdserver.cpp
@@ -579,7 +579,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket
QString flat = tokens.join(" ");
- if (tokens.count() != 2)
+ if (tokens.count() != 3)
{
VERBOSE(VB_IMPORTANT, "LCDServer: bad SET_CHANNEL_PROGRESS command: "
<< flat);
@@ -588,7 +588,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket
}
bool bOK;
- float progress = tokens[1].toFloat(&bOK);
+ float progress = tokens[2].toFloat(&bOK);
if (!bOK)
{
VERBOSE(VB_IMPORTANT, "LCDServer: bad float value in "
@@ -598,7 +598,7 @@ void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket
}
if (m_lcd)
- m_lcd->setChannelProgress(progress);
+ m_lcd->setChannelProgress(tokens[1], progress);
sendMessage(socket, "OK");
}

0 comments on commit 5c54c54

Please sign in to comment.
Something went wrong with that request. Please try again.