An error with the remaining time in the channel display has been fixed

The remaining time in the channel display wasn't updated.
A new token "currentremaining" was introduced in the Progressbar section
of displaychannel.xml.
This commit is contained in:
kamel5
2021-02-10 13:33:54 +01:00
parent 78d424d256
commit 538d59ca4e
6 changed files with 22 additions and 6 deletions

View File

@@ -433,6 +433,7 @@ enum class eDCProgressBarIT {
remaining,
permashift,
livebuffer,
currentremaining,
count
};

View File

@@ -216,16 +216,19 @@ void cVeDcProgressBar::SetTokenContainer(void) {
tokenContainer->DefineIntToken("{remaining}", (int)eDCProgressBarIT::remaining);
tokenContainer->DefineIntToken("{permashift}", (int)eDCProgressBarIT::permashift);
tokenContainer->DefineIntToken("{livebuffer}", (int)eDCProgressBarIT::livebuffer);
tokenContainer->DefineIntToken("{currentremaining}", (int)eDCProgressBarIT::currentremaining);
InheritTokenContainer();
}
void cVeDcProgressBar::Set(const cEvent *p) {
if (!p) {
startTime = -1;
endTime = -1;
duration = -1;
return;
}
startTime = p->StartTime();
endTime = p-> EndTime();
duration = p->Duration();
int current = 0;
@@ -249,18 +252,24 @@ void cVeDcProgressBar::Set(const cEvent *p) {
} else {
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
}
tokenContainer->AddIntToken((int)eDCProgressBarIT::currentremaining, (int)round((endTime - t) / 60));
}
bool cVeDcProgressBar::Parse(bool force) {
if (!cViewElement::Parse(force))
return false;
int current = 0;
time_t t = time(NULL);
if (t > startTime)
current = t - startTime;
if (!(current > currentLast + 3) && !force && !Dirty())
return false;
currentLast = current;
SetDirty();
if (duration <= 0) {
tokenContainer->AddIntToken((int)eDCProgressBarIT::duration, 0);
tokenContainer->AddIntToken((int)eDCProgressBarIT::elapsed, 0);
@@ -276,6 +285,7 @@ bool cVeDcProgressBar::Parse(bool force) {
} else {
tokenContainer->AddIntToken((int)eDCProgressBarIT::permashift, 0);
}
tokenContainer->AddIntToken((int)eDCProgressBarIT::currentremaining, (int)round((endTime - t) / 60));
}
return true;
}

View File

@@ -51,6 +51,7 @@ class cVeDcProgressBar : public cViewElement {
private:
int currentLast;
int startTime;
int endTime;
int duration;
int GetLiveBuffer(void);
public:
@@ -199,4 +200,4 @@ public:
cVeDcGroupChannelListDetail(void) {};
virtual ~cVeDcGroupChannelListDetail(void) {};
};
#endif //__VIEWELEMENTSDC_H
#endif //__VIEWELEMENTSDC_H