X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=remote%2Fsource%2Fxinemacontrol.cpp;h=db349e73685a7d0472a9a9b7dd9cd0dba860389b;hb=4dd3070fa50882b7ec7a26f7d0994c064c6b29d6;hp=76108b98f815425b32946dda8d8dec7b97990b19;hpb=1abfbdd94fa45883f6d742df00508715f79c9954;p=xinema.git diff --git a/remote/source/xinemacontrol.cpp b/remote/source/xinemacontrol.cpp index 76108b9..db349e7 100644 --- a/remote/source/xinemacontrol.cpp +++ b/remote/source/xinemacontrol.cpp @@ -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,4 +100,29 @@ 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; + emit title_changed(title); + } + else if(keyword=="duration") + { + duration = args.toFloat(); + emit duration_changed(duration); + } + else if(keyword=="position") + { + position = args.toFloat(); + emit position_changed(position); + } }