forked from ghostfox/qyouradio
heugh jazz
This commit is contained in:
@@ -4,23 +4,19 @@ import QtQuick.Layouts 6.8
|
||||
|
||||
import QYRComponents 1.0
|
||||
|
||||
ColumnLayout {
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
|
||||
property bool loading: true
|
||||
property bool failed: false
|
||||
|
||||
VideoPlayer {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: false
|
||||
}
|
||||
|
||||
GridView {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
// anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: Player.active ? 96 : 0
|
||||
visible: !loading || !failed
|
||||
// anchors.fill: parent
|
||||
anchors.fill: parent
|
||||
model: ListModel { id: model }
|
||||
clip: true
|
||||
|
||||
@@ -28,8 +24,6 @@ ColumnLayout {
|
||||
cellHeight: 224
|
||||
|
||||
delegate: VideoEntry {}
|
||||
|
||||
Component.onCompleted: parent.fetchData()
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
@@ -66,6 +60,12 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
onTriggered: parent.fetchData()
|
||||
}
|
||||
|
||||
function fetchData() {
|
||||
model.clear();
|
||||
loading = true;
|
||||
@@ -76,15 +76,29 @@ ColumnLayout {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE) {
|
||||
loading = false;
|
||||
if (xhr.status != 200) {
|
||||
console.log("Invalid response");
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
const data = JSON.parse(xhr.responseText);
|
||||
console.log("Received data, found " + data.length + " videos");
|
||||
data.forEach(video => {
|
||||
model.append(video);
|
||||
});
|
||||
}
|
||||
}
|
||||
xhr.ontimeout = function() {
|
||||
loading = false;
|
||||
failed = true;
|
||||
console.log("Request timed out");
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
VideoPlayer {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user