void Client::stream_created(XineStream &stream)
{
+ stream.signal_title_changed.connect(sigc::mem_fun(this, &Client::stream_title_changed));
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();
send_reply("title "+title);
}
+void Client::stream_title_changed(const string &title)
+{
+ send_reply("title "+title);
+}
+
void Client::stream_duration_changed(const Time::TimeDelta &dur)
{
send_reply(format("duration %.3f", dur/Time::sec));
void list_directory(const Msp::FS::Path &);
void stream_created(XineStream &);
+ void stream_title_changed(const std::string &);
void stream_duration_changed(const Msp::Time::TimeDelta &);
void stream_position_changed(const Msp::Time::TimeDelta &);
};
queue = xine_event_new_queue(stream);
+ check_info();
+
engine.add_stream(*this);
}
xine_dispose(stream);
}
-string XineStream::get_title() const
-{
- const char *title = xine_get_meta_info(stream, XINE_META_INFO_TITLE);
- return (title ? title : string());
-}
-
void XineStream::play()
{
xine_play(stream, 0, 0);
xine_event_free(event);
}
+ check_info();
+}
+
+void XineStream::check_info()
+{
+ const char *xt = xine_get_meta_info(stream, XINE_META_INFO_TITLE);
+ if(xt)
+ {
+ if(title.compare(xt))
+ {
+ title = xt;
+ signal_title_changed.emit(title);
+ }
+ }
+ else if(!title.empty())
+ {
+ title.clear();
+ signal_title_changed.emit(title);
+ }
+
int dur_msec, pos_msec;
xine_get_pos_length(stream, 0, &pos_msec, &dur_msec);
Time::TimeDelta dur = dur_msec*Time::msec;
class XineStream
{
public:
+ sigc::signal<void, const std::string &> signal_title_changed;
sigc::signal<void, const Msp::Time::TimeDelta &> signal_duration_changed;
sigc::signal<void, const Msp::Time::TimeDelta &> signal_position_changed;
XineEngine &engine;
xine_stream_t *stream;
xine_event_queue_t *queue;
+ std::string title;
Msp::Time::TimeDelta duration;
Msp::Time::TimeDelta position;
const Msp::Time::TimeDelta &get_duration() const { return duration; }
const Msp::Time::TimeDelta &get_position() const { return position; }
- std::string get_title() const;
+ const std::string &get_title() const { return title; }
void play();
void stop();
void tick();
private:
+ void check_info();
void handle_event(const xine_event_t &);
};