forked from ghostfox/qyouradio
better and better
This commit is contained in:
@@ -9,6 +9,8 @@ Item {
|
||||
// color: Colors.surface1
|
||||
// radius: 10
|
||||
|
||||
StackView.onRemoved: destroy()
|
||||
|
||||
required property string id
|
||||
property bool hasThumbnail: false
|
||||
property bool loading: true
|
||||
@@ -22,13 +24,22 @@ Item {
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
Component.onCompleted: Player.onPositionChanged = () => {
|
||||
console.log("test print");
|
||||
if (Player.id == id) {
|
||||
position = Player.position
|
||||
}
|
||||
}
|
||||
Component.onDestruction: if (Player.id == id) Player.unloadVideo()
|
||||
onPositionChanged: if (Player.id == id) Player.position = position
|
||||
|
||||
ColumnLayout {
|
||||
visible: !loading && !failed
|
||||
anchors.fill: parent
|
||||
|
||||
Image {
|
||||
Layout.fillWidth: true
|
||||
height: width * parent.parent.ratio
|
||||
// height: width * parent.parent.ratio
|
||||
asynchronous: true
|
||||
cache: true
|
||||
source: parent.parent.hasThumbnail ? ("https://youvideo.nonamesoft.xyz/thumbnails/" + parent.parent.id) : "https://youvideo.nonamesoft.xyz/thumbnails/audio.png"
|
||||
@@ -37,25 +48,24 @@ Item {
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
text: Player.loading ? "Loading" : (Player.playing ? "Pause" : "Play")
|
||||
enabled: !Player.loading
|
||||
text: Player.id == id ? (Player.loading ? "Loading" : (Player.playing ? "Pause" : "Play")) : "Play"
|
||||
enabled: Player.id != id || !(Player.loading && Player.id == id)
|
||||
onClicked: function() {
|
||||
if (Player.id != id) {
|
||||
Player.loadVideo(parent.parent.parent.id, parent.parent.parent.extension, parent.parent.parent.title, parent.parent.parent.position);
|
||||
}
|
||||
|
||||
if (Player.playing) {
|
||||
Player.pause()
|
||||
Player.pause();
|
||||
} else {
|
||||
Player.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Stop"
|
||||
onClicked: Player.stop()
|
||||
}
|
||||
|
||||
Label {
|
||||
heading: "h4"
|
||||
text: new Date(Player.position).toISOString().slice(14, 19)
|
||||
text: new Date(parent.parent.parent.position).toISOString().slice(14, 19)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +74,8 @@ Item {
|
||||
from: 0
|
||||
to: parent.parent.parent.duration
|
||||
value: parent.parent.parent.position
|
||||
buffered: Player.buffered
|
||||
onMoved: Player.position = value
|
||||
buffered: Player.id == id ? Player.buffered : 0
|
||||
onMoved: parent.parent.parent.position = value
|
||||
}
|
||||
|
||||
Label {
|
||||
@@ -138,12 +148,12 @@ Item {
|
||||
|
||||
Button {
|
||||
text: "Retry"
|
||||
onClicked: parent.fetchData()
|
||||
onClicked: parent.parent.fetchData()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
interval: 0
|
||||
running: true
|
||||
onTriggered: parent.fetchData()
|
||||
}
|
||||
@@ -166,8 +176,18 @@ Item {
|
||||
title = data.name;
|
||||
description = data.description;
|
||||
extension = data.extension;
|
||||
duration = data.metadata.duration * 1000;
|
||||
ratio = data.metadata.size[0] / data.metadata.size[1];
|
||||
if (ratio == NaN) {
|
||||
ratio = 1.77777;
|
||||
}
|
||||
console.log(ratio);
|
||||
if (Player.id == id) {
|
||||
console.log("Already playing, this is not intended but possible in its current state so it's a feature, not a bug :3");
|
||||
return;
|
||||
}
|
||||
|
||||
Player.loadVideo(id, extension, title, position)
|
||||
}
|
||||
}
|
||||
xhr.ontimeout = function() {
|
||||
|
||||
Reference in New Issue
Block a user