MediaPlayer/Card WIP

This commit is contained in:
quadbyte 2025-08-13 18:04:32 -04:00
parent a1b6c0845d
commit d4eff97566
3 changed files with 611 additions and 56 deletions

View file

@ -1,7 +1,8 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Services
Singleton {
id: root
@ -59,19 +60,19 @@ Singleton {
stdout: SplitParser {
splitMarker: ""
onRead: data => {
const newValues = Array(count).fill(0)
for (var i = 0; i < values.length; i++) {
newValues[i] = values[i]
}
if (process.index + data.length > count) {
process.index = 0
}
for (var i = 0; i < data.length; i += 1) {
newValues[process.index] = Math.min(data.charCodeAt(i), 128) / 128
process.index = (process.index + 1) % count
}
values = newValues
}
const newValues = Array(count).fill(0)
for (var i = 0; i < values.length; i++) {
newValues[i] = values[i]
}
if (process.index + data.length > count) {
process.index = 0
}
for (var i = 0; i < data.length; i += 1) {
newValues[process.index] = Math.min(data.charCodeAt(i), 128) / 128
process.index = (process.index + 1) % count
}
values = newValues
}
}
}
}

View file

@ -12,9 +12,9 @@ Singleton {
property real currentPosition: 0
property int selectedPlayerIndex: 0
property bool isPlaying: currentPlayer ? currentPlayer.isPlaying : false
property string trackTitle: currentPlayer ? (currentPlayer.trackTitle || "Unknown Track") : ""
property string trackArtist: currentPlayer ? (currentPlayer.trackArtist || "Unknown Artist") : ""
property string trackAlbum: currentPlayer ? (currentPlayer.trackAlbum || "Unknown Album") : ""
property string trackTitle: currentPlayer ? (currentPlayer.trackTitle || "") : ""
property string trackArtist: currentPlayer ? (currentPlayer.trackArtist || "") : ""
property string trackAlbum: currentPlayer ? (currentPlayer.trackAlbum || "") : ""
property string trackArtUrl: currentPlayer ? (currentPlayer.trackArtUrl || "") : ""
property real trackLength: currentPlayer ? currentPlayer.length : 0
property bool canPlay: currentPlayer ? currentPlayer.canPlay : false
@ -24,13 +24,8 @@ Singleton {
property bool canSeek: currentPlayer ? currentPlayer.canSeek : false
property bool hasPlayer: getAvailablePlayers().length > 0
// Expose cava values
property alias cavaValues: cava.values
Item {
Component.onCompleted: {
updateCurrentPlayer()
}
Component.onCompleted: {
updateCurrentPlayer()
}
function getAvailablePlayers() {
@ -154,8 +149,4 @@ Singleton {
updateCurrentPlayer()
}
}
Cava {
id: cava
}
}