Ticket #2426: embed_playback_part2.diff

File embed_playback_part2.diff, 17.1 KB (added by skamithi, 14 years ago)

first version of the part 2 patch. Basically it just replaces the Jump to Program stuff. So to activate it, do as if you were going to "Jump To Program". Instead of a OSD screen, you should now see the Watch Recording screen. I have set the behaviour to be consistent with the other embedded widgets e.g schedule recording, program guide, etc. The video is paused and the watch recording window is displayed. The active show is unhighlighted. buttons such as "play and delete" are removed. Creating a playlist in this mode is not allowed, and those commands don't exist. Preview Video is disabled ( it caused too many lock/unlock problems).

  • libs/libmythtv/libmythtv.pro

     
    139139HEADERS += playgroup.h              progdetails.h
    140140HEADERS += channeleditor.h          channelsettings.h
    141141HEADERS += previewgenerator.h       dvbtransporteditor.h
     142HEADERS += playbackbox.h
    142143
    143144SOURCES += programinfo.cpp          proglist.cpp
    144145SOURCES += RingBuffer.cpp
     
    160161SOURCES += progdetails.cpp
    161162SOURCES += channeleditor.cpp        channelsettings.cpp
    162163SOURCES += previewgenerator.cpp     dvbtransporteditor.cpp
     164SOURCES += playbackbox.cpp
    163165
    164166# DiSEqC
    165167HEADERS += diseqc.h                 diseqcsettings.h
  • libs/libmythtv/tv_play.h

     
    6868enum scheduleEditTypes {
    6969    kScheduleProgramGuide = 0,
    7070    kScheduleProgramFinder,
    71     kScheduledRecording
     71    kScheduledRecording,
     72    kPlaybackBox,
    7273};
    7374
    7475class MPUBLIC TV : public QObject
     
    112113    // Recording commands
    113114    int  PlayFromRecorder(int recordernum);
    114115    int  Playback(ProgramInfo *rcinfo);
     116
     117    // Various commands
    115118    void setLastProgram(ProgramInfo *rcinfo);
    116119    ProgramInfo *getLastProgram(void) { return lastProgram; }
    117120    void setInPlayList(bool setting) { inPlaylist = setting; }
    118121    void setUnderNetworkControl(bool setting) { underNetworkControl = setting; }
     122    bool IsSameProgram(ProgramInfo *p);
    119123
    120     // Various commands
    121124    void ShowNoRecorderDialog(void);
    122125    void FinishRecording(void);
    123126    void AskAllowRecording(const QStringList&, int, bool);
     
    194197    static void *EPGMenuHandler(void *param);
    195198    static void *FinderMenuHandler(void *param);
    196199    static void *ScheduleMenuHandler(void *param);
     200    static void *RecordedShowMenuHandler(void *param);
    197201
    198202    void RunTV(void);
    199203    static void *EventThread(void *param);
     
    297301    void SetAutoCommercialSkip(enum commSkipMode skipMode = CommSkipOff);
    298302    void SetManualZoom(bool zoomON = false);
    299303
    300     void DoDisplayJumpMenu(void);
    301304    void SetJumpToProgram(QString progKey = "", int progIndex = 0);
    302305 
    303306    bool ClearOSD(void);
     
    325328    void ToggleActiveWindow(void);
    326329    void SwapPIP(void);
    327330    void SwapPIPSoon(void) { needToSwapPIP = true; }
    328     void DisplayJumpMenuSoon(void) { needToJumpMenu = true; }
    329331
    330332    void ToggleAutoExpire(void);
    331333
     
    426428
    427429    bool ignoreKeys;
    428430    bool needToSwapPIP;
    429     bool needToJumpMenu;
    430431    QMap<QString,ProgramList> progLists;
    431432
    432433    mutable QMutex chanEditMapLock; ///< Lock for chanEditMap and ddMap
  • libs/libmythtv/tv_play.cpp

     
    3939#include "DVDRingBuffer.h"
    4040#include "datadirect.h"
    4141#include "sourceutil.h"
     42#include "playbackbox.h"
    4243
    4344#ifndef HAVE_ROUND
    4445#define round(x) ((int) ((x) + 0.5))
     
    415416      queuedTranscode(false), getRecorderPlaybackInfo(false),
    416417      adjustingPicture(kAdjustingPicture_None),
    417418      adjustingPictureAttribute(kPictureAttribute_None),
    418       ignoreKeys(false), needToSwapPIP(false), needToJumpMenu(false),
     419      ignoreKeys(false), needToSwapPIP(false),
    419420      // Channel Editing
    420421      chanEditMapLock(true), ddMapSourceId(0), ddMapLoaderRunning(false),
    421422      // Sleep Timer
     
    19351936            SwapPIP();
    19361937            needToSwapPIP = false;
    19371938        }
    1938 
    1939         if (needToJumpMenu)
    1940         {
    1941             DoDisplayJumpMenu();
    1942             needToJumpMenu = false;
    1943         }
    19441939    }
    19451940 
    19461941    if (!IsErrored() && (GetState() != kState_None))
     
    27202715            jumpToProgram = true;
    27212716        }
    27222717        else if (action == "JUMPREC")
    2723             DisplayJumpMenuSoon();
     2718            EditSchedule(kPlaybackBox);
    27242719        else if (action == "SIGNALMON")
    27252720        {
    27262721            if ((GetState() == kState_WatchingLiveTV) && activerecorder)
     
    49734968    pbinfoLock.unlock();
    49744969
    49754970    bool changeChannel = false;
     4971    ProgramInfo *nextProgram = NULL;
    49764972
    49774973    if (StateIsLiveTV(GetState()))
    49784974    {
     
    50024998                    RunProgramFind(true, false);
    50034999                    break;
    50045000            case kScheduledRecording:
     5001            {
    50055002                    pbinfoLock.lock();
    50065003                    ScheduledRecording record;
    50075004                    record.loadByProgram(playbackinfo);
    50085005                    record.exec();
    50095006                    pbinfoLock.unlock();
    50105007                    break;
     5008            }
     5009            case kPlaybackBox:
     5010            {
     5011                    pbinfoLock.lock();
     5012                    nextProgram = PlaybackBox::RunPlaybackBox(this, true);
     5013                    if (nextProgram)
     5014                    {
     5015                        setLastProgram(nextProgram);
     5016                        jumpToProgram = true;
     5017                        exitPlayer = true;
     5018                        delete nextProgram;
     5019                    }
     5020                    pbinfoLock.unlock();
     5021                    break;
     5022            }
    50115023        }
    50125024
    50135025        if (!stayPaused)
     
    50535065    return NULL;
    50545066}
    50555067
     5068void *TV::RecordedShowMenuHandler(void *param)
     5069{
     5070    TV *obj = (TV *)param;
     5071    obj->doEditSchedule(kPlaybackBox);
     5072
     5073    return NULL;
     5074}
     5075
    50565076void TV::EditSchedule(int editType)
    50575077{
    50585078    if (menurunning == true)
     
    50755095        case kScheduledRecording:
    50765096                pthread_create(&tid, &attr, TV::ScheduleMenuHandler, this);
    50775097                break;
     5098        case kPlaybackBox:
     5099                pthread_create(&tid, &attr, TV::RecordedShowMenuHandler, this);
    50785100    }
    50795101}
    50805102
     
    63706392            jumpToProgram = true;
    63716393        }
    63726394        else if (action == "JUMPREC")
    6373             DisplayJumpMenuSoon();
     6395            EditSchedule(kPlaybackBox);
    63746396        else if (action.left(8) == "JUMPPROG")
    63756397        {
    63766398            SetJumpToProgram(action.section(" ",1,-2),
     
    64016423    }
    64026424}
    64036425
    6404 void TV::DoDisplayJumpMenu(void)
    6405 {
    6406     if (treeMenu)
    6407         delete treeMenu;
    6408 
    6409     treeMenu = new OSDGenericTree(NULL, "treeMenu");
    6410     OSDGenericTree *item, *subitem;
    6411 
    6412     // Build jumpMenu of recorded program titles
    6413     ProgramInfo *p;
    6414     progLists.clear();
    6415     vector<ProgramInfo *> *infoList;
    6416     infoList = RemoteGetRecordedList(false);
    6417 
    6418     bool LiveTVInAllPrograms = gContext->GetNumSetting("LiveTVInAllPrograms",0);
    6419 
    6420     if (infoList)
    6421     {
    6422         pbinfoLock.lock();
    6423         vector<ProgramInfo *>::iterator i = infoList->begin();
    6424         for ( ; i != infoList->end(); i++)
    6425         {
    6426             p = *i;
    6427             //if (p->recgroup != "LiveTV" || LiveTVInAllPrograms)
    6428             if (p->recgroup == playbackinfo->recgroup)
    6429                 progLists[p->title].prepend(p);
    6430         }
    6431         pbinfoLock.unlock();
    6432 
    6433         QMap<QString,ProgramList>::Iterator Iprog;
    6434         for (Iprog = progLists.begin(); Iprog != progLists.end(); Iprog++)
    6435         {
    6436             ProgramList plist = Iprog.data();
    6437             int progIndex = plist.count();
    6438             if (progIndex == 1)
    6439             {
    6440                 item = new OSDGenericTree(treeMenu, tr(Iprog.key()),
    6441                     QString("JUMPPROG %1 0").arg(Iprog.key()));
    6442             }
    6443             else
    6444             {
    6445                 item = new OSDGenericTree(treeMenu, tr(Iprog.key()));
    6446                 for (int i = 0; i < progIndex; i++)
    6447                 {
    6448                     p = plist.at(i);
    6449                     if (p->subtitle != "")
    6450                         subitem = new OSDGenericTree(item, tr(p->subtitle),
    6451                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
    6452                     else
    6453                         subitem = new OSDGenericTree(item, tr(p->title),
    6454                             QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
    6455                 }
    6456             }
    6457         }
    6458     }
    6459 
    6460     if (GetOSD())
    6461     {
    6462         ClearOSD();
    6463 
    6464         OSDListTreeType *tree = GetOSD()->ShowTreeMenu("menu", treeMenu);
    6465         if (tree)
    6466         {
    6467             connect(tree, SIGNAL(itemSelected(OSDListTreeType *,OSDGenericTree *)),
    6468                     this, SLOT(TreeMenuSelected(OSDListTreeType *, OSDGenericTree *)));
    6469 
    6470             connect(tree, SIGNAL(itemEntered(OSDListTreeType *, OSDGenericTree *)),
    6471                     this, SLOT(TreeMenuEntered(OSDListTreeType *, OSDGenericTree *)));
    6472         }
    6473     }
    6474 }
    6475 
    64766426void TV::ShowOSDTreeMenu(void)
    64776427{
    64786428    BuildOSDTreeMenu();
     
    74437393        lastProgram = NULL;
    74447394}
    74457395
     7396bool TV::IsSameProgram(ProgramInfo *rcinfo)
     7397{
     7398    if (rcinfo && playbackinfo)
     7399        return playbackinfo->IsSameProgram(*rcinfo);
     7400
     7401    return false;
     7402}
     7403
    74467404/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • programs/mythfrontend/playbackbox.cpp

     
    1616#include <qfileinfo.h>
    1717#include <qsqldatabase.h>
    1818#include <qmap.h>
     19#include <qwaitcondition.h>
    1920
    2021#include <cmath>
    2122#include <unistd.h>
     
    5051
    5152#define USE_PREV_GEN_THREAD
    5253
     54QWaitCondition pbbIsVisibleCond;
     55
    5356static int comp_programid(ProgramInfo *a, ProgramInfo *b)
    5457{
    5558    if (a->programid == b->programid)
     
    185188        return (a->startts.date() > b->startts.date() ? 1 : -1);
    186189}
    187190
     191
     192ProgramInfo * PlaybackBox::RunPlaybackBox(TV *player, bool thread)
     193{
     194    ProgramInfo *nextProgram = NULL;
     195    if (thread)
     196        qApp->lock();
     197
     198    PlaybackBox *pbb = new PlaybackBox(PlaybackBox::Play,
     199            gContext->GetMainWindow(), "tvplayselect", player);
     200    pbb->Show();
     201
     202    if (thread)
     203    {
     204        qApp->unlock();
     205        pbbIsVisibleCond.wait();
     206    }
     207    else
     208        pbb->exec();
     209
     210    if (pbb->getSelected())
     211        nextProgram = new ProgramInfo(*pbb->getSelected());
     212   
     213    delete pbb;
     214   
     215    return nextProgram;
     216}
     217
    188218PlaybackBox::PlaybackBox(BoxType ltype, MythMainWindow *parent,
    189                          const char *name)
     219                         const char *name, TV *player)
    190220    : MythDialog(parent, name),
    191221      // Settings
    192222      type(ltype),
     
    248278      previewPixmapEnabled(false),      previewPixmap(NULL),
    249279      previewSuspend(false),            previewChanid(""),
    250280      // Network Control Variables
    251       underNetworkControl(false)
     281      underNetworkControl(false),
     282      m_player(NULL)
    252283{
    253284    formatShortDate    = gContext->GetSetting("ShortDateFormat", "M/d");
    254285    formatLongDate     = gContext->GetSetting("DateFormat", "ddd MMMM d");
     
    263294    groupnameAsAllProg = gContext->GetNumSetting("DispRecGroupAsAllProg", 0);
    264295    arrowAccel         = gContext->GetNumSetting("UseArrowAccels", 1);
    265296    inTitle            = gContext->GetNumSetting("PlaybackBoxStartInTitle", 0);
    266     previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview");
     297    if (!player)
     298        previewVideoEnabled =gContext->GetNumSetting("PlaybackPreview");
    267299    previewPixmapEnabled=gContext->GetNumSetting("GeneratePreviewPixmaps");
    268300    previewFromBookmark= gContext->GetNumSetting("PreviewFromBookmark");
    269301    drawTransPixmap    = gContext->LoadScalePixmap("trans-backup.png");
     
    283315    titleList << "";
    284316    playList.clear();
    285317
     318    if (player)
     319        m_player = player;
     320
    286321    // recording group stuff
    287322    recGroupType.clear();
    288323    recGroupType[recGroup] = (displayCat) ? "category" : "recgroup";
     
    369404    gContext->removeListener(this);
    370405    gContext->removeCurrentLocation();
    371406
    372     killPlayerSafe();
     407    if (!m_player)
     408        killPlayerSafe();
    373409
    374410    if (previewVideoRefreshTimer)
    375411    {
     
    566602
    567603void PlaybackBox::exitWin()
    568604{
    569     killPlayerSafe();
     605    if (m_player)
     606    {
     607        if (curitem)
     608            delete curitem;
     609        curitem = NULL;
     610        pbbIsVisibleCond.wakeAll();
     611    }
     612    else
     613        killPlayerSafe();
     614
    570615    accept();
    571616}
    572617
     
    12471292                if (playList.grep(tempInfo->MakeUniqueKey()).count())
    12481293                    ltype->EnableForcedFont(cnt, "tagged");
    12491294
    1250                 if (tempInfo->availableStatus != asAvailable)
     1295                if (tempInfo->availableStatus != asAvailable ||
     1296                        (m_player && m_player->IsSameProgram(tempInfo)))
    12511297                    ltype->EnableForcedFont(cnt, "inactive");
    12521298            }
    12531299        }
     
    20792125    if (!curitem)
    20802126        return;
    20812127
     2128    if (m_player && m_player->IsSameProgram(curitem))
     2129        exitWin();
     2130
    20822131    if (curitem && curitem->availableStatus != asAvailable)
    20832132        showAvailablePopup(curitem);
    20842133    else
    20852134        play(curitem);
     2135
     2136    if (m_player)
     2137    {
     2138        pbbIsVisibleCond.wakeAll();
     2139        accept();
     2140    }
    20862141}
    20872142
    20882143void PlaybackBox::stopSelected()
     
    22112266        popup->addButton(tr("Playlist options"), this,
    22122267                         SLOT(showPlaylistPopup()));
    22132268    }
    2214     else
     2269    else if (!m_player)
    22152270    {
    22162271        if (inTitle)
    22172272        {
     
    22542309    if (!rec)
    22552310        return false;
    22562311
     2312    if (m_player)
     2313        return true;
     2314           
    22572315    if (fileExists(rec) == false)
    22582316    {
    22592317        QString msg =
     
    29122970
    29132971    initPopup(popup, program, "", "");
    29142972
    2915     QButton *playButton;
     2973    QButton *playButton = new QButton();
    29162974
    2917     if (curitem->programflags & FL_BOOKMARK)
    2918         playButton = popup->addButton(tr("Play from..."), this,
    2919                                       SLOT(showPlayFromPopup()));
    2920     else
    2921         playButton = popup->addButton(tr("Play"), this, SLOT(doPlay()));
     2975    if (!(m_player && m_player->IsSameProgram(curitem)))
     2976    {
     2977        if (curitem->programflags & FL_BOOKMARK)
     2978            popup->addButton(tr("Play from..."), this,
     2979                                        SLOT(showPlayFromPopup()));
     2980        else
     2981            popup->addButton(tr("Play"), this, SLOT(doPlay()));
     2982    }
    29222983
    2923     if (playList.grep(curitem->MakeUniqueKey()).count())
    2924         popup->addButton(tr("Remove from Playlist"), this,
    2925                          SLOT(togglePlayListItem()));
    2926     else
    2927         popup->addButton(tr("Add to Playlist"), this,
    2928                          SLOT(togglePlayListItem()));
     2984    if (!m_player)
     2985    {
     2986        if (playList.grep(curitem->MakeUniqueKey()).count())
     2987            popup->addButton(tr("Remove from Playlist"), this,
     2988                            SLOT(togglePlayListItem()));
     2989        else
     2990            popup->addButton(tr("Add to Playlist"), this,
     2991                            SLOT(togglePlayListItem()));
     2992    }
    29292993
    29302994    if (program->recstatus == rsRecording)
    29312995        popup->addButton(tr("Stop Recording"), this, SLOT(askStop()));
     
    29413005    popup->addButton(tr("Recording Options"), this, SLOT(showRecordingPopup()));
    29423006    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup()));
    29433007
    2944     popup->addButton(tr("Delete"), this, SLOT(askDelete()));
     3008    if (!(m_player && m_player->IsSameProgram(curitem)))
     3009        popup->addButton(tr("Delete"), this, SLOT(askDelete()));
    29453010
    29463011    popup->ShowPopup(this, SLOT(doCancel()));
    29473012
  • programs/mythfrontend/mythfrontend.pro

     
    2323QMAKE_CLEAN += $(TARGET)
    2424
    2525# Input
    26 HEADERS += manualbox.h playbackbox.h viewscheduled.h globalsettings.h
     26HEADERS += manualbox.h viewscheduled.h globalsettings.h
    2727HEADERS += manualschedule.h programrecpriority.h channelrecpriority.h
    2828HEADERS += statusbox.h networkcontrol.h
    2929
    30 SOURCES += main.cpp manualbox.cpp playbackbox.cpp viewscheduled.cpp
     30SOURCES += main.cpp manualbox.cpp viewscheduled.cpp
    3131SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp
    3232SOURCES += channelrecpriority.cpp statusbox.cpp networkcontrol.cpp
    3333
  • programs/mythfrontend/playbackbox.h

     
    1313#include "xmlparse.h"
    1414#include "programinfo.h"
    1515#include "jobqueue.h"
     16#include "tv_play.h"
    1617
    1718#include <qvaluelist.h>
    1819#include <pthread.h>
     
    9899    } killStateType;
    99100     
    100101
    101     PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0);
     102    PlaybackBox(BoxType ltype, MythMainWindow *parent, const char *name = 0, TV *player = NULL);
    102103   ~PlaybackBox(void);
    103104   
    104105    void customEvent(QCustomEvent *e);
    105  
     106    static ProgramInfo *RunPlaybackBox(TV *player, bool thread = false);
     107   
     108   
    106109  protected slots:
    107110    void timeout(void);
    108111
     
    246249    void stop(ProgramInfo *);
    247250    void remove(ProgramInfo *);
    248251    void showActions(ProgramInfo *);
     252    ProgramInfo *getSelected(void){ return curitem; }
     253       
    249254
    250255    void togglePlayListItem(ProgramInfo *pginfo);
    251256    void randomizePlayList(void);
     
    451456    mutable QMutex      ncLock;
    452457    QValueList<QString> networkControlCommands;
    453458    bool                underNetworkControl;
     459   
     460    TV                  *m_player;
    454461};
    455462
    456463#endif