From 54b997ad6114e29b4dbb5a78f3e7f1496a2efba6 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 7 Jun 2025 17:19:19 +0200 Subject: [PATCH] Cleainging up, bug hunting and optimizing --- qml/harbour-allradio.qml | 38 ++-- qml/helpers/db.js | 5 +- qml/items/RadioBrowser.qml | 76 +++---- qml/items/RadioMprisPlayer.qml | 21 +- qml/items/RadioPlayer.qml | 301 +++++++++++----------------- qml/models/AdvancedSearchModel.qml | 7 +- qml/models/CountryListModel.qml | 9 +- qml/models/CountryNameModel.qml | 3 +- qml/models/GetCountryStations.qml | 13 +- qml/pages/AboutPage.qml | 49 ----- qml/pages/AllRadio.qml | 92 ++++----- qml/pages/CountryListPage.qml | 5 +- qml/pages/CountryStationsPage.qml | 37 ++-- qml/pages/RadioPlayerPage.qml | 7 +- translations/harbour-allradio-de.ts | 43 ++++ translations/harbour-allradio.ts | 63 +++++- 16 files changed, 329 insertions(+), 440 deletions(-) diff --git a/qml/harbour-allradio.qml b/qml/harbour-allradio.qml index e7086e8..513032a 100644 --- a/qml/harbour-allradio.qml +++ b/qml/harbour-allradio.qml @@ -1,16 +1,10 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 -//import Nemo.Configuration 1.0 ///////// -import Nemo.Notifications 1.0 /////////// +import Nemo.Notifications 1.0 import Amber.Mpris 1.0 import "pages" import "items" -//import "radio-player" -//import "video-player" import "helpers" -//import "jupii" - -// Check out Amber Mpris Qml !!! ApplicationWindow { @@ -18,52 +12,50 @@ ApplicationWindow property string _version: "2.0.16" property string _language: Qt.locale().name.slice(0,2) property string _country: Qt.locale().name.slice(-2) - //property int currentListIndex: -1 - //property int currentListCount: -1 property int sleepTime: 0 - //property alias settings: allradioSettings property alias mediaPlayerPanel: mediaPlayerPanel + property alias radioPlayer: radioPlayer + property alias radioBrowser: radioBrowser + property alias sleepTimer: sleepTimer +/* property RadioPlayer radioPlayer : RadioPlayer {id:radioPlayer} property RadioBrowser radioBrowser : RadioBrowser {id:radioBrowser;parent: allRadio} property SleepTimer sleepTimer : SleepTimer {id:sleepTimer} - +*/ + SleepTimer {id: sleepTimer} + RadioBrowser {id: radioBrowser; parent: allRadio} + RadioPlayer {id: radioPlayer} RadioMprisPlayer {id: radioMprisPlayer} MediaPlayerPanel {id: mediaPlayerPanel} - //ConfigurationGroup {id:settingsGroup;path: "/apps/harbour-allradio";ConfigurationGroup {id: allradioSettings;path: "/settings"}} Notification {id: notification;onClicked: console.log("Clicked")} - //MprisPlayer {} + // Not finished. --latest and --random should work though function handleArguments() { for(var i = 1; i < Qt.application.arguments.length; i++) { switch (Qt.application.arguments[i]) { case "--help": help();break; // no argument - //case "--codec": console.info("*** CODEC *** "+Qt.application.arguments[i+1]);break; // argument can be: mp3, aac, aac+, hls - //case "--favorite": console.info("*** FAVORITE *** "+Qt.application.arguments[i+1]);break; // argument can be: top, latest, random - //case "--pause": console.info("*** HISTORY *** "+Qt.application.arguments[i+1]);break; // argument can be: top, latest, random case "--sleep": console.info("*** SLEEP *** : "+Qt.application.arguments[i+1]);break; // play for 1-120 minutes (sleeptimer) case "--latest": console.info("*** PLAY *** : "+Qt.application.arguments[i+1]);latest();break; // latest, saved, random, world case "--random": console.info("*** PLAY *** : "+Qt.application.arguments[i+1]);random();break; // latest, saved, random, world } } } - + // Help text to be displayed in the console function help(){ console.info("help") - } - - + // Play latest from console 'harbour-allradio --latest' function latest(){ radioPlayer.loadRecentPlay() radioPlayer.playStream() - } + // Play random from console (stations added to favorites needed) 'harbour-allradio --random' function random(){ radioPlayer.loadRandomPlay() radioPlayer.playStream() - } - initialPage: Component { AllRadio { } } + + initialPage: Component { AllRadio { } } cover: Qt.resolvedUrl("cover/CoverPage.qml") allowedOrientations: defaultAllowedOrientations Component.onCompleted: {mediaPlayerPanel.parent.z = 99;handleArguments()} diff --git a/qml/helpers/db.js b/qml/helpers/db.js index d2a3f98..19520ac 100644 --- a/qml/helpers/db.js +++ b/qml/helpers/db.js @@ -24,7 +24,7 @@ function checkforold() { function init() { db = settings_db_open(); - checkforold() + //checkforold() try { db.transaction( function(tx) { @@ -227,10 +227,7 @@ function getStationFavorite(id) { // Get info about number of clicks and if stat db.transaction(function(tx) { var rs = tx.executeSql('SELECT * FROM stations WHERE id = "'+id+'" AND favorite = 1'); res = rs.rows.length - // console.log("FAVO RESULT: "+res+" ID: "+id ) if (res>0) return true; else return false; - - }) } catch (err) { res = 0 diff --git a/qml/items/RadioBrowser.qml b/qml/items/RadioBrowser.qml index 52d0a02..1f55e4c 100644 --- a/qml/items/RadioBrowser.qml +++ b/qml/items/RadioBrowser.qml @@ -34,129 +34,109 @@ Item { //property int viewTagCount: tagsModel.maxCount property int countryCount: 0 property bool loading: stationCount !== 0 && tagCount !== 0 && countryCount !== 0 ? false : true - property string lookup: "http://all.api.radio-browser.info/json/servers" //"http://all.api.radio-browser.info/json/servers" + property string lookup: "http://all.api.radio-browser.info/json/servers" // --------------------------------------------------------------------------------------- onOnlineChanged: { - //console.log("onOnlineChanged") if (online && serverUrl !== "") { countriesModel.source = serverUrl + "/xml/countrycodes?hidebroken=true" - //tagsModel.source = serverUrl + "/xml/tags?hidebroken=true" } } - function getServer(s,u) { - //console.log("getServer") + // Not used?!?!? + /* function getServer(s,u) { stationCount = 0 tagCount = 0 countryCount = 0 server = s serverUrl = u getStats() - } + } */ + // Choose a random server from available servers function getRandom() { - //console.log("getRandom") if (serversModel.count > 0) { var random = Math.floor((Math.random() * serversModel.count) + 1) - 1 serverUrl = serversModel.get(random).serverUrl server = serversModel.get(random).server - //console.log("getRandom: "+server) getStats() - - } //else getList() + } } + // Get a list of available Radio Community Servers. function getList() { - //console.log("getList") var req = new XMLHttpRequest(); - req.open("get", lookup,true); - req.setRequestHeader('User-Agent',_useragent); - req.timeout = 4000; // Set timeout to 4 seconds (4000 milliseconds) - req.ontimeout = function () { console.log("Timed out!!!"); } - //console.log("server 2") req.onreadystatechange = function () { - //console.log(console.log("getList: "+req.status)) - if (req.readyState === 4 && req.status === 200) { + if (req.readyState === 4 && req.status < 300) { var obj = JSON.parse(req.responseText) serversModel.clear() for (var key in obj) { addIfNotExist(obj[key]) } getRandom() - } else if (req.readyState === 4 && req.status === 502) {lookup="http://de2.api.radio-browser.info/json/servers";getList();} + } else if (req.readyState === 4 && req.status > 299) {lookup="http://de2.api.radio-browser.info/json/servers";getList();} }; - + req.open("get", lookup); + req.setRequestHeader('User-Agent',_useragent); req.send(); } - + // Add available server to listmodel function addIfNotExist(server) { for (var i = 0; i < serversModel.count; i++) { - if (serversModel.get(i).server === server.name) { return } } serversModel.append({"serverUrl": "http://"+server.name,"server": server.name}) } - + // ---------------------------------------------- + // Station online? function getStats() { - //console.log("getStats") - var req = new XMLHttpRequest(); - req.open("get", serverUrl+"/json/stats",true); - req.setRequestHeader('User-Agent',_useragent); req.onreadystatechange = function () { - //console.log("XMLHTTPREQUEST READYSTATE: "+req.readyState + " STATUS: "+req.status) - if (req.readyState === 4 && req.status === 200) { - //console.log("STATUS:"+req.status) + if (req.readyState === 4 && req.status < 300) { var obj = req.response.split("{").pop(); obj = JSON.parse("{"+obj) - if (obj.status === "OK") { stationCount = obj.stations-obj.stations_broken tagCount = obj.tags if (obj.status === "OK") {online = true} else {online = false} } - } else if (req.readyState === 4 && req.status === 502) getRandom() + } else if (req.readyState === 4 && req.status > 299) getRandom() }; + req.open("get", serverUrl+"/json/stats"); + req.setRequestHeader('User-Agent',_useragent); req.send(); } - + // ---------------------------------------------- + // Vote/like for radio station on community radio browser. function upVote(stationuuid,returnValue) { var req = new XMLHttpRequest(); var ret = false - req.open("get", serverUrl+"/json/vote/"+stationuuid,true); - req.setRequestHeader('User-Agent',_useragent); req.onreadystatechange = function () { - //console.log("XMLHTTPREQUEST READYSTATE: "+req.readyState + " STATUS: "+req.status) if (req.readyState === 4 && req.status === 200) { var obj = req.response.split("{").pop(); obj = JSON.parse("{"+obj) - //console.log(obj.ok) if (obj.ok) { - //stationCount = obj.stations-obj.stations_broken - //tagCount = obj.tags if (obj.ok) {returnValue=true;console.log(" ****** VOTED *****")} else {returnValue=false;console.log(" ****** NOT VOTED *****")} } return ret - } }; + req.open("get", serverUrl+"/json/vote/"+stationuuid); + req.setRequestHeader('User-Agent',_useragent); req.send(); - } - - + // ---------------------------------------------- + // Load model with country names. CountryNameModel {id: countryNameModel} function getCountryName(land) { // Get translated countryname for(var i = 0; i < countryNameModel.count; i++) { - var current = countryNameModel.get(i); - if(land === current.code) { - return countryNameModel.countryname(i) - } + var current = countryNameModel.get(i); + if(land === current.code) { + return countryNameModel.countryname(i) + } } } - } diff --git a/qml/items/RadioMprisPlayer.qml b/qml/items/RadioMprisPlayer.qml index b9407b6..460b64c 100644 --- a/qml/items/RadioMprisPlayer.qml +++ b/qml/items/RadioMprisPlayer.qml @@ -14,29 +14,12 @@ 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() - } - - function playPrev() { - if (playlistIndex <= playlistCount && playlistIndex > 0) playlistIndex = playlistIndex - 1 //: playlistIndex = 0 - loadPlaylistSelected() - } - */ - - canGoNext: radioPlayer.playlistIndex < radioPlayer.playlist.count -1 && radioPlayer._favorite -//true //appstate.playlistIndex < appstate.playlist.count - canGoPrevious: radioPlayer.playlistIndex > 0 && radioPlayer._favorite// appstate.playlistIndex > 0 + canGoPrevious: radioPlayer.playlistIndex > 0 && radioPlayer._favorite canPause: radioPlayer.isPlaying ? true : false canPlay: radioPlayer.isPaused ? true : false - - canSeek: false// playback.seekable + canSeek: false hasTrackList: false - - loopStatus: Mpris.LoopNone shuffle: false volume: 1 diff --git a/qml/items/RadioPlayer.qml b/qml/items/RadioPlayer.qml index f5f6770..61dfcb3 100644 --- a/qml/items/RadioPlayer.qml +++ b/qml/items/RadioPlayer.qml @@ -19,14 +19,11 @@ MediaPlayer { property string _url_resolved: "" property string _homepage: "" // property string _votes: "" - // property string _plays: "" + // property string _plays: "" // For future implementation?! // property string _trend: "" property bool _favorite: false //-------------------------------- - // property bool videoP: false - property bool playerPageOpen: false -// property bool jupiiOn: false property string radioId: "" property string metaInfo: metaData.title ? metaData.title : "" property string radioArtist: "" @@ -42,37 +39,23 @@ MediaPlayer { property string radioStatusString property bool isPlaying: false property bool isPaused: false - property int stationOk: 3 + property int stationOk: 0 property int maxTagClicks: 0 property int playlistCount: playlist.count -1 property int playlistIndex: Favorites.getSetting("playlistIndex",-1) - //property int playlistIndex: playlistCount = Favorites.getSetting("playlistIndex",-1) + property ListModel playHistory: ListModel {id: playHistory} + property ListModel playlist: ListModel {id: playlist} property QDtimer timer: QDtimer { id: qdTimer interval: 200; running: false; repeat: false } - //property string videoOut: "" -// property ListModel mostPlayedFavorites: ListModel {id: mostPlayedFavorites} - //videoOutput: videoOut -// property variant magnitudeArray: null -// property int millisecondsPerBar: 68 - - property ListModel playHistory: ListModel {id: playHistory} - property ListModel playlist: ListModel {id: playlist} - autoPlay: false autoLoad: true - //onPlaylistIndexChanged: console.log("INDEX: "+playlistIndex) - - //on_FavoriteChanged: {setStationFavorite(_stationuuid,_name,_countrycode,_homepage,_url_resolved,_favicon,_tags,_codec,_bitrate,_hls,_favorite);Favorites.getMostPlayedFavorites(mostPlayedFavorites,15)} onPlaying: if (!playerPageOpen) pageStack.push("../pages/RadioPlayerPage.qml") - // onPlaylistIndexChanged: loadPlaylistSelected() - onMetaInfoChanged: { - // console.log(" ******* METAINFO: "+metaInfo) if (metaInfo.search(" - ") > -1) { var res = metaInfo.split(" - ") radioArtist = res[0] @@ -83,12 +66,7 @@ MediaPlayer { } } - onRadioAudioChanged: { - // if (hasVideo) console.log(" *** VIDEO"); else console.log(" *** AUDIO") - } - onStationOkChanged: { - // console.log("StationOK?: "+stationOk) if (stationOk === 1) { setStationClick() getStationFavorite(_stationuuid) @@ -99,34 +77,102 @@ MediaPlayer { } } - on_StationuuidChanged: { //if (_stationuuid !== "") {getStationUrl(_stationuuid);radioPlayUrl = _url_resolved} else radioPlayUrl = "" + on_StationuuidChanged: { radioCountryName = radioBrowser.getCountryName(_countrycode) stop() source = "" - //metaInfo = "" radioVideo = false radioAudio = false isPaused = false isPlaying = false - stationOk = 3 + stationOk = 0 getStationUrl(_stationuuid); } - //onIsPausedChanged: if (_paused) { - //radioPlaying = false - ///radioPaused = true - // radioSource = "" - // metaInfo = "" - // if(radioVideo) { - // videoPlayer.visible = false - // radioSource = "" - // } - // } - onHasVideoChanged: if (hasVideo) radioVideo = true onHasAudioChanged: if (hasAudio) radioAudio = true + onError: { + notification.category = "Error" + notification.summary = _name + notification.body = errorString + notification.publish() + radioPlayer.stopStream() + } + onStatusChanged: { + switch (status) { + case 1: status1();break; // NoMedia + case 2: status2();break; // Loading + case 3: status3();break; // Loaded + case 4: status4();break; // Buffering + case 5: status5();break; // Stalled + case 6: status6();break; // Buffered + case 7: status7();break; // EndOfMedia + case 8: status8();break; // InvalidMedia + case 9: status9();break; // UnknownStatus + } + } + + function status1 () { // NoMedia + radioStatus = status + radioStatusString = "No Media" + } + + function status2 () { // Loading + radioStatus = status + radioStatusString = "Loading" + } + + function status3 () { // Loaded + radioStatus = status + radioStatusString = "Loaded" + } + + function status4 () { // Buffering + radioStatus = status + radioStatusString = "Buffering" + } + + function status5 () { // Stalled + radioStatus = status + radioStatusString = "Stalled" + notification.category = "Status" + notification.summary = _name + notification.body = "Stalled" + notification.publish() + radioPlayer.stopStream() + } + + function status6 () { // Buffered + radioStatus = status + radioStatusString = "Buffered" + } + + function status7 () { // EndOfMedia + radioStatus = status + radioStatusString = "End Of Media" + notification.category = "Status" + notification.summary = _name + notification.body = "End of media" + notification.publish() + radioPlayer.resumeStream() + } + + function status8 () { // InvalidMedia + radioStatus = status + radioStatusString = "Invalid Media" + notification.category = "Status" + notification.summary = _name + notification.body = "Invalid media" + notification.publish() + radioPlayer.stopStream() + } + + function status9 () { // UnknownStatus + radioStatus = status + radioStatusString = "Unknown Status" + } function stopStream() { // stop and clear stream source = "" @@ -147,50 +193,36 @@ MediaPlayer { _hls = "" _homepage = "" stop() - // metaInfo = "" } - - - - function playNext() { if (playlistIndex < playlistCount) playlistIndex = playlistIndex + 1 loadPlaylistSelected() } function playPrev() { - if (playlistIndex <= playlistCount) playlistIndex = playlistIndex - 1 //: playlistIndex = 0 + if (playlistIndex <= playlistCount) playlistIndex = playlistIndex - 1 loadPlaylistSelected() } - function videoPause() { source = "" stop() } - - function pauseStream() { // stop stream without clear - - - isPaused = true + function pauseStream() { isPlaying = false source = "" stop() - // metaInfo = "" } function resumeStream() { isPlaying = true isPaused = false playStream() - } - - - function playStream() { // resume paused stream + function playStream() { source = _url_resolved play() isPlaying = true @@ -199,142 +231,20 @@ MediaPlayer { if (_favorite) Favorites.setSetting("playlistIndex",playlistIndex) } - onError: { - notification.category = "Error" - notification.summary = _name - //notification.subText = _name - notification.body = errorString - notification.publish() - radioPlayer.stopStream() - - } - - /* onRadioStatusChanged: { - notification.body = radioStatusString - notification.publish() - }*/ - - - - - onStatusChanged: { - //console.log(" ___ STATUS: "+status) - switch (status) { - case 1: status1();break; // NoMedia - case 2: status2();break; // Loading - case 3: status3();break; // Loaded - case 4: status4();break; // Buffering - case 5: status5();break; // Stalled - case 6: status6();break; // Buffered - case 7: status7();break; // EndOfMedia - case 8: status8();break; // InvalidMedia - case 9: status9();break; // UnknownStatus - } - } function tryagain() { tryTimer.running = true } - function status1 () { // NoMedia - radioStatus = status - radioStatusString = "No Media" - //console.log("Status: No Media") - } - function status2 () { // Loading - radioStatus = status - radioStatusString = "Loading" - //console.log("Status: Loading") - } - function status3 () { // Loaded - radioStatus = status - radioStatusString = "Loaded" - //console.log("Status: Loaded") - } - function status4 () { // Buffering - radioStatus = status - radioStatusString = "Buffering" - //console.log("Status: Buffering") - } - function status5 () { // Stalled - radioStatus = status - radioStatusString = "Stalled" - notification.category = "Status" - notification.summary = _name - //notification.subText = _name - notification.body = "Stalled" - notification.publish() - //console.log("Status: Stalled") - radioPlayer.stopStream() - } - function status6 () { // Buffered - radioStatus = status - radioStatusString = "Buffered" - //console.log("Status: Buffered") - } - function status7 () { // EndOfMedia - /* if (errorCount<4) { - //errorCount = errorCount + 1 - tryTimer.start() - }else{ */ - radioStatus = status - radioStatusString = "End Of Media" - notification.category = "Status" - notification.summary = _name - //notification.subText = _name - notification.body = "End of media" - notification.publish() - //console.log("Status: End Of Media") - radioPlayer.resumeStream() - // } - } - function status8 () { // InvalidMedia - radioStatus = status - radioStatusString = "Invalid Media" - notification.category = "Status" - notification.summary = _name - //notification.subText = _name - notification.body = "Invalid media" - notification.publish() - //console.log("Status: Invalid Media") - radioPlayer.stopStream() - } - function status9 () { // UnknownStatus - radioStatus = status - radioStatusString = "Unknown Status" - //console.log("Status: Unknown Status") - } - function getStationUrl(id) { // Register as radio station click on community radio and get station info from Community Radio and save it to Db. Initiate playback. - var req = new XMLHttpRequest(); - req.open("post", radioBrowser.serverUrl + "/xml/url/" +id, true); - // console.log(radioBrowser.serverUrl) - req.responseType = "document"; - req.setRequestHeader('User-Agent',radioBrowser._useragent); - req.onreadystatechange = function () { - if (req.readyState === 4 && req.status === 200) { - var temp = req.responseText - var ok = temp.indexOf('status ok="true"') !== -1 - // console.log("OK: "+ok) - if (ok) { - stationOk = 1 - } else { - stationOk = 0 - } - } //else if (req.readyState === 4) {stationOk = 2} - }; - req.send(); - } + + function setStationClick() { - //getStationFavorite(_stationuuid) Favorites.setStationClicked(JsFunctions.getTimeStamp(),_stationuuid,_name,_countrycode,_homepage,_url_resolved,_favicon,_tags,_codec,_bitrate,_hls,_favorite) + } - // property bool favo: isFavorite(stationuuid) ? true : false - - //getIfFavorite(_stationuuid) - //getIfFavorite(_stationuuid) - } // myclicktimestamp,id,name,countrycode,homepage,radiourlresolved,favicon,tagslist,codec,bitrate,hls,favorite function setStationFavorite(stationuuid,name,countrycode,homepage,url_resolved,favicon,tags,codec,bitrate,hls,favorite) { Favorites.setStationFavorite(stationuuid,name,countrycode,homepage,url_resolved,favicon,tags,codec,bitrate,hls,favorite) } + function getStationFavorite(id){ _favorite = Favorites.getStationFavorite(id) } @@ -342,12 +252,12 @@ MediaPlayer { function reloadDbData() { Favorites.getStationRecentClicked(playHistory,15) Favorites.getFavorites(playlist,"myclickcount",10000) - //Favorites.getStationMostClickedFav(radioPlayermostPlayed,settings._nrOfFavoritePreview) //Favorites.getCountryRecentClicked(playedCountries,2) //Favorites.getTagsRecentClicked(playedTags,10) //Favorites.getMostPlayedFavorites(mostPlayedFavorites,15) } + function loadPlaylistSelected(){ if (playlist.get(playlistIndex).url_resolved) { _favicon = playlist.get(playlistIndex).favicon @@ -368,6 +278,7 @@ MediaPlayer { // pageStack.push("RadioPlayerPage.qml") } } + function loadRecentPlay(){ if (playHistory.get(0).url_resolved) { _favicon = playHistory.get(0).favicon @@ -388,6 +299,7 @@ MediaPlayer { // pageStack.push("RadioPlayerPage.qml") } } + function loadRandomPlay(){ var rnd = Math.floor(Math.random() * playlist.count) if (playlist.get(rnd).url_resolved) { @@ -431,9 +343,24 @@ MediaPlayer { mprisPlayer.playbackStatus = Mpris.Paused } } - - - + // Register as radio station click on community radio and get station info from Community Radio and save it to Db. Initiate playback. + function getStationUrl(id) { + var req = new XMLHttpRequest(); + req.onreadystatechange = function () { + if (req.readyState === 4 && req.status < 300) { + var temp = req.responseText + var ok = temp.indexOf('status ok="true"') !== -1 + if (ok) { + stationOk = 1 + } else { + stationOk = 0 + } + } + }; + req.open("post", radioBrowser.serverUrl + "/xml/url/" +id); + req.setRequestHeader('User-Agent',radioBrowser._useragent); + req.send(); + } Component.onCompleted: {reloadDbData();_favorite ? loadPlaylistSelected() : loadRecentPlay()} } diff --git a/qml/models/AdvancedSearchModel.qml b/qml/models/AdvancedSearchModel.qml index 8d2c783..df92400 100644 --- a/qml/models/AdvancedSearchModel.qml +++ b/qml/models/AdvancedSearchModel.qml @@ -6,10 +6,6 @@ XmlListModel { property bool clear: false property ListModel stationsModel: ListModel {id: stationsModel} - // onFinishedChanged: console.log("*** FINISHED: "+finished+" ***") - - //onClearChanged: if (clear) {stationsModel.clear()} - query: "/result/station" XmlRole { name: "stationuuid"; query: "@stationuuid/string()" } XmlRole { name: "name"; query: "@name/string()" } @@ -52,10 +48,9 @@ XmlListModel { "clicktrend" : get(i).clicktrend, "clickcount" : get(i).clickcount, "lastcheckok" : get(i).lastcheckok - }) + }); } finished = true - // console.log(" ***** APPENDED ******") } } diff --git a/qml/models/CountryListModel.qml b/qml/models/CountryListModel.qml index ebf01db..7c31601 100644 --- a/qml/models/CountryListModel.qml +++ b/qml/models/CountryListModel.qml @@ -13,14 +13,10 @@ Item { var filt for(var i = 0; i < xmlModel.count; i++) { cname = getCountryName(xmlModel.get(i).name) - //if (cname) filt = cname.toLowerCase() if (cname) {filt = cname.toLowerCase(); if (filt.indexOf(filter) !== -1) countryModel.append({"name" : cname, "alpha_2" : xmlModel.get(i).name,"stationcount" : xmlModel.get(i).stationcount})} - //console.log(cname) } countryModel.listModelSort(countryModel, compareElements) - //numberOfCountries = i - countryCount = countryModel.count - // console.log("COUNTRIESMODEL DONE: "+countryModel.count) + radioBrowser.countryCount = countryModel.count running = false } @@ -49,18 +45,15 @@ Item { XmlListModel { id: xmlModel query: "/result/countrycode" - //source: radioServers.serverUrl + type + "/countrycodes?hidebroken=true" XmlRole { name: "name"; query: "@name/string()" } XmlRole { name: "stationcount"; query: "@stationcount/string()" } onStatusChanged: { - //if (status === XmlListModel.Loading) loadingInfo = "Preloading countries" if (status === XmlListModel.Ready) { addtomodel() running = false } - //if (status === XmlListModel.Loading) running = true; } } diff --git a/qml/models/CountryNameModel.qml b/qml/models/CountryNameModel.qml index 6ed5e32..c2bddf3 100644 --- a/qml/models/CountryNameModel.qml +++ b/qml/models/CountryNameModel.qml @@ -510,8 +510,7 @@ ListModel { qsTr("Kosovo"), qsTr("No country") ] - } + } return countryname.text[index] } - } diff --git a/qml/models/GetCountryStations.qml b/qml/models/GetCountryStations.qml index d0c5304..7eaaa1a 100644 --- a/qml/models/GetCountryStations.qml +++ b/qml/models/GetCountryStations.qml @@ -2,22 +2,14 @@ import QtQuick 2.0 import QtQuick.XmlListModel 2.0 Item { - // radio-browser advanced: - ////property int bitrateMin: 0 - ////property int bitrateMax: 1000000 - ////property string state: "" - ////property bool stateExact: false - ////property string language: "" - ////property bool languageExact: false - ////property string tagList: "" // commaseparated string property string name: "" property bool nameExact: false property string countrycode: "" property string tag: "" property bool tagExcact: false property string codec: "" - property string order: "" // name, url, homepage, favicon, tags, country, state, language, votes, codec, bitrate, lastcheckok, lastchecktime, clicktimestamp, clickcount, clicktrend, random - property bool reverse: false//order === name ? false : true // true if name + property string order: "" + property bool reverse: false property int offset: 0 property int limit: 150 property string source: "" @@ -43,7 +35,6 @@ Item { if (order !== "") filterString = filterString + "&order="+order if (order === "name") reverse = false; else reverse = true filterString = filterString + "&reverse="+reverse + "&offset="+offset+"&limit="+limit - // console.log(radioBrowser.serverUrl + "/xml/stations/search?hidebroken=true"+filterString) source = radioBrowser.serverUrl + "/xml/stations/search?hidebroken=true"+filterString } } diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index 9527605..6896cc2 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -35,55 +35,6 @@ Page { horizontalCenter: parent.horizontalCenter } } - /* Rectangle{ - gradient: Gradient { - GradientStop { position: 0.0; color: "#333333" } - GradientStop { position: 1.0; color: "#777777" } - } - anchors { - horizontalCenter: parent.horizontalCenter - } - height: 3 - width: parent.width-64 - } - - Label { - width: 360 - font.pixelSize: Theme.fontSizeMedium - text: "Created by llelectronics" - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignHCenter - } - Repeater{ - anchors.horizontalCenter: parent.horizontalCenter - //model: credits - Label { - anchors.horizontalCenter: parent.horizontalCenter - text: title - font.pixelSize: Theme.fontSizeSmall - } - } - Rectangle{ - gradient: Gradient { - GradientStop { position: 0.0; color: "#333333" } - GradientStop { position: 1.0; color: "#777777" } - } - anchors { - horizontalCenter: parent.horizontalCenter - } - height: 3 - width: parent.width-64 - } - - Button { - id: homepage - anchors.horizontalCenter: parent.horizontalCenter - text: "Sourcecode on Github" - onClicked: { - mainWindow.openNewTab('page-'+salt(), "https://github.com/llelectronics/webcat", false); - } - } */ Label { width: parent.width-70 diff --git a/qml/pages/AllRadio.qml b/qml/pages/AllRadio.qml index 39f0d17..2f8cccc 100644 --- a/qml/pages/AllRadio.qml +++ b/qml/pages/AllRadio.qml @@ -43,30 +43,21 @@ Page { onVisibleChanged: if (visible) reloadDbData() PullDownMenu { - MenuItem { - text: qsTr("About") - onClicked: pageStack.push("AboutPage.qml") + MenuItem { + text: qsTr("About") + onClicked: pageStack.push("AboutPage.qml") + } + MenuItem { + text: qsTr("Settings") + onClicked: pageStack.push("SettingsPage.qml") + } + MenuItem { + text: qsTr("Sleep timer") + onClicked: { + pageStack.push("SleepTimerPage.qml") } - MenuItem { - text: qsTr("Settings") - onClicked: pageStack.push("SettingsPage.qml") - } - MenuItem { - text: qsTr("Sleep timer") - onClicked: { - pageStack.push("SleepTimerPage.qml") - } - - /* var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", { - hour: 0, - minute: 30, - hourMode: DateTime.TwentyFourHours - }) - dialog.accepted.connect(function() { - }) - } */ - } - } + } + } Column { id: mainColumn @@ -96,6 +87,7 @@ Page { smooth: true source: "../images/community.png" } + ColorOverlay { anchors.fill: logo source: logo @@ -178,11 +170,11 @@ Page { height: Theme.itemSizeHuge * 1.35 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight - visible: favorites.count > 0//radioBrowser.getCountryName(_country) || playedCountries.count > 0 ? true : false + visible: favorites.count > 0 model: favorites @@ -191,21 +183,18 @@ Page { onClicked: { if (model.url_resolved !== radioPlayer._url_resolved) { + radioPlayer._countrycode = model.countrycode// THIS IS THE FUNCTION DESTROYING AARCH64?!? radioPlayer._favicon = model.favicon radioPlayer._name = model.name - radioPlayer._countrycode = model.countrycode radioPlayer._tags = model.tags - radioPlayer._codec = model.codec//getCodec(model.codec) - radioPlayer._bitrate = model.bitrate //getBitrate(model.bitrate) + radioPlayer._codec = model.codec + radioPlayer._bitrate = model.bitrate radioPlayer._hls = model.hls radioPlayer._url_resolved = model.url_resolved radioPlayer._homepage = model.homepage radioPlayer._stationuuid = model.stationuuid radioPlayer.getStationFavorite(model.stationuuid) radioPlayer.playlistIndex = index - - //console.log("Index: "+index) - } } } @@ -216,7 +205,7 @@ Page { HeaderButton { visible: radioPlayer.playHistory.count > 0 - headerText: qsTr("Play history")//playedCountries.count > 0 ? "Trending in " + radioBrowser.getCountryName(playedCountries.get(0).alpha_2) : "Trending in " + radioBrowser.getCountryName(_country) + headerText: qsTr("Play history") onClicked: pageStack.push("HistoryPage.qml") } @@ -226,7 +215,7 @@ Page { height: playedTags.count > 0 ? Theme.itemSizeHuge * 1.35 : 0 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight @@ -236,18 +225,21 @@ Page { delegate: SmallStationsDelegate { flagVisible: true onClicked: { + console.log("*** CLICKED") if (model.url_resolved !== radioPlayer._url_resolved) { + console.log("*** URL_RESOLVED") + radioPlayer._countrycode = model.countrycode// THIS IS THE FUNCTION DESTROYING AARCH64?!? radioPlayer._favicon = model.favicon radioPlayer._name = model.name - radioPlayer._countrycode = model.countrycode radioPlayer._tags = model.tags - radioPlayer._codec = model.codec//getCodec(model.codec) - radioPlayer._bitrate = model.bitrate //getBitrate(model.bitrate) + radioPlayer._codec = model.codec + radioPlayer._bitrate = model.bitrate radioPlayer._hls = model.hls radioPlayer._url_resolved = model.url_resolved radioPlayer._homepage = model.homepage radioPlayer._stationuuid = model.stationuuid radioPlayer.getStationFavorite(model.stationuuid) + console.log("*** URL_RESOLVED END") } } } @@ -258,7 +250,7 @@ Page { HeaderButton { visible: radioPlayer.playHistory.count > 0 - headerText: qsTr("My most played Tags")//playedCountries.count > 0 ? "Trending in " + radioBrowser.getCountryName(playedCountries.get(0).alpha_2) : "Trending in " + radioBrowser.getCountryName(_country) + headerText: qsTr("My most played Tags") onClicked: pageStack.push("TagListPage.qml",{}) } @@ -268,7 +260,7 @@ Page { height: playedTags.count > 0 ? Theme.itemSizeHuge * 1.35 : 0 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight @@ -291,7 +283,7 @@ Page { height: Theme.itemSizeHuge * 1.35 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight @@ -302,18 +294,21 @@ Page { delegate: SmallStationsDelegate { flagVisible: false onClicked: { + console.log("*** CLICKED") if (model.url_resolved !== radioPlayer._url_resolved) { + console.log("*** URL_RESOLVED") + radioPlayer._countrycode = model.countrycode// THIS IS THE FUNCTION DESTROYING AARCH64?!? radioPlayer._favicon = model.favicon radioPlayer._name = model.name - radioPlayer._countrycode = model.countrycode radioPlayer._tags = model.tags - radioPlayer._codec = model.codec//getCodec(model.codec) - radioPlayer._bitrate = model.bitrate //getBitrate(model.bitrate) + radioPlayer._codec = model.codec + radioPlayer._bitrate = model.bitrate radioPlayer._hls = model.hls radioPlayer._url_resolved = model.url_resolved radioPlayer._homepage = model.homepage radioPlayer._stationuuid = model.stationuuid radioPlayer.getStationFavorite(model.stationuuid) + console.log("*** URL_RESOLVED END") } } } @@ -323,7 +318,6 @@ Page { HeaderButton { visible: playedCountries.count > 1 -// headerText: playedCountries.count > 0 ? "Trending in " + radioBrowser.getCountryName(playedCountries.get(1).alpha_2) : "Trending in " + radioBrowser.getCountryName(_country) headerText: playedCountries.count > 1 ? qsTr("Trending in")+" " + radioBrowser.getCountryName(playedCountries.get(1).alpha_2) : qsTr("Trending in")+" " + radioBrowser.getCountryName(_country) onClicked: pageStack.push("CountryStationsPage.qml",{searchby:"clicktrend",_countrycode: playedCountries.get(1).alpha_2}) } @@ -333,7 +327,7 @@ Page { height: Theme.itemSizeHuge * 1.35 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight @@ -345,9 +339,9 @@ Page { flagVisible: false onClicked: { if (model.url_resolved !== radioPlayer._url_resolved) { + radioPlayer._countrycode = model.countrycode// THIS IS THE FUNCTION DESTROYING AARCH64?!? radioPlayer._favicon = model.favicon radioPlayer._name = model.name - radioPlayer._countrycode = model.countrycode radioPlayer._tags = model.tags radioPlayer._codec = model.codec//getCodec(model.codec) radioPlayer._bitrate = model.bitrate //getBitrate(model.bitrate) @@ -364,7 +358,7 @@ Page { Item {height: Theme.paddingLarge;width: parent.width} HeaderButton { - headerText: qsTr("Trending in the world")//playedCountries.count > 0 ? "Trending in " + radioBrowser.getCountryName(playedCountries.get(0).alpha_2) : "Trending in " + radioBrowser.getCountryName(_country) + headerText: qsTr("Trending in the world") onClicked: pageStack.push("CountryStationsPage.qml",{searchby:"clicktrend",_countrycode: ""}) } @@ -373,7 +367,7 @@ Page { height: Theme.itemSizeHuge * 1.35 width: page.width cellHeight: height - cellWidth: cellHeight * 0.75//Theme.itemSizeHuge + Theme.itemSizeMedium * 2 + cellWidth: cellHeight * 0.75 flow: GridView.TopToBottom snapMode: SlideshowView.NoSnap layoutDirection: Qt.LeftToRight @@ -382,9 +376,9 @@ Page { flagVisible: true onClicked: { if (model.url_resolved !== radioPlayer._url_resolved) { + radioPlayer._countrycode = model.countrycode// THIS IS THE FUNCTION DESTROYING AARCH64?!? radioPlayer._favicon = model.favicon radioPlayer._name = model.name - radioPlayer._countrycode = model.countrycode radioPlayer._tags = model.tags radioPlayer._codec = model.codec//getCodec(model.codec) radioPlayer._bitrate = model.bitrate //getBitrate(model.bitrate) @@ -404,8 +398,6 @@ Page { Favorites.getTagsRecentClicked(playedTags,15) Favorites.getFavorites(favorites,"myclickcount",15) Favorites.getCountryRecentClicked(playedCountries,4) - - getTrending1.countrycode = playedCountries.count > 0 ? playedCountries.get(0).alpha_2 : _country getTrending1.order = "clicktrend" getTrending1.offset = 0 diff --git a/qml/pages/CountryListPage.qml b/qml/pages/CountryListPage.qml index 110cd6e..438cabc 100644 --- a/qml/pages/CountryListPage.qml +++ b/qml/pages/CountryListPage.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import QtQuick.LocalStorage 2.0 +import "../helpers/db.js" as Favorites import "../delegates" Page { @@ -26,7 +27,7 @@ Page { width: parent.width placeholderText: "Search" text: "" - inputMethodHints: Qt.ImhNoAutoUppercase //| Qt.ImhNoPredictiveText + inputMethodHints: Qt.ImhNoAutoUppercase EnterKey.iconSource: "image://theme/icon-m-enter-close" EnterKey.onClicked: {focus = false} focus: sfocus @@ -42,7 +43,7 @@ Page { onClicked: { sfocus=false; - settings.setValue("lastCountry",alpha_2) + Favorites.setSetting("lastCountry",alpha_2) pageStack.push("CountryStationsPage.qml",{stationCount: stationcount,_countrycode: alpha_2,searchby:"name"}) } } diff --git a/qml/pages/CountryStationsPage.qml b/qml/pages/CountryStationsPage.qml index 6257d3c..d600f9d 100644 --- a/qml/pages/CountryStationsPage.qml +++ b/qml/pages/CountryStationsPage.qml @@ -8,7 +8,7 @@ Page { property string filterby property alias searchby: getCountryStations.order property string searchtext: "" - property string _countrycode: "" + property string countrycode: "" property int stationCount: 0 property alias name: getCountryStations.name property alias tag: getCountryStations.tag @@ -47,8 +47,8 @@ Page { ViewPlaceholder { anchors.centerIn: parent enabled: view.count == 0 - text: getCountryStations.finished && view.count === 0 ? "Oh no..." : "Please wait" - hintText: getCountryStations.finished && view.count === 0 ? "No radio stations!?!" : "getting radio stations" + text: getCountryStations.finished && view.count === 0 ? qsTr("Oh no...") : qsTr("Please wait") + hintText: getCountryStations.finished && view.count === 0 ? qsTr("No radio stations!?!") : qsTr("getting radio stations") } VerticalScrollDecorator {} @@ -74,7 +74,7 @@ Page { anchors.topMargin: Theme.paddingLarge anchors.right: parent.right anchors.left: parent.left - anchors.rightMargin: Theme.paddingLarge//headerLogo.width + (Theme.paddingLarge * 2) + anchors.rightMargin: Theme.paddingLarge anchors.leftMargin: Theme.paddingLarge Row { @@ -86,7 +86,7 @@ Page { height: ccode.height * 0.8 fillMode: Image.PreserveAspectFit smooth: true - source: _countrycode === "" ? "../images/bycountry_t.png" : "../flags/"+_countrycode.toLowerCase()+".png" + source: countrycode === "" ? "../images/bycountry_t.png" : "../flags/"+countrycode.toLowerCase()+".png" } Label { id: ccode @@ -94,7 +94,7 @@ Page { color: Theme.highlightColor wrapMode: Text.WordWrap elide: Text.ElideLeft - text: getCountryStations.country //+ " ["+stationCount+"]" + text: getCountryStations.country } } Label { @@ -102,7 +102,7 @@ Page { color: Theme.secondaryHighlightColor width: parent.width horizontalAlignment: Text.AlignRight - text: sortedby//view.count + " channels" + text: sortedby } } } @@ -112,7 +112,7 @@ Page { width: parent.width SearchField { id: sfield - placeholderText: "Search" + placeholderText: qsTr("Search") inputMethodHints: Qt.ImhNoAutoUppercase EnterKey.iconSource: "image://theme/icon-m-enter-close" EnterKey.onClicked: focus = false @@ -148,8 +148,8 @@ Page { label: "Search by:" currentIndex: comboIndex menu: ContextMenu { - MenuItem { text: "Name" } - MenuItem { text: "Tag" } + MenuItem { text: qsTr("Name") } + MenuItem { text: qsTr("Tag") } } onValueChanged: { switch(currentIndex) { @@ -157,9 +157,9 @@ Page { case 1: filterby="tag";getCountryStations.offset=0;getCountryStations.tag=sfield.text;getCountryStations.name="" } if (searchtext.length !== 0) { - getCountryStations.offset=0; - getCountryStations.clear = true - getCountryStations.getStations() + getCountryStations.offset=0; + getCountryStations.clear = true + getCountryStations.getStations() } } } @@ -168,19 +168,19 @@ Page { PullDownMenu { MenuItem { - text: "Name" + text: qsTr("Name") onClicked: {getCountryStations.clear=true;getCountryStations.order = "name";getCountryStations.getStations()}//;xmlModel.running = true} } MenuItem { - text: "Most likes" + text: qsTr("Most likes") onClicked: {getCountryStations.clear=true;getCountryStations.order = "votes";getCountryStations.getStations()}//;xmlModel.running = true} } MenuItem { - text: "Most played" + text: qsTr("Most played") onClicked: {getCountryStations.clear=true;getCountryStations.order = "clickcount";getCountryStations.getStations()}//xmlModel.running = true} } MenuItem { - text: "Trending right now" + text: qsTr("Trending right now") onClicked: {getCountryStations.clear=true;getCountryStations.order = "clicktrend";getCountryStations.getStations()}//xmlModel.running = true} } } @@ -205,8 +205,9 @@ Page { } } } + Component.onCompleted: { - getCountryStations.countrycode=_countrycode + getCountryStations.countrycode=countrycode getCountryStations.order=searchby getCountryStations.getStations() } diff --git a/qml/pages/RadioPlayerPage.qml b/qml/pages/RadioPlayerPage.qml index e2acbf2..bdee41b 100644 --- a/qml/pages/RadioPlayerPage.qml +++ b/qml/pages/RadioPlayerPage.qml @@ -33,7 +33,7 @@ Page { PageHeader { id: pheader - z: orientation === Orientation.Portrait || !screenTimer.running ? 98 : 0 + z: orientation === Orientation.Portrait //|| !screenTimer.running ? 98 : 0 visible: orientation !== Orientation.LandscapeMask Column { @@ -263,9 +263,9 @@ Page { id: sleeptimer source: "image://theme/icon-s-timer" height: play.height - width: height + width: favorite.height fillMode: Image.PreserveAspectFit - anchors.verticalCenter: play.verticalCenter + anchors.verticalCenter: favorite.verticalCenter MouseArea { anchors.fill: parent onClicked: { @@ -291,6 +291,7 @@ Page { property bool returnValue: false source: returnValue ? "image://theme/icon-m-like" : "image://theme/icon-m-outline-like" height: favorite.height + anchors.verticalCenter: favorite.verticalCenter width: height fillMode: Image.PreserveAspectFit onReturnValueChanged: console.log(" RETURN VALUE: "+upvote.returnValue) diff --git a/translations/harbour-allradio-de.ts b/translations/harbour-allradio-de.ts index 19dde3e..a4b9886 100644 --- a/translations/harbour-allradio-de.ts +++ b/translations/harbour-allradio-de.ts @@ -1062,6 +1062,49 @@ + + CountryStationsPage + + Oh no... + + + + Please wait + + + + No radio stations!?! + + + + getting radio stations + + + + Search + + + + Name + + + + Tag + + + + Most likes + + + + Most played + + + + Trending right now + + + FavoriteStations diff --git a/translations/harbour-allradio.ts b/translations/harbour-allradio.ts index 5595a3b..24901e3 100644 --- a/translations/harbour-allradio.ts +++ b/translations/harbour-allradio.ts @@ -16,43 +16,43 @@ AllRadio About - Om + Settings - Inställningar + Sleep timer - Insomningstimer + Search - Sök + Sök Countries - Favoriter + My Favorites - Mina Favoriter + Play history - Uppspelningshistorik + My most played Tags - Mest spelade taggar + Trending in - Trendar i + Trending in the world - Trender i världen + @@ -1062,6 +1062,49 @@ + + CountryStationsPage + + Oh no... + + + + Please wait + + + + No radio stations!?! + + + + getting radio stations + + + + Search + Sök + + + Name + + + + Tag + + + + Most likes + + + + Most played + + + + Trending right now + + + FavoriteStations