]> git.tdb.fi Git - xinema.git/blobdiff - remote/source/xinemacontrol.cpp
Implement seeking and play/pause controls in the remote
[xinema.git] / remote / source / xinemacontrol.cpp
index 63399a6e4a0bcde7bfd9861b2193c9db9570a44d..db349e73685a7d0472a9a9b7dd9cd0dba860389b 100644 (file)
@@ -1,6 +1,9 @@
 #include "xinemacontrol.h"
 
-XinemaControl::XinemaControl()
+XinemaControl::XinemaControl():
+       playback_state(STOPPED),
+       duration(0.0f),
+       position(0.0f)
 {
        QObject::connect(&socket, &QAbstractSocket::connected, this, &XinemaControl::connected);
        QObject::connect(&socket, &QAbstractSocket::disconnected, this, &XinemaControl::disconnected);
@@ -33,6 +36,26 @@ void XinemaControl::play_file(const QString &fn)
        send_request("play_file "+fn);
 }
 
+void XinemaControl::play()
+{
+       send_request("play");
+}
+
+void XinemaControl::seek(float time)
+{
+       send_request(QString("seek %1").arg(time));
+}
+
+void XinemaControl::pause()
+{
+       send_request("pause");
+}
+
+void XinemaControl::stop()
+{
+       send_request("stop");
+}
+
 void XinemaControl::send_request(const QString &req)
 {
        socket.write(req.toUtf8());
@@ -77,6 +100,16 @@ void XinemaControl::process_reply(const QString &reply)
                emit subdirectory_added(args);
        else if(keyword=="file")
                emit file_added(args);
+       else if(keyword=="state")
+       {
+               if(args=="STOPPED")
+                       playback_state = STOPPED;
+               else if(args=="PAUSED")
+                       playback_state = PAUSED;
+               else if(args=="PLAYING")
+                       playback_state = PLAYING;
+               emit playback_state_changed(playback_state);
+       }
        else if(keyword=="title")
        {
                title = args;