Skip to content

Commit

Permalink
general playlist might work better now
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 5c0c47a commit 1b88ee3
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 76 deletions.
6 changes: 3 additions & 3 deletions qml/components/MediaController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Item {

// signals
signal currentTrackChanged()
signal currentPosition(double position)

property string current_track_title : ""
property string current_track_artist : ""
Expand Down Expand Up @@ -76,7 +77,6 @@ Item {
property bool videoPlaying: false
property string errorMsg: ""

signal currentPosition(int position)

onError: {
if (error === MediaPlayer.ResourceError) errorMsg = qsTr("Error: Problem with allocating resources")
Expand All @@ -101,7 +101,7 @@ Item {
}

onPositionChanged: {
mediaPlayer.currentPosition(mediaPlayer.position/mediaPlayer.duration*100)
root.currentPosition(mediaPlayer.position/mediaPlayer.duration*100)
}

onPlaying: {
Expand Down Expand Up @@ -169,7 +169,7 @@ Item {
}

function playUrl(url) {
console.log("only this function is allowed to start playback")
console.log("only this function is allowed to start playback", url)
mediaPlayer.source = url
mediaPlayer.play()
}
Expand Down
15 changes: 8 additions & 7 deletions qml/components/PlaylistManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Item {

//property var currentPlaylist: []
property int currentIndex: -1
property bool canNext: false //currentPlaylist.length > 0 && currentIndex < currentPlaylist.length - 1
property bool canPrev: false //currentIndex > 0
property bool canNext: size > 0 && currentIndex < size - 1
property bool canPrev: currentIndex > 0
property int size: 0 //currentPlaylist.length
property int current_track: -1
property int tidalId : 0
Expand All @@ -21,7 +21,6 @@ Item {
signal clearList()
signal currentTrack(int position)


signal listFinished()
signal listChanged()

Expand Down Expand Up @@ -107,6 +106,7 @@ Item {
call("playlistmanager.PL.PlaylistIndex", [], function(index){
current_track = index
})

}

function getSize() {
Expand Down Expand Up @@ -137,7 +137,7 @@ Item {
}

function nextTrack() {
call('playlistmanager.PL.NextTrack', {})
call_sync('playlistmanager.PL.NextTrack', {})
}

function previousTrack() {
Expand Down Expand Up @@ -230,12 +230,13 @@ Item {
}

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

function nextTrackClicked() {
Expand Down
200 changes: 150 additions & 50 deletions qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,202 @@ import QtQuick 2.0
import Sailfish.Silica 1.0

CoverBackground {
id: cover

property bool isPlaying: coverImage.source != ""
property var application
property var home
Image {
id: defaultLogo
visible: !isPlaying
source: "/usr/share/icons/hicolor/86x86/apps/harbour-tidalplayer.png"
anchors.centerIn: parent
width: parent.width * 0.5
height: width
opacity: 0.6
}

Image {
id: backgroundImage
anchors.fill: parent
source: coverImage.source
fillMode: Image.PreserveAspectCrop
opacity: 0.1
asynchronous: true
}

Rectangle {
id: gradient
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "transparent" }
GradientStop { position: 1.0; color: Theme.rgba(Theme.primaryColor, 0.1) }
}
}

Image {
id: coverImage
width: 0.66 * parent.height
//anchors.centerIn: parent.top
width: parent.width - 2 * Theme.paddingMedium
height: width
anchors {
top: parent.top
topMargin: Theme.paddingLarge
horizontalCenter: parent.horizontalCenter
}
fillMode: Image.PreserveAspectFit
anchors.margins: Theme.paddingSmall
asynchronous: true
visible: source != ""

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

Column {
anchors.top: coverImage.bottom
Label {
id: titleLabel
//anchors.bottom: parent
text: qsTr("Tidal Player")
color: Theme.highlightColor
anchors.margins: Theme.paddingSmall
anchors.top: coverImage.bottom
}
Label {
id: artist_albumLabel
//anchors.bottom: parent
color: Theme.highlightColor
anchors.margins: Theme.paddingSmall
anchors.top: titleLabel.bottom
anchors {
top: coverImage.source ? coverImage.bottom : parent.verticalCenter
topMargin: Theme.paddingMedium
left: parent.left
right: parent.right
leftMargin: Theme.paddingMedium
rightMargin: Theme.paddingMedium
}
spacing: Theme.paddingSmall

Label {
id: titleLabel
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.fontSizeMedium
color: Theme.primaryColor
truncationMode: TruncationMode.Fade
maximumLineCount: 2
wrapMode: Text.Wrap
text: qsTr("Tidal Player")
}

Label {
id: artist_albumLabel
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.fontSizeSmall
color: Theme.secondaryColor
truncationMode: TruncationMode.Fade
maximumLineCount: 2
wrapMode: Text.Wrap
text: qsTr("No track playing")
}
}

Row {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: Theme.paddingLarge
}
spacing: Theme.paddingMedium
visible: !isPlaying

Label {
text: qsTr("Tap to navigate")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
}
}

CoverActionList {
id: coverAction
id: playbackActions
enabled: isPlaying

CoverAction {
id: prevButton
iconSource: "image://theme/icon-m-simple-previous"
iconSource: "image://theme/icon-cover-previous"
onTriggered: {
mediaController.blockAutoNext = true
playlistManager.previousTrack()
}
}

CoverAction {
iconSource: "image://theme/icon-m-simple-play"
id: playpause
onTriggered:
{
if (mediaController.playbackState === 1)
{
iconSource: "image://theme/icon-cover-play"
onTriggered: {
if (mediaController.playbackState === 1) {
mediaController.pause()
}
else if(mediaController.playbackState === 2){
} else if(mediaController.playbackState === 2) {
mediaController.play()
}
}
}

CoverAction {
id: nextButton
iconSource: "image://theme/icon-m-simple-next"
iconSource: "image://theme/icon-cover-next"
onTriggered: {
mediaController.blockAutoNext = true
playlistManager.nextTrackClicked()
}
}
}

CoverActionList {
id: navigationActions
enabled: !isPlaying


CoverAction {
iconSource: "image://theme/icon-m-home" // Icon für Playlists
onTriggered: {
application.activate()
home.currentIndex = 0 // Playlists Tab
}
}

CoverAction {
iconSource: "image://theme/icon-cover-search"
iconSource: "image://theme/icon-m-search"
onTriggered: {
application.activate()
home.currentIndex = 1 // Search Tab
}
}
CoverAction {
iconSource: "image://theme/icon-m-media-playlists" // Icon für Current
onTriggered: {
application.activate()
home.currentIndex = 2 // Current Tab
}
}
}

Connections
{
Connections {
target: tidalApi
onCurrentPlayback:
{
titleLabel.text = trackinfo.track_num + " - " + trackinfo.title
artist_albumLabel.text = trackinfo.album + " - " + trackinfo.artist
onCurrentPlayback: {
titleLabel.text = trackinfo.title
artist_albumLabel.text = trackinfo.artist + "\n" + trackinfo.album
coverImage.source = trackinfo.image
}
}
Connections
{

Connections {
target: playlistManager
onPlayListFinished:
{
titleLabel.text = ""
artist_albumLabel.text = ""
onPlayListFinished: {
titleLabel.text = qsTr("Tidal Player")
artist_albumLabel.text = qsTr("No track playing")
coverImage.source = ""
prevButton.enabled = playlistManager.canPrev;
nextButton.enabled = playlistManager.canNext;
prevButton.enabled = playlistManager.canPrev
nextButton.enabled = playlistManager.canNext
}
}
Connections
{

Connections {
target: mediaController
onPlaybackStateChanged:
{
onPlaybackStateChanged: {
if(mediaController.playbackState === 1)
playpause.iconSource = "image://theme/icon-m-simple-pause"
else if(mediaController.playbackState === 2)
playpause.iconSource = "image://theme/icon-m-simple-play"
playpause.iconSource = "image://theme/icon-cover-pause"
else if(mediaController.playbackState === 2)
playpause.iconSource = "image://theme/icon-cover-play"
}
}
}
15 changes: 12 additions & 3 deletions qml/harbour-tidalplayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.nemomobile.mpris 1.0
import Nemo.Configuration 1.0

import "components"

import "cover"
import "pages"
import "pages/widgets"


ApplicationWindow
{
id: applicationWindow
//property alias firstPage: firstpage // Property für FirstPage
property bool loginTrue : false
property var locale: Qt.locale()
property date currentDate: new Date()
Expand Down Expand Up @@ -70,8 +72,15 @@ ApplicationWindow
id: mediaController
}

initialPage: Component { FirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
initialPage: Component {
FirstPage {
id: firstpage // Diese ID wird nun über applicationWindow.firstPage verfügbar
}
}
cover: CoverPage {
application: applicationWindow
home : firstpage
}
allowedOrientations: defaultAllowedOrientations


Expand Down
4 changes: 2 additions & 2 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import "widgets"
import "stuff"

Page {
id: searchPage
id: firstPage

// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations: Orientation.All

property int currentIndex : 0
// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
clip: true
Expand Down
Loading

0 comments on commit 1b88ee3

Please sign in to comment.