Cleainging up, bug hunting and optimizing
This commit is contained in:
+28
-48
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+114
-187
@@ -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()}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user