mpv support
authorKonrad Rosenbaum <konrad@silmor.de>
Sun, 16 Jul 2023 17:15:07 +0000 (19:15 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Sun, 16 Jul 2023 17:15:07 +0000 (19:15 +0200)
kino.cpp
kino.h

index 992de94..1423b84 100644 (file)
--- a/kino.cpp
+++ b/kino.cpp
@@ -49,13 +49,15 @@ Kino::Kino(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
        bar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
        bar->setIconSize(QSize(48,48));
        QAction*a=mplayaction=bar->addAction(QIcon(":/play-dvd.png"),"&Play",this,SLOT(playMedia()));
-       a->setToolTip("Play Media: Alt-P\nPlay without full-screen: Alt-Shift-P");
+       a->setToolTip("Play Media:\n  Alt-P - Xine fullscreen\n  Alt-Shift-P - Xine Window\n  Alt-V - VLC fullscreen\n  Alt-Shift-V - VLC Window\n  Alt-M - MPV fullscreen\n  Alt-Shift-M - MPV Window");
     QMenu*m=new QMenu;
     a->setMenu(m);
     a=m->addAction("Play with Xine",this,SLOT(playMedia()),QKeySequence("Alt+P"));
     a=m->addAction("Play with Xine, no FullScreen",this,[this](){this->playMedia(false);},QKeySequence("Alt+Shift+P"));
     a=m->addAction("Play with VLC",this,[this](){this->playMedia(true,Player::Vlc);},QKeySequence("Alt+V"));
     a=m->addAction("Play with VLC, no FullScreen",this,[this](){this->playMedia(false,Player::Vlc);},QKeySequence("Alt+Shift+V"));
+    a=m->addAction("Play with MPV",this,[this](){this->playMedia(true,Player::Mpv);},QKeySequence("Alt+M"));
+    a=m->addAction("Play with MPV, no FullScreen",this,[this](){this->playMedia(false,Player::Mpv);},QKeySequence("Alt+Shift+M"));
        a=meditaction=bar->addAction(QIcon(":/configure.png"),"&Edit Description",this,SLOT(editMedia()));
        a->setShortcut(QKeySequence("Alt+E"));
        a->setToolTip("Edit Media Description: Alt-E");
@@ -156,6 +158,17 @@ void Kino::findRoot()
 //             qDebug()<<"Searching for kino.ini in"<<tokens[1];
                QFileInfo fi(path+"/kino.ini");
                if(fi.exists()&&fi.isFile())mRoot<<path;
+        //find super volume and descend into .... whatever
+        fi=QFileInfo(path+"/kino.super");
+        if(fi.exists()){
+            qDebug()<<"Kino found a super volume in"<<path;
+            for(auto subdir:QDir(path).entryList(QDir::Dirs|QDir::NoDotAndDotDot)){
+                QString spath=path+"/"+subdir;
+                fi=QFileInfo(spath+"/kino.ini");
+                qDebug()<<"...checking sub-volume"<<spath;
+                if(fi.exists()&&fi.isFile())mRoot<<spath;
+            }
+        }
        }
        qDebug()<<"found roots:"<<mRoot;
        //initialize from physical volumes
@@ -375,17 +388,26 @@ bool Kino::play(QString p,bool f,Player player)
        if(vol.volumeId().isNull())return false;
        auto &ent=getEntry(vol,p);
        if(!ent.isPlayable())return false;
-       //construct MRL
-       QString mrl=QString("dvd://%1/%2").arg(vol.rootdir()).arg(ent.directory());
        //start; TODO: keep track of running processes
     QStringList args;
     if(f){
         if(player==Player::Xine)args<<"-f";
-        else if(player==Player::Vlc)args<<"--fullscreen";
+        else if(player==Player::Vlc||player==Player::Mpv)args<<"--fullscreen";
         else qDebug()<<"OOOOPS! Unknown Player type!";
     }
-    args<<mrl;
-       QProcess::startDetached(player==Player::Xine?"xine":"vlc",args);
+       //construct MRL
+       if(player!=Player::Mpv)
+        args<<QString("dvd://%1/%2").arg(vol.rootdir()).arg(ent.directory());
+    else
+        args<<"dvd://"<<QString("/%1/%2").arg(vol.rootdir()).arg(ent.directory());
+    //select program
+    QString prog;
+    switch(player){
+        case Player::Xine:prog="xine";break;
+        case Player::Vlc:prog="vlc";break;
+        case Player::Mpv:prog="mpv";break;
+    }
+       QProcess::startDetached(prog,args);
        return true;
 }
 
diff --git a/kino.h b/kino.h
index 11af822..002a283 100644 (file)
--- a/kino.h
+++ b/kino.h
@@ -38,7 +38,7 @@ struct History_s
 class Kino:public QWidget
 {
        Q_OBJECT
-       enum class Player {Xine,Vlc,Default=Xine};
+       enum class Player {Xine,Vlc,Mpv,Default=Xine};
 public:
        ///instantiates main window, loads old state
        explicit Kino(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags());