]> git.tdb.fi Git - xinema.git/blobdiff - remote/source/streamcontrolitem.cpp
Implement seeking and play/pause controls in the remote
[xinema.git] / remote / source / streamcontrolitem.cpp
index a225d52494f2366c63494c7015de75706a48846b..b7624df813d6c5f45cbe24cf99171fdeb84320f5 100644 (file)
@@ -15,6 +15,7 @@ void StreamControlItem::set_control(XinemaControlItem *c)
        if(control)
        {
                XinemaControl &xc = control->get_control();
+               connect(&xc, &XinemaControl::playback_state_changed, this, &StreamControlItem::playback_state_changed);
                connect(&xc, &XinemaControl::title_changed, this, &StreamControlItem::title_changed);
                connect(&xc, &XinemaControl::duration_changed, this, &StreamControlItem::duration_changed);
                connect(&xc, &XinemaControl::position_changed, this, &StreamControlItem::position_changed);
@@ -24,12 +25,35 @@ void StreamControlItem::set_control(XinemaControlItem *c)
 
        if(control)
        {
+               emit playback_state_changed();
                emit title_changed();
                emit duration_changed();
                emit position_changed();
        }
 }
 
+StreamControlItem::PlaybackState StreamControlItem::get_playback_state() const
+{
+       if(!control)
+               return Stopped;
+
+       return static_cast<PlaybackState>(control->get_control().get_playback_state());
+}
+
+void StreamControlItem::set_playback_state(PlaybackState state)
+{
+       if(!control)
+               return;
+
+       XinemaControl &xc = control->get_control();
+       if(state==Stopped)
+               xc.stop();
+       else if(state==Paused)
+               xc.pause();
+       else if(state==Playing)
+               xc.play();
+}
+
 QString StreamControlItem::get_title() const
 {
        if(!control)
@@ -46,6 +70,12 @@ float StreamControlItem::get_duration() const
        return control->get_control().get_duration();
 }
 
+void StreamControlItem::set_position(float pos)
+{
+       if(control)
+               control->get_control().seek(pos);
+}
+
 float StreamControlItem::get_position() const
 {
        if(!control)