]> Some of my projects - localmylist.git/commitdiff
Add MyList::playFile
authorAPTX <marek321@gmail.com>
Sun, 31 May 2015 10:18:03 +0000 (12:18 +0200)
committerAPTX <marek321@gmail.com>
Sun, 31 May 2015 10:21:14 +0000 (12:21 +0200)
This method opens the file from OpenFileData
in a video player. play-next now uses this method.
It is available in the scripting API.

localmylist/mylist.cpp
localmylist/mylist.h
play-next/main.cpp

index c46da34601a84058f45b2db7f8e649cfdc9330ce..64a6e2df328b16e3a11ae2181f23a6d8138aa22f 100644 (file)
@@ -3,6 +3,7 @@
 #include <QMetaType>
 #include <QCoreApplication>
 #include <QHostInfo>
+#include <QProcess>
 
 #include "database.h"
 #include "abstracttask.h"
@@ -175,6 +176,23 @@ void MyList::voteEpisode(int aid, int epno, const QString &epType, double vote)
        database()->addPendingMyListUpdate(pmu);
 }
 
+bool MyList::playFile(const OpenFileData &ofd, const QStringList &additionalArguments)
+{
+       if (!ofd.fid)
+               return false;
+
+       QSettings &settings = *defaultLocalQSettings();
+       settings.beginGroup("cli");
+       QString player = settings.value("player", QString()).toString();
+       settings.endGroup();
+
+       if (player.isEmpty())
+               return false;
+
+       QStringList args = QStringList() << ofd.path << additionalArguments;
+
+       return QProcess::startDetached(player, args);
+}
 
 void MyList::setupUdpClient()
 {
index b53fe6fffb7916a4b0e7d6e162062ba9d631e7b1..9fa1a54b8d3a01173c735ce4241d2999b4fd64ba 100644 (file)
@@ -62,6 +62,18 @@ public slots:
        void voteEpisode(int eid, double vote);
        void voteEpisode(int aid, int epno, const QString &epType, double vote);
 
+       /**
+        * @brief playFile open a file in a video player
+        * @param ofd OpenFileData - file to open
+        * @param additionalArguments Additional arguments to pass to the player.
+        *        The file's path is passed as the first argument
+        * @return true on success, false on failure
+        *
+        * @note cli/player must be set in the local config
+        */
+       bool playFile(const LocalMyList::OpenFileData &ofd,
+                                 const QStringList &additionalArguments = QStringList());
+
        AbstractTask *addFile(const QFileInfo &file);
        AbstractTask *addDirectory(const QDir &directory);
        AbstractTask *importTitles(const QFileInfo &file);
index abbd24196a814f7978a42a56ea8d39ff866e9b71..b00a516d36fdab3bdd63d132f1915ad16699e88b 100644 (file)
@@ -3,7 +3,6 @@
 #include <QFile>
 #include <QStringList>
 #include <QTextStream>
-#include <QProcess>
 
 #include "mylist.h"
 #include "database.h"
@@ -61,7 +60,7 @@ int main(int argc, char *argv[])
        cout << "EPISODE " << data.epno << " - " << data.episodeTitle << endl;
        cout << "Starting player..." << endl;
 
-       QProcess::startDetached(player, QStringList() << data.path);
+       MyList::instance()->playFile(data);
        return 0;