Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
Signed-off-by: Conrad Hübler <Conrad.Huebler@gmx.net>
  • Loading branch information
conradhuebler committed Dec 31, 2024
1 parent 1b88ee3 commit 9b1922e
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 60 deletions.
18 changes: 17 additions & 1 deletion qml/components/MediaController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ Item {
else if (error === MediaPlayer.FormatError) errorMsg = qsTr("Error: Video or Audio format is not supported")
else if (error === MediaPlayer.AccessDenied) errorMsg = qsTr("Error: Access denied to the video")
else if (error === MediaPlayer.NetworkError) errorMsg = qsTr("Error: Network error")
console.log(errorMsg)
stop()
isPlaying = false
}

onStopped: {
console.log("Playback stopped, look for next track")
if (!blockAutoNext) {
console.log("playing next track is not blocked by user interface")
if (playlistManager.canNext) {
playlistManager.nextTrack()
} else {
playlistManager.playListFinished()
isPlaying = false
}
}else{
console.log("playing next track is blocked by user interface")
//blockAutoNext = false
}
blockAutoNext = false
}

onPositionChanged: {
Expand All @@ -114,6 +119,13 @@ Item {
onPaused: {
mprisPlayer.playbackStatus = Mpris.Paused
}

onStatusChanged:
{
console.log("Playback state changed: ", playbackState)
console.log("Next and prev ", playlistManager.canNext, playlistManager.canPrev)
console.log(errorMsg)
}
}

// MPRIS Connections
Expand Down Expand Up @@ -169,9 +181,13 @@ Item {
}

function playUrl(url) {
mediaPlayer.blockAutoNext = true
console.log("only this function is allowed to start playback", url)
mediaPlayer.source = url
mediaPlayer.play()
console.log("track time", mediaPlayer.duration)
console.log("track time", mediaPlayer.metaData.albumArtist)
mediaPlayer.blockAutoNext = false
}


Expand Down
10 changes: 3 additions & 7 deletions qml/components/PlaylistManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,16 @@ Item {

function nextTrack() {
console.log("Next track called", mediaController.playbackState)
//if(mediaController.playbackState !== 1) {
playlistPython.canNext = false
playlistPython.nextTrack()
//}
playlistPython.nextTrack()
currentTrackIndex()
//playTrack()
}

function nextTrackClicked() {
console.log("Next track called")
console.log("Next track clicked")
mediaController.blockAutoNext = true
playlistPython.canNext = false
playlistPython.nextTrack()
currentTrackIndex()
mediaController.blockAutoNext = false
}

function restartTrack(id) {
Expand Down
2 changes: 1 addition & 1 deletion qml/harbour-tidalplayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ApplicationWindow
}
cover: CoverPage {
application: applicationWindow
home : firstpage
//home : firstpage
}
allowedOrientations: defaultAllowedOrientations

Expand Down
164 changes: 136 additions & 28 deletions qml/pages/AlbumPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Page {
id: albumPage
property int albumId: -1
property var albumData: null
property bool isHeaderCollapsed: false

allowedOrientations: Orientation.All

Expand All @@ -21,8 +22,16 @@ Page {

contentHeight: column.height

PullDownMenu {
// Überwache das Scrollen des Flickable
onContentYChanged: {
if (contentY > Theme.paddingLarge) {
isHeaderCollapsed = true
} else {
isHeaderCollapsed = false
}
}

PullDownMenu {
MenuItem {
text: minPlayerPanel.open ? "Hide player" : "Show player"
onClicked: minPlayerPanel.open = !minPlayerPanel.open
Expand All @@ -39,44 +48,143 @@ Page {
title: albumData ? albumData.title : qsTr("Album Info")
}

Image {
id: coverImage
width: parent.width * 0.8
height: width
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
source: albumData ? albumData.image : ""

Rectangle {
color: Theme.rgba(Theme.highlightBackgroundColor, 0.1)
anchors.fill: parent
visible: coverImage.status !== Image.Ready
Item {
id: albumInfoContainer
width: parent.width
height: isHeaderCollapsed ? Theme.itemSizeLarge : parent.width * 0.4
clip: true

Behavior on height {
NumberAnimation { duration: 200 }
}

Row {
width: parent.width
height: parent.height
spacing: Theme.paddingMedium
anchors.margins: Theme.paddingMedium

Image {
id: coverImage
width: parent.height
height: width
fillMode: Image.PreserveAspectFit
source: albumData ? albumData.image : ""

Rectangle {
color: Theme.rgba(Theme.highlightBackgroundColor, 0.1)
anchors.fill: parent
visible: coverImage.status !== Image.Ready
}
}

Column {
width: parent.width - coverImage.width - parent.spacing - Theme.paddingLarge * 2
height: parent.height
spacing: Theme.paddingSmall
anchors.verticalCenter: parent.verticalCenter

Label {
id: artistName
width: parent.width
text: albumData ? albumData.artist : ""
truncationMode: TruncationMode.Fade
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
}

Label {
width: parent.width
text: albumData ? Format.formatDuration(albumData.duration, Format.DurationLong) : ""
color: Theme.secondaryHighlightColor
font.pixelSize: Theme.fontSizeMedium
}

Label {
width: parent.width
text: albumData ? qsTr("Released: ") + albumData.releaseDate : ""
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
opacity: isHeaderCollapsed ? 0.0 : 1.0
visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: 150 } }
}

Label {
width: parent.width
text: albumData ? qsTr("Tracks: ") + albumData.numberOfTracks : ""
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
opacity: isHeaderCollapsed ? 0.0 : 1.0
visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: 150 } }
}
}
}
}
Row {
id: albumControlBar
width: parent.width
height: Theme.itemSizeSmall
spacing: Theme.paddingMedium
anchors {
left: parent.left
right: parent.right
margins: Theme.paddingMedium
}

Label {
id: artistName
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: albumData ? albumData.artist : ""
truncationMode: TruncationMode.Fade
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeLarge
IconButton {
width: Theme.iconSizeMedium
height: Theme.iconSizeMedium
icon.source: "image://theme/icon-m-play"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if (albumData) {
playlistManager.clearPlayList()
playlistManager.playAlbum(albumId)
playlistManager.playTrack(0)
}
}
}

IconButton {
width: Theme.iconSizeMedium
height: Theme.iconSizeMedium
icon.source: "image://theme/icon-m-add"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if (albumData) {
playlistManager.playAlbum(albumId)
}
}
}

Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: albumData ? Format.formatDuration(albumData.duration, Format.DurationLong) : ""
color: Theme.secondaryHighlightColor
font.pixelSize: Theme.fontSizeMedium
text: qsTr("Play Album")
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeSmall
anchors.verticalCenter: parent.verticalCenter
}

Item {
width: parent.width
height: Theme.paddingLarge
width: Theme.paddingLarge
height: parent.height
}

Label {
text: albumData ? qsTr("%n tracks", "", albumData.numberOfTracks) : ""
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
anchors.verticalCenter: parent.verticalCenter
}
}

// Optional: Füge einen Separator hinzu
Separator {
width: parent.width
color: Theme.primaryColor
horizontalAlignment: Qt.AlignHCenter
}
TrackList {
id: trackList
width: parent.width
Expand Down
6 changes: 4 additions & 2 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Page {
property int currentIndex : 0
// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
clip: true
id: flickable
anchors {
fill: parent
bottomMargin: minPlayerPanel.margin
}
contentHeight: parent.height - miniPlayerPanel.height

contentHeight: column.height

// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
PullDownMenu {
Expand Down
3 changes: 2 additions & 1 deletion qml/pages/Personal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ Item {
MenuItem {
text: qsTr("Play Playlist")
onClicked: {
playlistManager.clearPlayList()
tidalApi.playPlaylist(model.id)
playlistManager.nextTrack()
playlistManager.nextTrackClicked()
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions qml/pages/stuff/SearchResultDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,14 @@ ListItem {
case 1: // Track
pageStack.push(Qt.resolvedUrl("../AlbumPage.qml"),
{
"albumId": item.albumid // oder wie auch immer deine Album-ID gespeichert ist
"albumId": item.albumid
})
console.log(item.albumid)
break
case 2: // Album
pageStack.push(Qt.resolvedUrl("../AlbumPage.qml"),
{
"albumId" :item.id
})
console.log(item.albumid)
break
case 3: // Artist
pageStack.push(Qt.resolvedUrl("../ArtistPage.qml"))
Expand Down
17 changes: 3 additions & 14 deletions qml/pages/widgets/MiniPlayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ DockedPanel {
open: true
dock: Dock.Bottom


property string url: ""
property int track_id

function play() {
mediaController.source = url;
mediaController.play();
progressSlider.visible = true
show();
}

// Hintergrundbild
Image {
id: bgImage
Expand Down Expand Up @@ -241,12 +230,12 @@ DockedPanel {

Connections {
target: tidalApi
onCurrentPlayback:
onCurrentPlayback:
{
mediaTitle.text = trackinfo.track_num + " - " + trackinfo.title + " - " + trackinfo.album + " - " + trackinfo.artist
bgImage.source = trackinfo.image
//prevButton.enabled = playlistManager.canPrev
//nextButton.enabled = playlistManager.canNext
prevButton.enabled = playlistManager.canPrev
nextButton.enabled = playlistManager.canNext
progressSlider.visible = true
//mprisPlayer.updateTrack(title, artist, album)
}
Expand Down
6 changes: 3 additions & 3 deletions qml/tidal.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def playPlaylist(self, id):
pyotherside.send('loadingStarted')
playlist = self.session.playlist(id)
first_track = playlist.tracks()[0]
pyotherside.send("insertTrack", first_track.id)
#pyotherside.send("insertTrack", first_track.id)
pyotherside.send("printConsole", f" insert Track: {first_track.id}")

for i, track in enumerate(playlist.tracks()):
Expand All @@ -345,8 +345,8 @@ def playPlaylist(self, id):
pyotherside.send("cacheTrack", track_info)
pyotherside.send("addTracktoPL", track_info['id'])

if i == 0:
pyotherside.send("fillStarted")
#if i == 0:
# pyotherside.send("fillStarted")

pyotherside.send("fillFinished")
pyotherside.send('loadingFinished')
Expand Down

0 comments on commit 9b1922e

Please sign in to comment.