Ticket #1702: alternate-player.patch

File alternate-player.patch, 11.6 KB (added by eggi@…, 18 years ago)
  • mythvideo/mythvideo/videodlg.h

     
    2626       
    2727        virtual ~VideoDialog();
    2828       
    29         virtual void playVideo(Metadata *someItem);
     29        virtual void playVideo(Metadata *someItem, bool wantsAltPlayer);
    3030       
    31         QString getHandler(Metadata *someItem);
    32         QString getCommand(Metadata *someItem);
     31        QString getHandler(Metadata *someItem, bool wantsAltPlayer);
     32        QString getCommand(Metadata *someItem, bool wantsAltPlayer);
    3333        bool checkParentPassword();
    3434        GenericTree *getVideoTreeRoot(void);
    3535       
     
    4646        void exitWin();
    4747        virtual void slotParentalLevelChanged() {cerr << "VideoDialog::parseContainer" << endl;}
    4848        virtual void slotWatchVideo();
     49        virtual void slotAltWatchVideo();
    4950           
    5051    protected:
    5152        virtual void updateBackground(void);
     
    6364        int currentParentalLevel;       
    6465        bool isFileBrowser;
    6566        bool isFlatList;
     67        bool hasAltPlayer;
    6668        Metadata* curitem;
    6769        MythPopupBox* popup;
    6870        bool expectingPopup;
  • mythvideo/mythvideo/globalsettings.cpp

     
    205205    return gc;
    206206};
    207207
     208static HostLineEdit *VideoAlternatePlayer()
     209{
     210    HostLineEdit *gc = new HostLineEdit("VideoAlternatePlayer");
     211    gc->setLabel(QObject::tr("Alternate Player"));
     212    gc->setValue("");
     213    gc->setHelpText(QObject::tr("If, for some reason, the default player "
     214                    "doesn't play a video, you can play it in the alternate "
     215                    "player by hitting the INFO button and selecting 'Watch "
     216                    "In Alternate Player'"));
     217    return gc;
     218};
     219
    208220static HostSpinBox *VideoGalleryRows()
    209221{
    210222    HostSpinBox *gc = new HostSpinBox("VideoGalleryRowsPerPage", 2, 5, 1);
     
    285297    VerticalConfigurationGroup* playersettings = new VerticalConfigurationGroup(false);
    286298    playersettings->setLabel(QObject::tr("Player Settings"));
    287299    playersettings->addChild(VideoDefaultPlayer());
     300    playersettings->addChild(VideoAlternatePlayer());
    288301    addChild(playersettings);
    289302}
  • mythvideo/mythvideo/videotree.cpp

     
    3232    current_parental_level = gContext->GetNumSetting("VideoDefaultParentalLevel", 1);
    3333
    3434    file_browser = gContext->GetNumSetting("VideoTreeNoDB", 0);
     35    hasAltPlayer = gContext->GetSetting("VideoAlternatePlayer") != "";
    3536
    3637    //
    3738    //  Theme and tree stuff
     
    351352{
    352353    if(node_number > -1)
    353354    {
    354         playVideo(curitem);       
     355        playVideo(curitem, false);       
    355356    }
    356357}
    357358
     
    498499        if(info)
    499500        {
    500501            focusButton = popup->addButton(tr("Watch This Video"), this, SLOT(slotWatchVideo()));
     502            if(hasAltPlayer)
     503                popup->addButton(tr("Watch In Alternate Player"), this, SLOT(slotAltWatchVideo()));
    501504            popup->addButton(tr("View Full Plot"), this, SLOT(slotViewPlot()));
    502505        }
    503506        else
     
    593596    cancelPopup();
    594597   
    595598    if (curitem)
    596         playVideo(curitem);
     599        playVideo(curitem, false);
    597600    else
    598601        cerr << "no Item to watch" << endl;
    599602
    600603}
    601604
     605void VideoTree::slotAltWatchVideo()
     606{
     607    cancelPopup();
     608   
     609    if (curitem)
     610        playVideo(curitem, true);
     611    else
     612        cerr << "no Item to watch" << endl;
    602613
    603 void VideoTree::playVideo(Metadata *someItem)
     614}
     615
     616
     617
     618void VideoTree::playVideo(Metadata *someItem, bool wantsAltPlayer)
    604619{
    605620    if (!someItem)
    606621        return;
    607622       
    608623    QString filename = someItem->Filename();
    609     QString handler = getHandler(someItem);
     624    QString handler = getHandler(someItem, wantsAltPlayer);
    610625    QString year = QString("%1").arg(someItem->Year());
    611626    // See if this is being handled by a plugin..
    612627    if(gContext->GetMainWindow()->HandleMedia(handler, filename, someItem->Plot(),
     
    616631        return;
    617632    }
    618633
    619     QString command = getCommand(someItem);
     634    QString command = getCommand(someItem, wantsAltPlayer);
    620635       
    621636   
    622637    QTime playing_time;
     
    649664        if (parentItem->ChildID() > 0)
    650665        {
    651666            //Load up data about this child
    652             command = getCommand(childItem);
     667            command = getCommand(childItem, wantsAltPlayer);
    653668            playing_time.start();
    654669            myth_system((QString("%1 ") .arg(command)).local8Bit());
    655670        }
     
    671686}
    672687
    673688
    674 QString VideoTree::getHandler(Metadata *someItem)
     689QString VideoTree::getHandler(Metadata *someItem, bool wantsAltPlayer)
    675690{
    676691   
    677692    if (!someItem)
     
    680695    QString filename = someItem->Filename();
    681696    QString ext = someItem->Filename().section('.',-1);
    682697
    683     QString handler = gContext->GetSetting("VideoDefaultPlayer");
     698    QString handler = gContext->GetSetting(wantsAltPlayer ? "VideoAlternatePlayer": "VideoDefaultPlayer");
     699    if (wantsAltPlayer && handler != "")
     700    {
     701        // If user asked for the alternate player command, we don't check for
     702        // specialized player commands
     703        return handler;
     704    }
    684705    QString special_handler = someItem->PlayCommand();
    685706 
    686707    //
     
    724745    return handler;
    725746}
    726747
    727 QString VideoTree::getCommand(Metadata *someItem)
     748QString VideoTree::getCommand(Metadata *someItem, bool wantsAltPlayer)
    728749{
    729750    if (!someItem)
    730751        return "";
    731752       
    732753    QString filename = someItem->Filename();
    733     QString handler = getHandler(someItem);
     754    QString handler = getHandler(someItem, wantsAltPlayer);
    734755    QString arg;
    735756    arg.sprintf("\"%s\"",
    736757                filename.replace(QRegExp("\""), "\\\"").utf8().data());
  • mythvideo/mythvideo/videodlg.cpp

     
    4343
    4444    isFileBrowser = false;
    4545    isFlatList = false;
     46    hasAltPlayer = gContext->GetSetting("VideoAlternatePlayer") != "";
    4647    video_list = new VideoList(_winName);
    4748    video_tree_root = NULL;
    4849   
     
    178179    cancelPopup();
    179180   
    180181    if (curitem)
    181         playVideo(curitem);
     182        playVideo(curitem, false);
    182183    else
    183184        cerr << "no Item to watch" << endl;
    184185
    185186}
    186187
     188void VideoDialog::slotAltWatchVideo()
     189{
     190    cancelPopup();
     191   
     192    if (curitem)
     193        playVideo(curitem, true);
     194    else
     195        cerr << "no Item to watch" << endl;
    187196
    188 void VideoDialog::playVideo(Metadata *someItem)
     197}
     198
     199
     200
     201void VideoDialog::playVideo(Metadata *someItem, bool wantsAltPlayer)
    189202{
    190203    QString filename = someItem->Filename();
    191     QString handler = getHandler(someItem);
     204    QString handler = getHandler(someItem, wantsAltPlayer);
    192205    QString year = QString("%1").arg(someItem->Year());
    193206    // See if this is being handled by a plugin..
    194207    if(gContext->GetMainWindow()->HandleMedia(handler, filename, someItem->Plot(),
     
    198211        return;
    199212    }
    200213
    201     QString command = getCommand(someItem);
     214    QString command = getCommand(someItem, wantsAltPlayer);
    202215       
    203216   
    204217    QTime playing_time;
     
    231244        if (parentItem->ChildID() > 0)
    232245        {
    233246            //Load up data about this child
    234             command = getCommand(childItem);
     247            command = getCommand(childItem, wantsAltPlayer);
    235248            playing_time.start();
    236249            myth_system((QString("%1 ") .arg(command)).local8Bit());
    237250        }
     
    253266}
    254267
    255268
    256 QString VideoDialog::getHandler(Metadata *someItem)
     269QString VideoDialog::getHandler(Metadata *someItem, bool wantsAltPlayer)
    257270{
    258271   
    259272    if (!someItem)
     
    262275    QString filename = someItem->Filename();
    263276    QString ext = someItem->Filename().section('.',-1);
    264277
    265     QString handler = gContext->GetSetting("VideoDefaultPlayer");
     278    QString handler = gContext->GetSetting(wantsAltPlayer ? "VideoAlternatePlayer": "VideoDefaultPlayer");
     279    if (wantsAltPlayer && handler != "")
     280    {
     281        // If user asked for the alternate player command, we don't check for
     282        // specialized player commands
     283        return handler;
     284    }
    266285    QString special_handler = someItem->PlayCommand();
    267286 
    268287    //
     
    306325    return handler;
    307326}
    308327
    309 QString VideoDialog::getCommand(Metadata *someItem)
     328QString VideoDialog::getCommand(Metadata *someItem, bool wantsAltPlayer)
    310329{
    311330    if (!someItem)
    312331        return "";
    313332       
    314333    QString filename = someItem->Filename();
    315     QString handler = getHandler(someItem);
     334    QString handler = getHandler(someItem, wantsAltPlayer);
    316335    QString arg;
    317336    arg.sprintf("\"%s\"",
    318337                filename.replace(QRegExp("\""), "\\\"").utf8().data());
  • mythvideo/mythvideo/videobrowser.cpp

     
    6868        handled = true;
    6969
    7070        if ((action == "SELECT" || action == "PLAY") && curitem)
    71             playVideo(curitem);
     71            playVideo(curitem, false);
    7272        else if (action == "INFO")
    7373            doMenu(true);
    7474        else if (action == "DOWN")
     
    129129        if(info)
    130130        {
    131131            focusButton = popup->addButton(tr("Watch This Video"), this, SLOT(slotWatchVideo()));
     132            if(hasAltPlayer)
     133                popup->addButton(tr("Watch In Alternate Player"), this, SLOT(slotAltWatchVideo()));
    132134            popup->addButton(tr("View Full Plot"), this, SLOT(slotViewPlot()));
    133135        }
    134136        else
  • mythvideo/mythvideo/videogallery.cpp

     
    489489        if(info)
    490490        {
    491491            focusButton = popup->addButton(tr("Watch This Video"), this, SLOT(slotWatchVideo()));
     492            if(hasAltPlayer)
     493                popup->addButton(tr("Watch In Alternate Player"), this, SLOT(slotAltWatchVideo()));
    492494            popup->addButton(tr("View Full Plot"), this, SLOT(slotViewPlot()));
    493495            popup->addButton(tr("View Details"), this, SLOT(handleVideoSelect()));
    494496
  • mythvideo/mythvideo/videotree.h

     
    2727
    2828    void buildVideoList();
    2929   
    30     virtual void playVideo(Metadata *someItem);
    31     QString getHandler(Metadata *someItem);
    32     QString getCommand(Metadata *someItem);
     30    virtual void playVideo(Metadata *someItem, bool wantsAltPlayer);
     31    QString getHandler(Metadata *someItem, bool wantsAltPlayer);
     32    QString getCommand(Metadata *someItem, bool wantsAltPlayer);
    3333       
    3434  public slots:
    3535    void slotDoCancel();
     
    3838    void slotViewPlot();
    3939    void slotDoFilter();
    4040    virtual void slotWatchVideo();
     41    virtual void slotAltWatchVideo();
    4142   
    4243    void handleTreeListSelection(int, IntVector*);
    4344    void handleTreeListEntry(int, IntVector*);
     
    5960    void         wireUpTheme();
    6061    int          current_parental_level;
    6162    bool         file_browser;
     63    bool         hasAltPlayer;
    6264
    6365    //
    6466    //  Theme-related "widgets"