#include <msp/fs/dir.h>
#include <msp/fs/stat.h>
+#include <msp/strings/format.h>
#include "client.h"
#include "xinema.h"
+#include "xinestream.h"
using namespace std;
using namespace Msp;
{
socket->signal_data_available.connect(sigc::mem_fun(this, &Client::data_available));
socket->signal_end_of_file.connect(sigc::mem_fun(this, &Client::end_of_stream));
+
+ xinema.signal_stream_created.connect(sigc::mem_fun(this, &Client::stream_created));
}
void Client::data_available()
send_reply("file "+*i);
}
}
+
+void Client::stream_created(XineStream &stream)
+{
+ stream.signal_duration_changed.connect(sigc::mem_fun(this, &Client::stream_duration_changed));
+ stream.signal_position_changed.connect(sigc::mem_fun(this, &Client::stream_position_changed));
+ string title = stream.get_title();
+ if(!title.empty())
+ send_reply("title "+title);
+}
+
+void Client::stream_duration_changed(const Time::TimeDelta &dur)
+{
+ send_reply(format("duration %.3f", dur/Time::sec));
+}
+
+void Client::stream_position_changed(const Time::TimeDelta &pos)
+{
+ if(abs(pos-last_position)>=Time::sec)
+ {
+ send_reply(format("position %.3f", pos/Time::sec));
+ last_position = pos;
+ }
+}