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 Sailfish.Silica 1.0
|
||||
import Nemo.Configuration 1.0 /////////
|
||||
//import Nemo.Configuration 1.0 /////////
|
||||
import Nemo.Notifications 1.0 ///////////
|
||||
import Amber.Mpris 1.0
|
||||
import "pages"
|
||||
@ -18,8 +18,10 @@ ApplicationWindow
|
||||
property string _version: "2.0.15"
|
||||
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 settings: allradioSettings
|
||||
property alias mediaPlayerPanel: mediaPlayerPanel
|
||||
property RadioPlayer radioPlayer : RadioPlayer {id:radioPlayer}
|
||||
property RadioBrowser radioBrowser : RadioBrowser {id:radioBrowser;parent: allRadio}
|
||||
@ -27,7 +29,7 @@ ApplicationWindow
|
||||
|
||||
RadioMprisPlayer {id: radioMprisPlayer}
|
||||
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")}
|
||||
//MprisPlayer {}
|
||||
|
||||
@ -44,10 +46,13 @@ ApplicationWindow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function help(){
|
||||
console.info("help")
|
||||
|
||||
}
|
||||
|
||||
|
||||
function latest(){
|
||||
radioPlayer.loadRecentPlay()
|
||||
radioPlayer.playStream()
|
||||
|
@ -28,7 +28,7 @@ function init() {
|
||||
try {
|
||||
db.transaction(
|
||||
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 countries (countrycode 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
|
||||
}
|
||||
}
|
||||
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
|
||||
// UPDATE OR INSERT STATION CLICKED
|
||||
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]);
|
||||
// console.log("DB INSERT STATION CLICK: "+id)
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
setCountryClicked(cc)
|
||||
setTagClicked(t)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ MediaPlayer {
|
||||
property int stationOk: 3
|
||||
property int maxTagClicks: 0
|
||||
property int playlistCount: playlist.count - 1
|
||||
property int playlistIndex: allradioSettings.value("currentFavorite",-1)
|
||||
property int playlistIndex: Favorites.getSetting("playlistIndex",-1)
|
||||
property QDtimer timer: QDtimer {
|
||||
id: qdTimer
|
||||
interval: 200; running: false; repeat: false
|
||||
@ -63,6 +63,7 @@ MediaPlayer {
|
||||
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")
|
||||
@ -93,7 +94,7 @@ MediaPlayer {
|
||||
playStream()
|
||||
stationOk === 0
|
||||
reloadDbData()
|
||||
if (_favorite) allradioSettings.setValue("currentFavorite",playlistIndex)
|
||||
//if (_favorite) allradioSettings.setValue("currentFavorite",playlistIndex)
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,6 +125,8 @@ MediaPlayer {
|
||||
onHasVideoChanged: if (hasVideo) radioVideo = true
|
||||
onHasAudioChanged: if (hasAudio) radioAudio = true
|
||||
|
||||
|
||||
|
||||
function stopStream() { // stop and clear stream
|
||||
source = ""
|
||||
isPaused = false
|
||||
@ -147,6 +150,9 @@ MediaPlayer {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function playNext() {
|
||||
if (playlistIndex < playlistCount && playlistIndex < playlist.count) playlistIndex = playlistIndex + 1
|
||||
loadPlaylistSelected()
|
||||
@ -161,7 +167,6 @@ MediaPlayer {
|
||||
function videoPause() {
|
||||
source = ""
|
||||
stop()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -185,15 +190,12 @@ MediaPlayer {
|
||||
|
||||
|
||||
function playStream() { // resume paused stream
|
||||
//radioSource = ""
|
||||
|
||||
|
||||
source = _url_resolved
|
||||
play()
|
||||
isPlaying = true
|
||||
isPaused = false
|
||||
qdTimer.start()
|
||||
// play()
|
||||
Favorites.setSetting("playlistIndex",playlistIndex)
|
||||
}
|
||||
|
||||
onError: {
|
||||
@ -339,6 +341,7 @@ 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)
|
||||
@ -359,6 +362,7 @@ MediaPlayer {
|
||||
_favorite = playlist.get(playlistIndex).favorite
|
||||
isPlaying = true
|
||||
isPaused = false
|
||||
|
||||
playStream()
|
||||
// pageStack.push("RadioPlayerPage.qml")
|
||||
}
|
||||
@ -378,6 +382,7 @@ MediaPlayer {
|
||||
_favorite = playHistory.get(0).favorite
|
||||
isPlaying = false
|
||||
isPaused = true
|
||||
//playlistIndex = allradioSettings.value("currentFavorite",-1)
|
||||
// pageStack.push("RadioPlayerPage.qml")
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,7 @@ Page {
|
||||
|
||||
GridView {
|
||||
//clip: true
|
||||
id: favoriteView
|
||||
clip: true
|
||||
height: Theme.itemSizeHuge * 1.35
|
||||
width: page.width
|
||||
@ -201,6 +202,10 @@ Page {
|
||||
radioPlayer._homepage = model.homepage
|
||||
radioPlayer._stationuuid = model.stationuuid
|
||||
radioPlayer.getStationFavorite(model.stationuuid)
|
||||
radioPlayer.playlistIndex = index
|
||||
|
||||
console.log("Index: "+index)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import "../helpers/db.js" as Favorites
|
||||
Page {
|
||||
property ListModel favorites: ListModel {id: favorites}
|
||||
property real showP: 0.0
|
||||
property int tab: allradioSettings.value("favoriteTab",0)
|
||||
property int tab: 0//allradioSettings.value("favoriteTab",0)
|
||||
SilicaListView {
|
||||
|
||||
id: view
|
||||
@ -98,7 +98,12 @@ Page {
|
||||
radioPlayer._homepage = model.homepage
|
||||
radioPlayer._stationuuid = model.stationuuid
|
||||
radioPlayer._favorite = model.favorite ? true : false
|
||||
radioPlayer.fav
|
||||
//pageStack.push("RadioPlayerPage.qml")
|
||||
radioPlayer.playlistIndex = index
|
||||
|
||||
console.log("Index: "+index)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,7 +122,7 @@ Page {
|
||||
updateFav()
|
||||
}
|
||||
Component.onDestruction: {
|
||||
allradioSettings.setValue("favoriteTab",tab)
|
||||
//allradioSettings.setValue("favoriteTab",tab)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ Page {
|
||||
radioPlayer._homepage = model.homepage
|
||||
radioPlayer._stationuuid = model.stationuuid
|
||||
radioPlayer._favorite = model.favorite ? true : false
|
||||
radioPlayer.playlistIndex = favoriteView.currentIndex
|
||||
//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 {
|
||||
id: sleeptimer
|
||||
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 {
|
||||
id: favorite
|
||||
source: radioPlayer._favorite ? "image://theme/icon-m-favorite-selected" : "image://theme/icon-m-favorite"
|
||||
|
Loading…
x
Reference in New Issue
Block a user