{
text: modelData
- onPressed: xinemaControl.play_file(browseDirectory.directory+"/"+modelData);
+ onPressed:
+ {
+ xinemaControl.play_file(browseDirectory.directory+"/"+modelData);
+ pageStack.replace("PlaybackPage.qml");
+ }
}
}
}
--- /dev/null
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import fi.mikkosoft.xinema 0.1
+
+Page
+{
+ id: page
+
+ Column
+ {
+ width: parent.width
+ spacing: Theme.paddingLarge
+
+ PageHeader
+ {
+ title: qsTr("Playback")
+ }
+
+ Label
+ {
+ text: streamControl.title
+ }
+
+ Slider
+ {
+ id: slider
+ width: parent.width
+ minimumValue: 0.0
+ maximumValue: Math.max(streamControl.duration, 1.0)
+ valueText:
+ {
+ var secs = Math.round(value);
+ var mins = Math.floor(secs/60);
+ secs %= 60;
+ var hours = Math.floor(mins/60);
+ mins %= 60;
+
+ var str = "";
+ if(hours>0)
+ {
+ str = hours+":";
+ if(mins<10)
+ str += "0";
+ }
+
+ str += mins+":";
+ if(secs<10)
+ str += "0";
+
+ return str+secs;
+ }
+ }
+ }
+
+ StreamControl
+ {
+ id: streamControl
+ control: xinemaControl
+ onPositionChanged:
+ {
+ if(!slider.down)
+ slider.value = streamControl.position
+ }
+ }
+}
source/discovery.cpp \
source/discoveryitem.cpp \
source/remote.cpp \
+ source/streamcontrolitem.cpp \
source/xinemacontrol.cpp \
source/xinemacontrolitem.cpp
HEADERS += source/browsedirectoryitem.h \
source/discovery.h \
source/discoveryitem.h \
+ source/streamcontrolitem.h \
source/xinemacontrol.h \
source/xinemacontrolitem.h
#include <sailfishapp.h>
#include "browsedirectoryitem.h"
#include "discoveryitem.h"
+#include "streamcontrolitem.h"
#include "xinemacontrolitem.h"
int main(int argc, char **argv)
QGuiApplication *app = SailfishApp::application(argc, argv);
qmlRegisterType<BrowseDirectoryItem>("fi.mikkosoft.xinema", 0, 1, "BrowseDirectory");
qmlRegisterType<DiscoveryItem>("fi.mikkosoft.xinema", 0, 1, "Discovery");
+ qmlRegisterType<StreamControlItem>("fi.mikkosoft.xinema", 0, 1, "StreamControl");
qmlRegisterType<XinemaControlItem>("fi.mikkosoft.xinema", 0, 1, "XinemaControl");
QQuickView *view = SailfishApp::createView();
view->setSource(SailfishApp::pathTo("qml/main.qml"));
--- /dev/null
+#include "streamcontrolitem.h"
+#include "xinemacontrolitem.h"
+
+StreamControlItem::StreamControlItem():
+ control(0)
+{
+}
+
+void StreamControlItem::set_control(XinemaControlItem *c)
+{
+ if(control)
+ disconnect(control, 0, this, 0);
+
+ control = c;
+ if(control)
+ {
+ XinemaControl &xc = control->get_control();
+ 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);
+ }
+
+ emit control_changed();
+
+ if(control)
+ {
+ emit title_changed();
+ emit duration_changed();
+ emit position_changed();
+ }
+}
+
+QString StreamControlItem::get_title() const
+{
+ if(!control)
+ return QString();
+
+ return control->get_control().get_title();
+}
+
+float StreamControlItem::get_duration() const
+{
+ if(!control)
+ return 0;
+
+ return control->get_control().get_duration();
+}
+
+float StreamControlItem::get_position() const
+{
+ if(!control)
+ return 0;
+
+ return control->get_control().get_position();
+}
--- /dev/null
+#ifndef STREAMCONTROLITEM_H_
+#define STREAMCONTROLITEM_H_
+
+#include <QQuickItem>
+
+class XinemaControlItem;
+
+class StreamControlItem: public QQuickItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(XinemaControlItem *control READ get_control WRITE set_control NOTIFY control_changed)
+ Q_PROPERTY(QString title READ get_title NOTIFY title_changed)
+ Q_PROPERTY(float duration READ get_duration NOTIFY duration_changed)
+ Q_PROPERTY(float position READ get_position NOTIFY position_changed)
+
+private:
+ XinemaControlItem *control;
+
+public:
+ StreamControlItem();
+
+ void set_control(XinemaControlItem *);
+ XinemaControlItem *get_control() const { return control; }
+
+ QString get_title() const;
+ float get_duration() const;
+ float get_position() const;
+
+signals:
+ void control_changed();
+ void title_changed();
+ void duration_changed();
+ void position_changed();
+};
+
+#endif
emit subdirectory_added(args);
else if(keyword=="file")
emit file_added(args);
+ 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);
+ }
}
private:
QTcpSocket socket;
QByteArray buffer;
+ QString title;
+ float duration;
+ float position;
public:
XinemaControl();
void list_directory(const QString &);
void play_file(const QString &);
+ const QString &get_title() const { return title; }
+ float get_duration() const { return duration; }
+ float get_position() const { return position; }
+
signals:
void connected();
void disconnected();
void directory_started(const QString &);
void file_added(const QString &);
void subdirectory_added(const QString &);
+ void title_changed(const QString &);
+ void duration_changed(float);
+ void position_changed(float);
private:
void send_request(const QString &);