summary refs log tree commit diff
path: root/resources/qml/ui
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2021-11-09 23:52:59 -0500
committerJoseph Donofry <joedonofry@gmail.com>2021-11-09 23:52:59 -0500
commite3eb87cc214337dbf3e629706857a78c6bfda284 (patch)
treee102535703a82dae63335eed0f162c7f18440369 /resources/qml/ui
parentFix audio player and use same controls for video and audio (diff)
downloadnheko-e3eb87cc214337dbf3e629706857a78c6bfda284.tar.xz
More player fixes
Diffstat (limited to 'resources/qml/ui')
-rw-r--r--resources/qml/ui/media/MediaControls.qml24
1 files changed, 19 insertions, 5 deletions
diff --git a/resources/qml/ui/media/MediaControls.qml b/resources/qml/ui/media/MediaControls.qml
index de3e98a7..ec522391 100644
--- a/resources/qml/ui/media/MediaControls.qml
+++ b/resources/qml/ui/media/MediaControls.qml
@@ -22,7 +22,8 @@ Item {
     property int controlHeight: 25
     property bool shouldShowControls: playerMouseArea.shouldShowControls || volumeSlider.controlsVisible
 
-    signal activated(real mouseX, real mouseY)
+    signal playPauseActivated(real mouseX, real mouseY)
+    signal loadActivated(real mouseX, real mouseY)
 
     function durationToString(duration) {
         function maybeZeroPrepend(time) {
@@ -48,7 +49,9 @@ Item {
 
         property bool shouldShowControls: (containsMouse && controlHideTimer.running) || (control.mediaState != MediaPlayer.PlayingState) || controlRect.contains(mapToItem(controlRect, mouseX, mouseY))
 
-        onClicked: control.activated(mouseX, mouseY)
+        onClicked: {
+            control.mediaLoaded ? control.playPauseActivated(mouseX, mouseY) : control.loadActivated(mouseX, mouseY);
+        }
         hoverEnabled: true
         onPositionChanged: controlHideTimer.start()
         onExited: controlHideTimer.start()
@@ -75,7 +78,7 @@ Item {
             anchors.fill: parent
             width: parent.width
 
-            // Play/pause button
+            // Cache/Play/pause button
             Image {
                 id: playbackStateImage
 
@@ -84,14 +87,25 @@ Item {
                 fillMode: Image.PreserveAspectFit
                 Layout.preferredHeight: control.controlHeight
                 Layout.alignment: Qt.AlignVCenter
-                source: (control.mediaState == MediaPlayer.PlayingState) ? "image://colorimage/:/icons/icons/ui/pause-symbol.png?" + controlColor : "image://colorimage/:/icons/icons/ui/play-sign.png?" + controlColor
+                source: {
+                    if (control.mediaLoaded) {
+                        if (control.mediaState == MediaPlayer.PlayingState)
+                            return "image://colorimage/:/icons/icons/ui/pause-symbol.png?" + controlColor;
+                        else
+                            return "image://colorimage/:/icons/icons/ui/play-sign.png?" + controlColor;
+                    } else {
+                        return "image://colorimage/:/icons/icons/ui/arrow-pointing-down.png?" + controlColor;
+                    }
+                }
 
                 MouseArea {
                     id: playbackStateArea
 
                     anchors.fill: parent
                     hoverEnabled: true
-                    onClicked: control.activated(mouseX, mouseY)
+                    onClicked: {
+                        control.mediaLoaded ? control.playPauseActivated(mouseX, mouseY) : control.loadActivated(mouseX, mouseY);
+                    }
                 }
 
             }