From 7f0d724bad4943a8923ba999dbd432158b2d1672 Mon Sep 17 00:00:00 2001
From: nesnomis <nesnomis@gmail.com>
Date: Mon, 2 Jun 2025 18:52:15 +0200
Subject: [PATCH] Tweaking and fixing

---
 qml/items/RadioMprisPlayer.qml | 14 +++++++++++++-
 qml/items/RadioPlayer.qml      | 13 ++++++++-----
 qml/pages/RadioPlayerPage.qml  |  2 +-
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/qml/items/RadioMprisPlayer.qml b/qml/items/RadioMprisPlayer.qml
index 24f894b..268768a 100644
--- a/qml/items/RadioMprisPlayer.qml
+++ b/qml/items/RadioMprisPlayer.qml
@@ -14,8 +14,20 @@ MprisPlayer {
    supportedMimeTypes: ["audio/x-wav", "audio/x-vorbis+ogg", "audio/mpeg", "audio/mp4a-latm", "audio/x-aiff"]
 
    canControl: true
+/*
+   function playNext() {
+       if (playlistIndex < playlistCount && playlistIndex < playlist.count) playlistIndex = playlistIndex + 1
+       loadPlaylistSelected()
+   }
 
-   canGoNext: radioPlayer.playlistIndex < radioPlayer.playlist.count //true //appstate.playlistIndex < appstate.playlist.count
+   function playPrev() {
+       if (playlistIndex <= playlistCount && playlistIndex > 0) playlistIndex = playlistIndex - 1 //: playlistIndex = 0
+       loadPlaylistSelected()
+   }
+   */
+
+
+   canGoNext: radioPlayer.playlistIndex < radioPlayer.playlist.count -1 //true //appstate.playlistIndex < appstate.playlist.count
    canGoPrevious: radioPlayer.playlistIndex > 0 // appstate.playlistIndex > 0
    canPause: radioPlayer.isPlaying ? true : false
    canPlay: radioPlayer.isPaused ? true : false
diff --git a/qml/items/RadioPlayer.qml b/qml/items/RadioPlayer.qml
index 0dc0e2f..1a2fe07 100644
--- a/qml/items/RadioPlayer.qml
+++ b/qml/items/RadioPlayer.qml
@@ -46,7 +46,10 @@ MediaPlayer {
     property int maxTagClicks: 0
     property int playlistCount: playlist.count - 1
     property int playlistIndex: allradioSettings.value("currentFavorite",-1)
-    property QDtimer timer: QDtimer {id: qdTimer}
+    property QDtimer timer: QDtimer {
+        id: qdTimer
+        interval: 200; running: false; repeat: false
+    }
     //property string videoOut: ""
 //    property ListModel mostPlayedFavorites: ListModel {id: mostPlayedFavorites}
    //videoOutput: videoOut
@@ -145,12 +148,12 @@ MediaPlayer {
 
 
     function playNext() {
-        playlistIndex < playlistCount && playlistIndex > -1 ? playlistIndex = playlistIndex + 1 : playlistIndex = 0
+        if (playlistIndex < playlistCount && playlistIndex < playlist.count) playlistIndex = playlistIndex + 1
         loadPlaylistSelected()
     }
 
     function playPrev() {
-        playlistIndex < playlistCount && playlistIndex > 0 ? playlistIndex = playlistIndex - 1 : playlistIndex = 0
+        if (playlistIndex <= playlistCount && playlistIndex > -1) playlistIndex = playlistIndex - 1 //: playlistIndex = 0
         loadPlaylistSelected()
     }
 
@@ -277,7 +280,7 @@ MediaPlayer {
         notification.body = "End of media"
         notification.publish()
         //console.log("Status: End Of Media")
-        radioPlayer.stopStream()
+        radioPlayer.resumeStream()
       //  }
     }
     function status8 () { // InvalidMedia
@@ -335,7 +338,7 @@ MediaPlayer {
 
     function reloadDbData() {
         Favorites.getStationRecentClicked(playHistory,15)
-        Favorites.getFavorites(playlist,"name",10000)
+        Favorites.getFavorites(playlist,"myclickcount",10000)
         //Favorites.getStationMostClickedFav(radioPlayermostPlayed,settings._nrOfFavoritePreview)
         //Favorites.getCountryRecentClicked(playedCountries,2)
         //Favorites.getTagsRecentClicked(playedTags,10)
diff --git a/qml/pages/RadioPlayerPage.qml b/qml/pages/RadioPlayerPage.qml
index 4e743c4..b9f48fc 100644
--- a/qml/pages/RadioPlayerPage.qml
+++ b/qml/pages/RadioPlayerPage.qml
@@ -228,7 +228,7 @@ Page {
                 }
                 Image {
                     id: playDLNA
-                    enabled: radioPlayer.playlistIndex < radioPlayer.playlist.count
+                    enabled: radioPlayer.playlistIndex < radioPlayer.playlist.count -1
                     opacity: enabled ? 1.0 : 0.4
                     source: "image://theme/icon-m-next"
                     height: play.height