Ticket #13338: frontend-services-playLiveTV.patch

File frontend-services-playLiveTV.patch, 3.7 KB (added by Justin Randall, 6 months ago)

New version of patch compatible with recent changes to trunk.

  • mythtv/libs/libmythservicecontracts/services/frontendServices.h

    diff --git a/mythtv/libs/libmythservicecontracts/services/frontendServices.h b/mythtv/libs/libmythservicecontracts/services/frontendServices.h
    index a0844b8817a..1f148e7e245 100644
    a b class SERVICE_PUBLIC FrontendServices : public Service 
    1313    Q_CLASSINFO( "SendNotification_Method",       "POST" )
    1414    Q_CLASSINFO( "SendAction_Method",             "POST" )
    1515    Q_CLASSINFO( "PlayRecording_Method",          "POST" )
     16    Q_CLASSINFO( "PlayLiveTV_Method",             "POST" )
    1617    Q_CLASSINFO( "PlayVideo_Method",              "POST" )
    1718    Q_CLASSINFO( "SendKey_Method",                "POST" )
    1819
    class SERVICE_PUBLIC FrontendServices : public Service 
    4748                                            uint Width, uint Height) = 0;
    4849    virtual bool                 PlayRecording(int RecordedId, int ChanId,
    4950                                               const QDateTime &StartTime) = 0;
     51    virtual bool                 PlayLiveTV(int ChanId) = 0;
    5052    virtual bool                 PlayVideo(const QString &Id,
    5153                                           bool  UseBookmark) = 0;
    5254    virtual QStringList          GetContextList(void) = 0;
  • mythtv/programs/mythfrontend/services/frontend.cpp

    diff --git a/mythtv/programs/mythfrontend/services/frontend.cpp b/mythtv/programs/mythfrontend/services/frontend.cpp
    index 7903ded1e6c..eb02c64d5c2 100644
    a b bool Frontend::PlayRecording(int RecordedId, int ChanId, 
    189189    return false;
    190190}
    191191
     192bool Frontend::PlayLiveTV(int ChanId)
     193{
     194    if (ChanId <= 0)
     195    {
     196        LOG(VB_GENERAL, LOG_ERR, LOC +
     197            QString("PlayLiveTV: Channel ID is invalid."));
     198        return false;
     199    }
     200
     201    // channel tuning is only available from state playback i.e. Live TV
     202    if (GetMythUI()->GetCurrentLocation().toLower() != "playback")
     203    {
     204        GetMythMainWindow()->JumpTo(jumpMap["Live TV"]);
     205
     206        QTime timer;
     207        timer.start();
     208        while ((timer.elapsed() < FE_LONG_TO) &&
     209               (GetMythUI()->GetCurrentLocation().toLower() != "playback"))
     210            std::this_thread::sleep_for(std::chrono::milliseconds(10));
     211    }
     212
     213    if (GetMythUI()->GetCurrentLocation().toLower() == "playback")
     214    {
     215        LOG(VB_GENERAL, LOG_INFO, LOC +
     216            QString("PlayLiveTV, ChanID: %1")
     217            .arg(ChanId));
     218
     219        QString message = QString("NETWORK_CONTROL PLAY CHANID %1")
     220            .arg(ChanId);
     221
     222        MythEvent me(message);
     223        gCoreContext->dispatch(me);
     224        return true;
     225    }
     226
     227    return false;
     228}
     229
    192230bool Frontend::PlayVideo(const QString &Id, bool UseBookmark)
    193231{
    194232    if (TV::IsTVRunning())
  • mythtv/programs/mythfrontend/services/frontend.h

    diff --git a/mythtv/programs/mythfrontend/services/frontend.h b/mythtv/programs/mythfrontend/services/frontend.h
    index ffefe7baecc..309972fe77a 100644
    a b class Frontend : public FrontendServices 
    3636                                    uint Width, uint Height) override; // FrontendServices
    3737    bool                 PlayRecording(int RecordedId, int ChanId,
    3838                                       const QDateTime &StartTime) override; // FrontendServices
     39    bool                 PlayLiveTV(int ChanId) override; // FrontendServices
    3940    bool                 PlayVideo(const QString &Id, bool UseBookmark) override; // FrontendServices
    4041    QStringList          GetContextList(void) override; // FrontendServices
    4142    DTC::FrontendActionList* GetActionList(const QString &Context) override; // FrontendServices