MediaPlayer: more robust display
This commit is contained in:
parent
474bade65c
commit
f0ef9ac7b0
2 changed files with 10 additions and 7 deletions
|
|
@ -58,7 +58,7 @@ NBox {
|
|||
ColumnLayout {
|
||||
id: main
|
||||
|
||||
visible: MediaPlayer.currentPlayer
|
||||
visible: MediaPlayer.currentPlayer && MediaPlayer.canPlay
|
||||
spacing: Style.marginMedium * scaling
|
||||
|
||||
// Player selector
|
||||
|
|
@ -229,12 +229,14 @@ NBox {
|
|||
// Progress bar
|
||||
Rectangle {
|
||||
id: progressBarBackground
|
||||
visible: (MediaPlayer.currentPlayer && MediaPlayer.trackLength > 0)
|
||||
width: parent.width
|
||||
height: 4 * scaling
|
||||
radius: Style.radiusSmall * scaling
|
||||
color: Colors.mSurfaceVariant
|
||||
color: Colors.mSurface
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
||||
property real progressRatio: {
|
||||
if (!MediaPlayer.currentPlayer || !MediaPlayer.isPlaying || MediaPlayer.trackLength <= 0) {
|
||||
return 0
|
||||
|
|
@ -259,17 +261,15 @@ NBox {
|
|||
// Interactive progress handle
|
||||
Rectangle {
|
||||
id: progressHandle
|
||||
visible: (MediaPlayer.currentPlayer && MediaPlayer.trackLength > 0)
|
||||
width: 16 * scaling
|
||||
height: 16 * scaling
|
||||
radius: width * 0.5
|
||||
color: Colors.mPrimary
|
||||
border.color: Colors.mSurface
|
||||
border.width: Math.max(1 * Style.borderMedium * scaling)
|
||||
|
||||
x: Math.max(0, Math.min(parent.width - width, progressFill.width - width / 2))
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
visible: MediaPlayer.trackLength > 0
|
||||
scale: progressMouseArea.containsMouse || progressMouseArea.pressed ? 1.2 : 1.0
|
||||
|
||||
Behavior on scale {
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ Singleton {
|
|||
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 real trackLength: currentPlayer ? ((currentPlayer.length < infiniteTrackLength) ? currentPlayer.length : 0) : 0
|
||||
property bool canPlay: currentPlayer ? currentPlayer.canPlay : false
|
||||
property bool canPause: currentPlayer ? currentPlayer.canPause : false
|
||||
property bool canGoNext: currentPlayer ? currentPlayer.canGoNext : false
|
||||
property bool canGoPrevious: currentPlayer ? currentPlayer.canGoPrevious : false
|
||||
property bool canSeek: currentPlayer ? currentPlayer.canSeek : false
|
||||
property bool hasPlayer: getAvailablePlayers().length > 0
|
||||
property real infiniteTrackLength: 922337203685
|
||||
|
||||
Component.onCompleted: {
|
||||
updateCurrentPlayer()
|
||||
|
|
@ -49,6 +49,7 @@ Singleton {
|
|||
function findActivePlayer() {
|
||||
let availablePlayers = getAvailablePlayers()
|
||||
if (availablePlayers.length === 0) {
|
||||
console.log("[MediaPlayer] No active player found")
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +67,7 @@ Singleton {
|
|||
if (newPlayer !== currentPlayer) {
|
||||
currentPlayer = newPlayer
|
||||
currentPosition = currentPlayer ? currentPlayer.position : 0
|
||||
console.log("[MediaPlayer] Switching player")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +148,7 @@ Singleton {
|
|||
Connections {
|
||||
target: Mpris.players
|
||||
function onValuesChanged() {
|
||||
console.log("[MediaPlayer] Players changed")
|
||||
updateCurrentPlayer()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue