Working on some kind of playlist management
This commit is contained in:
parent
7f0d724bad
commit
1cf3224545
@ -1,6 +1,6 @@
|
|||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
import Nemo.Configuration 1.0 /////////
|
//import Nemo.Configuration 1.0 /////////
|
||||||
import Nemo.Notifications 1.0 ///////////
|
import Nemo.Notifications 1.0 ///////////
|
||||||
import Amber.Mpris 1.0
|
import Amber.Mpris 1.0
|
||||||
import "pages"
|
import "pages"
|
||||||
@ -18,8 +18,10 @@ ApplicationWindow
|
|||||||
property string _version: "2.0.15"
|
property string _version: "2.0.15"
|
||||||
property string _language: Qt.locale().name.slice(0,2)
|
property string _language: Qt.locale().name.slice(0,2)
|
||||||
property string _country: Qt.locale().name.slice(-2)
|
property string _country: Qt.locale().name.slice(-2)
|
||||||
|
property int currentListIndex: -1
|
||||||
|
property int currentListCount: -1
|
||||||
property int sleepTime: 0
|
property int sleepTime: 0
|
||||||
property alias settings: allradioSettings
|
//property alias settings: allradioSettings
|
||||||
property alias mediaPlayerPanel: mediaPlayerPanel
|
property alias mediaPlayerPanel: mediaPlayerPanel
|
||||||
property RadioPlayer radioPlayer : RadioPlayer {id:radioPlayer}
|
property RadioPlayer radioPlayer : RadioPlayer {id:radioPlayer}
|
||||||
property RadioBrowser radioBrowser : RadioBrowser {id:radioBrowser;parent: allRadio}
|
property RadioBrowser radioBrowser : RadioBrowser {id:radioBrowser;parent: allRadio}
|
||||||
@ -27,7 +29,7 @@ ApplicationWindow
|
|||||||
|
|
||||||
RadioMprisPlayer {id: radioMprisPlayer}
|
RadioMprisPlayer {id: radioMprisPlayer}
|
||||||
MediaPlayerPanel {id: mediaPlayerPanel}
|
MediaPlayerPanel {id: mediaPlayerPanel}
|
||||||
ConfigurationGroup {id:settingsGroup;path: "/apps/harbour-allradio";ConfigurationGroup {id: allradioSettings;path: "/settings"}}
|
//ConfigurationGroup {id:settingsGroup;path: "/apps/harbour-allradio";ConfigurationGroup {id: allradioSettings;path: "/settings"}}
|
||||||
Notification {id: notification;onClicked: console.log("Clicked")}
|
Notification {id: notification;onClicked: console.log("Clicked")}
|
||||||
//MprisPlayer {}
|
//MprisPlayer {}
|
||||||
|
|
||||||
@ -44,10 +46,13 @@ ApplicationWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function help(){
|
function help(){
|
||||||
console.info("help")
|
console.info("help")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function latest(){
|
function latest(){
|
||||||
radioPlayer.loadRecentPlay()
|
radioPlayer.loadRecentPlay()
|
||||||
radioPlayer.playStream()
|
radioPlayer.playStream()
|
||||||
|
@ -28,7 +28,7 @@ function init() {
|
|||||||
try {
|
try {
|
||||||
db.transaction(
|
db.transaction(
|
||||||
function(tx) {
|
function(tx) {
|
||||||
//tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)');
|
tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)');
|
||||||
tx.executeSql('CREATE TABLE IF NOT EXISTS stations (id TEXT UNIQUE, name TEXT, countrycode STRING, homepage TEXT, radiourlresolved TEXT, favicon TEXT, tagslist TEXT, codec TEXT, bitrate TEXT, hls TEXT, myclicktimestamp STRING, myclickcount INTEGER, favorite INTEGER)');
|
tx.executeSql('CREATE TABLE IF NOT EXISTS stations (id TEXT UNIQUE, name TEXT, countrycode STRING, homepage TEXT, radiourlresolved TEXT, favicon TEXT, tagslist TEXT, codec TEXT, bitrate TEXT, hls TEXT, myclicktimestamp STRING, myclickcount INTEGER, favorite INTEGER)');
|
||||||
tx.executeSql('CREATE TABLE IF NOT EXISTS countries (countrycode TEXT UNIQUE, myclickcount INTEGER)');
|
tx.executeSql('CREATE TABLE IF NOT EXISTS countries (countrycode TEXT UNIQUE, myclickcount INTEGER)');
|
||||||
tx.executeSql('CREATE TABLE IF NOT EXISTS tags (tag TEXT UNIQUE, myclickcount INTEGER)');
|
tx.executeSql('CREATE TABLE IF NOT EXISTS tags (tag TEXT UNIQUE, myclickcount INTEGER)');
|
||||||
@ -41,6 +41,42 @@ function init() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function setSetting(key, value) {
|
||||||
|
db = settings_db_open();
|
||||||
|
var res = "";
|
||||||
|
db.transaction(function(tx) {
|
||||||
|
var rs = tx.executeSql('INSERT OR REPLACE INTO settings VALUES (?,?);', [key,value]);
|
||||||
|
if (rs.rowsAffected > 0) {
|
||||||
|
res = "OK";
|
||||||
|
} else {
|
||||||
|
res = "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
console.log("setSetting: "+value)
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSetting(key, default_value) {
|
||||||
|
db = settings_db_open();
|
||||||
|
var res="";
|
||||||
|
try {
|
||||||
|
db.transaction(function(tx) {
|
||||||
|
var rs = tx.executeSql('SELECT value FROM settings WHERE setting=?;', [key]);
|
||||||
|
if (rs.rows.length > 0) {
|
||||||
|
res = rs.rows.item(0).value;
|
||||||
|
} else {
|
||||||
|
res = default_value;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
//console.log("Database " + err);
|
||||||
|
res = default_value;
|
||||||
|
};
|
||||||
|
console.log("getSetting: "+res)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
// id TEXT UNIQUE, name TEXT, countrycode STRING, homepage TEXT, radiourlresolved TEXT, favicon TEXT, tagslist TEXT, codec TEXT, bitrate TEXT, hls TEXT, myclicktimestamp STRING, myclickcount INTEGER, favorite INTEGER
|
// id TEXT UNIQUE, name TEXT, countrycode STRING, homepage TEXT, radiourlresolved TEXT, favicon TEXT, tagslist TEXT, codec TEXT, bitrate TEXT, hls TEXT, myclicktimestamp STRING, myclickcount INTEGER, favorite INTEGER
|
||||||
// UPDATE OR INSERT STATION CLICKED
|
// UPDATE OR INSERT STATION CLICKED
|
||||||
function setStationClicked(myclicktimestamp,id,name,countrycode,homepage,radiourlresolved,favicon,tagslist,codec,bitrate,hls,favorite) {
|
function setStationClicked(myclicktimestamp,id,name,countrycode,homepage,radiourlresolved,favicon,tagslist,codec,bitrate,hls,favorite) {
|
||||||
@ -60,8 +96,7 @@ function setStationClicked(myclicktimestamp,id,name,countrycode,homepage,radiour
|
|||||||
tx.executeSql('INSERT INTO stations VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)',[id, name, cc, homepage, radiourlresolved,favicon,t,codec,bitrate,hls,myclicktimestamp,1,fav]);
|
tx.executeSql('INSERT INTO stations VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)',[id, name, cc, homepage, radiourlresolved,favicon,t,codec,bitrate,hls,myclicktimestamp,1,fav]);
|
||||||
// console.log("DB INSERT STATION CLICK: "+id)
|
// console.log("DB INSERT STATION CLICK: "+id)
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
setCountryClicked(cc)
|
setCountryClicked(cc)
|
||||||
setTagClicked(t)
|
setTagClicked(t)
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ MediaPlayer {
|
|||||||
property int stationOk: 3
|
property int stationOk: 3
|
||||||
property int maxTagClicks: 0
|
property int maxTagClicks: 0
|
||||||
property int playlistCount: playlist.count - 1
|
property int playlistCount: playlist.count - 1
|
||||||
property int playlistIndex: allradioSettings.value("currentFavorite",-1)
|
property int playlistIndex: Favorites.getSetting("playlistIndex",-1)
|
||||||
property QDtimer timer: QDtimer {
|
property QDtimer timer: QDtimer {
|
||||||
id: qdTimer
|
id: qdTimer
|
||||||
interval: 200; running: false; repeat: false
|
interval: 200; running: false; repeat: false
|
||||||
@ -63,6 +63,7 @@ MediaPlayer {
|
|||||||
autoPlay: false
|
autoPlay: false
|
||||||
autoLoad: true
|
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)}
|
//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")
|
onPlaying: if (!playerPageOpen) pageStack.push("../pages/RadioPlayerPage.qml")
|
||||||
@ -93,7 +94,7 @@ MediaPlayer {
|
|||||||
playStream()
|
playStream()
|
||||||
stationOk === 0
|
stationOk === 0
|
||||||
reloadDbData()
|
reloadDbData()
|
||||||
if (_favorite) allradioSettings.setValue("currentFavorite",playlistIndex)
|
//if (_favorite) allradioSettings.setValue("currentFavorite",playlistIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +125,8 @@ MediaPlayer {
|
|||||||
onHasVideoChanged: if (hasVideo) radioVideo = true
|
onHasVideoChanged: if (hasVideo) radioVideo = true
|
||||||
onHasAudioChanged: if (hasAudio) radioAudio = true
|
onHasAudioChanged: if (hasAudio) radioAudio = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function stopStream() { // stop and clear stream
|
function stopStream() { // stop and clear stream
|
||||||
source = ""
|
source = ""
|
||||||
isPaused = false
|
isPaused = false
|
||||||
@ -147,6 +150,9 @@ MediaPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function playNext() {
|
function playNext() {
|
||||||
if (playlistIndex < playlistCount && playlistIndex < playlist.count) playlistIndex = playlistIndex + 1
|
if (playlistIndex < playlistCount && playlistIndex < playlist.count) playlistIndex = playlistIndex + 1
|
||||||
loadPlaylistSelected()
|
loadPlaylistSelected()
|
||||||
@ -161,7 +167,6 @@ MediaPlayer {
|
|||||||
function videoPause() {
|
function videoPause() {
|
||||||
source = ""
|
source = ""
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -185,15 +190,12 @@ MediaPlayer {
|
|||||||
|
|
||||||
|
|
||||||
function playStream() { // resume paused stream
|
function playStream() { // resume paused stream
|
||||||
//radioSource = ""
|
|
||||||
|
|
||||||
|
|
||||||
source = _url_resolved
|
source = _url_resolved
|
||||||
play()
|
play()
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
isPaused = false
|
isPaused = false
|
||||||
qdTimer.start()
|
qdTimer.start()
|
||||||
// play()
|
Favorites.setSetting("playlistIndex",playlistIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
onError: {
|
onError: {
|
||||||
@ -339,6 +341,7 @@ MediaPlayer {
|
|||||||
function reloadDbData() {
|
function reloadDbData() {
|
||||||
Favorites.getStationRecentClicked(playHistory,15)
|
Favorites.getStationRecentClicked(playHistory,15)
|
||||||
Favorites.getFavorites(playlist,"myclickcount",10000)
|
Favorites.getFavorites(playlist,"myclickcount",10000)
|
||||||
|
|
||||||
//Favorites.getStationMostClickedFav(radioPlayermostPlayed,settings._nrOfFavoritePreview)
|
//Favorites.getStationMostClickedFav(radioPlayermostPlayed,settings._nrOfFavoritePreview)
|
||||||
//Favorites.getCountryRecentClicked(playedCountries,2)
|
//Favorites.getCountryRecentClicked(playedCountries,2)
|
||||||
//Favorites.getTagsRecentClicked(playedTags,10)
|
//Favorites.getTagsRecentClicked(playedTags,10)
|
||||||
@ -359,6 +362,7 @@ MediaPlayer {
|
|||||||
_favorite = playlist.get(playlistIndex).favorite
|
_favorite = playlist.get(playlistIndex).favorite
|
||||||
isPlaying = true
|
isPlaying = true
|
||||||
isPaused = false
|
isPaused = false
|
||||||
|
|
||||||
playStream()
|
playStream()
|
||||||
// pageStack.push("RadioPlayerPage.qml")
|
// pageStack.push("RadioPlayerPage.qml")
|
||||||
}
|
}
|
||||||
@ -378,6 +382,7 @@ MediaPlayer {
|
|||||||
_favorite = playHistory.get(0).favorite
|
_favorite = playHistory.get(0).favorite
|
||||||
isPlaying = false
|
isPlaying = false
|
||||||
isPaused = true
|
isPaused = true
|
||||||
|
//playlistIndex = allradioSettings.value("currentFavorite",-1)
|
||||||
// pageStack.push("RadioPlayerPage.qml")
|
// pageStack.push("RadioPlayerPage.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,7 @@ Page {
|
|||||||
|
|
||||||
GridView {
|
GridView {
|
||||||
//clip: true
|
//clip: true
|
||||||
|
id: favoriteView
|
||||||
clip: true
|
clip: true
|
||||||
height: Theme.itemSizeHuge * 1.35
|
height: Theme.itemSizeHuge * 1.35
|
||||||
width: page.width
|
width: page.width
|
||||||
@ -201,6 +202,10 @@ Page {
|
|||||||
radioPlayer._homepage = model.homepage
|
radioPlayer._homepage = model.homepage
|
||||||
radioPlayer._stationuuid = model.stationuuid
|
radioPlayer._stationuuid = model.stationuuid
|
||||||
radioPlayer.getStationFavorite(model.stationuuid)
|
radioPlayer.getStationFavorite(model.stationuuid)
|
||||||
|
radioPlayer.playlistIndex = index
|
||||||
|
|
||||||
|
console.log("Index: "+index)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import "../helpers/db.js" as Favorites
|
|||||||
Page {
|
Page {
|
||||||
property ListModel favorites: ListModel {id: favorites}
|
property ListModel favorites: ListModel {id: favorites}
|
||||||
property real showP: 0.0
|
property real showP: 0.0
|
||||||
property int tab: allradioSettings.value("favoriteTab",0)
|
property int tab: 0//allradioSettings.value("favoriteTab",0)
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
|
|
||||||
id: view
|
id: view
|
||||||
@ -98,7 +98,12 @@ Page {
|
|||||||
radioPlayer._homepage = model.homepage
|
radioPlayer._homepage = model.homepage
|
||||||
radioPlayer._stationuuid = model.stationuuid
|
radioPlayer._stationuuid = model.stationuuid
|
||||||
radioPlayer._favorite = model.favorite ? true : false
|
radioPlayer._favorite = model.favorite ? true : false
|
||||||
|
radioPlayer.fav
|
||||||
//pageStack.push("RadioPlayerPage.qml")
|
//pageStack.push("RadioPlayerPage.qml")
|
||||||
|
radioPlayer.playlistIndex = index
|
||||||
|
|
||||||
|
console.log("Index: "+index)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +122,7 @@ Page {
|
|||||||
updateFav()
|
updateFav()
|
||||||
}
|
}
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
allradioSettings.setValue("favoriteTab",tab)
|
//allradioSettings.setValue("favoriteTab",tab)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ Page {
|
|||||||
radioPlayer._homepage = model.homepage
|
radioPlayer._homepage = model.homepage
|
||||||
radioPlayer._stationuuid = model.stationuuid
|
radioPlayer._stationuuid = model.stationuuid
|
||||||
radioPlayer._favorite = model.favorite ? true : false
|
radioPlayer._favorite = model.favorite ? true : false
|
||||||
|
radioPlayer.playlistIndex = favoriteView.currentIndex
|
||||||
//pageStack.push("RadioPlayerPage.qml")
|
//pageStack.push("RadioPlayerPage.qml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,21 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
visible: orientation === Orientation.Portrait
|
||||||
|
width: sleeptimer.width + upvote.width + favorite.width + (Theme.paddingMedium * 4)
|
||||||
|
height: upvote.height + (Theme.paddingMedium * 2)
|
||||||
|
radius: 90
|
||||||
|
color: Theme.rgba(Theme.overlayBackgroundColor,0.5)
|
||||||
|
border.width: 0
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: Theme.paddingLarge
|
||||||
|
Row {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.paddingMedium
|
||||||
Image {
|
Image {
|
||||||
id: sleeptimer
|
id: sleeptimer
|
||||||
source: "image://theme/icon-s-timer"
|
source: "image://theme/icon-s-timer"
|
||||||
@ -256,21 +271,6 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
visible: orientation === Orientation.Portrait
|
|
||||||
width: upvote.width + favorite.width + (Theme.paddingMedium * 4)
|
|
||||||
height: upvote.height + (Theme.paddingMedium * 2)
|
|
||||||
radius: 90
|
|
||||||
color: Theme.rgba(Theme.overlayBackgroundColor,0.5)
|
|
||||||
border.width: 0
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.rightMargin: Theme.paddingLarge
|
|
||||||
Row {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: Theme.paddingMedium
|
|
||||||
Image {
|
Image {
|
||||||
id: favorite
|
id: favorite
|
||||||
source: radioPlayer._favorite ? "image://theme/icon-m-favorite-selected" : "image://theme/icon-m-favorite"
|
source: radioPlayer._favorite ? "image://theme/icon-m-favorite-selected" : "image://theme/icon-m-favorite"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user