In timeshift mode, the title of the actual playback position is displayed

If the timeshift mode is activated during playback, the title of the
program that was active when the time shift started is displayed by
pressing OK.
The behavior has now been changed so that the title of the program is
displayed in the actual playback position when you press OK.
This commit is contained in:
kamel5 2021-02-11 16:45:08 +01:00
parent 628a28201b
commit 64599db339
4 changed files with 55 additions and 28 deletions

View File

@ -143,6 +143,7 @@ void cViewReplay::PreCache(void) {
void cViewReplay::ClearVariables(void) {
cView::ClearVariables();
recording = NULL;
lastEvent = NULL;
modeOnly = false;
lastFlush = 0;
lastFlushModeOnly = 0;
@ -162,20 +163,6 @@ void cViewReplay::ClearVariables(void) {
globalTimers.ClearTimers();
}
void cViewReplay::SetRecording(const cRecording *recording) {
this->recording = recording;
if (veRecTitle) {
veRecTitle->Set(recording);
}
if (veRecInfo) {
veRecInfo->Set(recording);
}
if (veScraperContent) {
veScraperContent->Set(recording);
}
SetTimeShiftValues();
}
void cViewReplay::GetGlobalTimers(void) {
if (!timersLoaded) {
timersLoaded = true;
@ -183,7 +170,7 @@ void cViewReplay::GetGlobalTimers(void) {
}
}
void cViewReplay::SetTimeShiftValues(void) {
void cViewReplay::SetTimeShiftValues(int current, int total) {
if (!recording)
return;
timeShiftActive = false;
@ -209,21 +196,43 @@ void cViewReplay::SetTimeShiftValues(void) {
}
if (!Schedule)
return;
const cEvent *event = Schedule->GetEventAround(time(NULL));
if (!event)
// Get event at actual recording position
const cEvent *eventEnde = Schedule->GetEventAround(time(NULL));
if (!eventEnde)
return;
double fps = recording->FramesPerSecond();
time_t liveEventStop = event->EndTime();
time_t liveEventStop = eventEnde->EndTime();
time_t recordingStart = time(0) - recording->LengthInSeconds();
timeShiftFramesTotal = (liveEventStop - recordingStart) * fps;
timeShiftLength = liveEventStop - recordingStart;
// Get event at actual replay position
int secondsafter = (int)(recording->LengthInSeconds() * (1.0 - (double)current / (double)total));
const cEvent *eventReplay = Schedule->GetEventAround(time(NULL) - secondsafter);
// Display title at replay position
if (eventReplay && eventReplay != lastEvent && veRecTitle) {
veRecTitle->Set(recording, eventReplay);
veRecTitle->Parse();
lastEvent = eventReplay;
}
int mins = (timeShiftLength / 60) % 60;
int hours = (timeShiftLength / 3600) % 24;
timeShiftDuration = cString::sprintf("%d:%02d", hours, mins);
}
void cViewReplay::SetRecording(const cRecording *recording) {
this->recording = recording;
if (veRecTitle) {
veRecTitle->Set(recording);
}
if (veRecInfo) {
veRecInfo->Set(recording);
}
if (veScraperContent) {
veScraperContent->Set(recording);
}
}
void cViewReplay::SetTitle(const char *title) {
recording = NULL;
if (veRecTitle) {
veRecTitle->Set(title);
}
@ -263,7 +272,7 @@ void cViewReplay::SetEndTime(int current, int total) {
}
void cViewReplay::SetProgressbar(int current, int total) {
SetTimeShiftValues();
SetTimeShiftValues(current, total);
if (veProgressbar)
veProgressbar->Set(current, total, timeShiftActive, timeShiftFramesTotal);
Render((int)eVeDisplayReplay::progressbar);

View File

@ -22,6 +22,7 @@ private:
cVeDrOnPause *veOnPause;
cVeDrOnPause *veOnPauseModeOnly;
const cRecording *recording;
const cEvent *lastEvent;
bool modeOnly;
time_t lastFlush;
time_t lastFlushModeOnly;
@ -34,7 +35,7 @@ private:
bool timersLoaded;
cGlobalTimers globalTimers;
void GetGlobalTimers(void);
void SetTimeShiftValues(void);
void SetTimeShiftValues(int current, int total);
void SetViewElements(void);
void ClearVariables(void);
void SetViewElementObjects(void);

View File

@ -8,6 +8,7 @@
******************************************************************/
cVeDrRecTitle::cVeDrRecTitle(void) {
recording = NULL;
event = NULL;
title = NULL;
}
@ -24,16 +25,20 @@ void cVeDrRecTitle::SetTokenContainer(void) {
InheritTokenContainer();
}
void cVeDrRecTitle::Set(const cRecording *recording) {
void cVeDrRecTitle::Set(const cRecording *recording, const cEvent *event) {
if (this->title) {
free(this->title);
this->title = NULL;
}
if (this->recording)
this->recording = NULL;
if (this->event)
this->event = NULL;
if (!recording)
return;
this->recording = recording;
if (event)
this->event = event;
}
void cVeDrRecTitle::Set(const char *title) {
@ -43,6 +48,8 @@ void cVeDrRecTitle::Set(const char *title) {
}
if (this->recording)
this->recording = NULL;
if (this->event)
this->event = NULL;
if (!title)
return;
free(this->title);
@ -58,13 +65,22 @@ bool cVeDrRecTitle::Parse(bool force) {
tokenContainer->Clear();
if (recording) {
const char *recName = NULL;
const char *recShortText = NULL;
const cRecordingInfo *recInfo = recording->Info();
if (recInfo)
if (event) {
recName = event->Title();
recShortText = event->ShortText();
} else if (recInfo) {
recName = recInfo->Title();
if (!recName)
recShortText = recInfo->ShortText();
}
if (!recName) {
recName = recording->Name();
recShortText = "";
}
tokenContainer->AddStringToken((int)eDRRecTitleST::rectitle, recName);
tokenContainer->AddStringToken((int)eDRRecTitleST::recsubtitle, recInfo ? recInfo->ShortText() : "");
tokenContainer->AddStringToken((int)eDRRecTitleST::recsubtitle, recShortText);
tokenContainer->AddStringToken((int)eDRRecTitleST::recdate, *ShortDateString(recording->Start()));
tokenContainer->AddStringToken((int)eDRRecTitleST::rectime, *TimeString(recording->Start()));
} else if (title) {

View File

@ -10,13 +10,14 @@
class cVeDrRecTitle : public cViewElement {
private:
const cRecording *recording;
const cEvent *event;
char *title;
public:
cVeDrRecTitle(void);
virtual ~cVeDrRecTitle(void);
void SetTokenContainer(void);
void Set(const cRecording *recording);
void Set(const char *title);
void Set(const cRecording *recording = NULL, const cEvent *event = NULL);
void Set(const char *title = NULL);
bool Parse(bool forced = false);
};
@ -207,4 +208,4 @@ public:
bool Parse(bool forced = false);
};
#endif //__VIEWELEMENTSDR_H
#endif //__VIEWELEMENTSDR_H