diff --git a/mythtv/libs/libmythservicecontracts/services/frontendServices.h b/mythtv/libs/libmythservicecontracts/services/frontendServices.h index a0844b8817a..1f148e7e245 100644 --- a/mythtv/libs/libmythservicecontracts/services/frontendServices.h +++ b/mythtv/libs/libmythservicecontracts/services/frontendServices.h @@ -13,6 +13,7 @@ class SERVICE_PUBLIC FrontendServices : public Service Q_CLASSINFO( "SendNotification_Method", "POST" ) Q_CLASSINFO( "SendAction_Method", "POST" ) Q_CLASSINFO( "PlayRecording_Method", "POST" ) + Q_CLASSINFO( "PlayLiveTV_Method", "POST" ) Q_CLASSINFO( "PlayVideo_Method", "POST" ) Q_CLASSINFO( "SendKey_Method", "POST" ) @@ -47,6 +48,7 @@ class SERVICE_PUBLIC FrontendServices : public Service uint Width, uint Height) = 0; virtual bool PlayRecording(int RecordedId, int ChanId, const QDateTime &StartTime) = 0; + virtual bool PlayLiveTV(int ChanId) = 0; virtual bool PlayVideo(const QString &Id, bool UseBookmark) = 0; virtual QStringList GetContextList(void) = 0; diff --git a/mythtv/programs/mythfrontend/services/frontend.cpp b/mythtv/programs/mythfrontend/services/frontend.cpp index 7903ded1e6c..eb02c64d5c2 100644 --- a/mythtv/programs/mythfrontend/services/frontend.cpp +++ b/mythtv/programs/mythfrontend/services/frontend.cpp @@ -189,6 +189,44 @@ bool Frontend::PlayRecording(int RecordedId, int ChanId, return false; } +bool Frontend::PlayLiveTV(int ChanId) +{ + if (ChanId <= 0) + { + LOG(VB_GENERAL, LOG_ERR, LOC + + QString("PlayLiveTV: Channel ID is invalid.")); + return false; + } + + // channel tuning is only available from state playback i.e. Live TV + if (GetMythUI()->GetCurrentLocation().toLower() != "playback") + { + GetMythMainWindow()->JumpTo(jumpMap["Live TV"]); + + QTime timer; + timer.start(); + while ((timer.elapsed() < FE_LONG_TO) && + (GetMythUI()->GetCurrentLocation().toLower() != "playback")) + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + + if (GetMythUI()->GetCurrentLocation().toLower() == "playback") + { + LOG(VB_GENERAL, LOG_INFO, LOC + + QString("PlayLiveTV, ChanID: %1") + .arg(ChanId)); + + QString message = QString("NETWORK_CONTROL PLAY CHANID %1") + .arg(ChanId); + + MythEvent me(message); + gCoreContext->dispatch(me); + return true; + } + + return false; +} + bool Frontend::PlayVideo(const QString &Id, bool UseBookmark) { if (TV::IsTVRunning()) diff --git a/mythtv/programs/mythfrontend/services/frontend.h b/mythtv/programs/mythfrontend/services/frontend.h index ffefe7baecc..309972fe77a 100644 --- a/mythtv/programs/mythfrontend/services/frontend.h +++ b/mythtv/programs/mythfrontend/services/frontend.h @@ -36,6 +36,7 @@ class Frontend : public FrontendServices uint Width, uint Height) override; // FrontendServices bool PlayRecording(int RecordedId, int ChanId, const QDateTime &StartTime) override; // FrontendServices + bool PlayLiveTV(int ChanId) override; // FrontendServices bool PlayVideo(const QString &Id, bool UseBookmark) override; // FrontendServices QStringList GetContextList(void) override; // FrontendServices DTC::FrontendActionList* GetActionList(const QString &Context) override; // FrontendServices