Commit f2a16c3c authored by Camilo Higuita's avatar Camilo Higuita

more work on spotify service and albums roll

parent d2efe3bc
......@@ -27,6 +27,7 @@
#include "utils/bae.h"
#include "services/web/youtube.h"
#include "services/web/Spotify/spotify.h"
#ifdef Q_OS_ANDROID
Q_DECL_EXPORT
......@@ -70,8 +71,10 @@ int main(int argc, char *argv[])
}
Babe bae;
/* Services */
YouTube youtube;
Spotify spotify;
QFontDatabase::addApplicationFont(":/utils/materialdesignicons-webfont.ttf");
......@@ -87,6 +90,7 @@ int main(int argc, char *argv[])
context->setContextProperty("player", &bae.player);
context->setContextProperty("bae", &bae);
context->setContextProperty("youtube", &youtube);
context->setContextProperty("spotify", &spotify);
context->setContextProperty("link", &bae.link);
qmlRegisterUncreatableMetaObject(
......
......@@ -784,13 +784,6 @@ Kirigami.ApplicationWindow
onCurrentIndexChanged:
{
currentView = currentIndex
if (pageStack.currentIndex === 0)
mainPlaylist.list.forceActiveFocus()
else if (currentView === viewsIndex.tracks)
tracksView.forceActiveFocus()
else if (currentView === viewsIndex.search)
searchView.forceActiveFocus()
if (!babeitView.isConnected
&& currentIndex === viewsIndex.vvave)
babeitView.logginDialog.open()
......
......@@ -85,5 +85,6 @@
<file>assets/heart_indicator_white.gif</file>
<file>services/web/Spotify/Spotify.qml</file>
<file>services/web/Spotify/LoginForm.qml</file>
<file>services/web/Spotify/spotify.html</file>
</qresource>
</RCC>
......@@ -13,13 +13,27 @@ BabePopup
WebEngineView
{
anchors.fill: parent
url: "https://accounts.spotify.com/en/authorize?response_type=code&client_id=a49552c9276745f5b4752250c2d84367&scope=streaming&redirect_uri=vvave:%2F%2Fcallback"
url: "https://accounts.spotify.com/en/authorize?response_type=token&client_id=a49552c9276745f5b4752250c2d84367&scope=streaming user-read-private user-read-birthdate user-read-email&redirect_uri=vvave:%2F%2Fcallback"
onLoadingChanged:
{
var myUrl = url.toString()
if(myUrl.startsWith("vvave://callback/#access_token="))
{
var code = myUrl.slice(("vvave://callback/#access_token=").length, myUrl.length)
spotify.setCode(code);
url = "qrc:/services/web/Spotify/spotify.html"
}
if(loadRequest.status === WebEngineLoadRequest.LoadSucceededStatus)
console.log("page loaded sucessfully")
}
onNewViewRequested:
{
console.log("new view requested")
}
}
}
......@@ -14,16 +14,6 @@ Page
id: loginLoader
}
Component
{
id: loginForm
LoginForm
{
parent: spotifyView
}
}
ColumnLayout
{
anchors.fill: parent
......@@ -39,9 +29,10 @@ Page
headerBarLeft: BabeButton
{
iconName: "internet-services"
onClicked:
onClicked:if(!isAndroid)
{
loginLoader.sourceComponent = loginForm
loginLoader.source = "LoginForm.qml"
loginLoader.item.open()
......
......@@ -17,3 +17,19 @@ Spotify::Spotify(QObject *parent) : QObject(parent)
{
}
void Spotify::setCode(const QString &code)
{
if(code.isEmpty())
this->code = BAE::loadSettings("SPOTIFY_CODE", "VVAVE", "").toString();
else
{
this->code = code;
BAE::saveSettings("SPOTIFY_CODE", code, "VVAVE");
}
}
QString Spotify::getCode()
{
return BAE::loadSettings("SPOTIFY_CODE", "VVAVE", "").toString();
}
......@@ -15,6 +15,12 @@ class Spotify : public QObject
public:
explicit Spotify(QObject *parent = nullptr);
Q_INVOKABLE void setCode(const QString &code = "");
Q_INVOKABLE QString getCode();
private:
QString code;
signals:
public slots:
};
......
<!DOCTYPE html>
<html>
<head>
<title>Spotify Web Playback SDK Quick Start Tutorial</title>
</head>
<body>
<h1>Spotify Web Playback SDK Quick Start Tutorial</h1>
<h2>Open your console log: <code>View > Developer > JavaScript Console</code></h2>
<script src="https://sdk.scdn.co/spotify-player.js"></script>
<!-- We will insert our code here. -->
<script>
window.onSpotifyWebPlaybackSDKReady = () => {
const token = 'BQD-clXoAed6M7WCfM4BxxVHQ5LC0sGgu5adY29NIkF5fS1mf-_t_48CNFTk4UYfenLC4qx9eKY7gtQ5sfiZOginbjR_tWfbc2rHoY90p_vILZlqHeWzNttfDSo7vKckLbReeQ_2Iv8g1JOP-SepvaBPbtAGMSQx';
const player = new Spotify.Player({
name: 'Web Playback SDK Quick Start Player',
getOAuthToken: cb => { cb(token); }
});
// Error handling
player.addListener('initialization_error', ({ message }) => { console.error(message); });
player.addListener('authentication_error', ({ message }) => { console.error(message); });
player.addListener('account_error', ({ message }) => { console.error(message); });
player.addListener('playback_error', ({ message }) => { console.error(message); });
// Playback status updates
player.addListener('player_state_changed', state => { console.log(state); });
// Ready
player.addListener('ready', ({ device_id }) => {
console.log('Ready with Device ID', device_id);
});
// Connect to the player!
player.connect();
};
</script>
</body>
</html>
......@@ -19,6 +19,7 @@ ItemDelegate
property bool showIndicator : false
property bool isCurrentListItem : ListView.isCurrentItem
property bool hideRepeated : false
property bool increaseCurrentItem : false
property color labelColor : GridView.isCurrentItem || hovered || down ? highlightColor : textColor
// height: typeof album === 'undefined' ? parseInt(albumSize+(albumSize*0.3)) : parseInt(albumSize+(albumSize*0.4))
......@@ -89,13 +90,13 @@ ItemDelegate
Image
{
id: img
width: albumSize
height: albumSize
width: increaseCurrentItem ? albumSize * (isCurrentListItem ? 1 : 0.85) : albumSize
height: width
anchors.centerIn: parent
sourceSize.width: albumSize
sourceSize.height: albumSize
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
cache: true
......
......@@ -129,8 +129,8 @@ Page
interactive: true
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
keyNavigationWraps: !isMobile
keyNavigationEnabled : !isMobile
keyNavigationWraps: true
keyNavigationEnabled : true
Keys.onUpPressed: decrementCurrentIndex()
Keys.onDownPressed: incrementCurrentIndex()
......
......@@ -14,6 +14,8 @@ BabeList
headerBarColor: backgroundColor
labelColor: textColor
focus: true
property bool trackNumberVisible
property bool quickPlayVisible : true
property bool coverArtVisible : false
......
......@@ -14,22 +14,22 @@ ListView
currentIndex: currentTrackIndex
highlightFollowsCurrentItem: true
highlightMoveDuration: 0
// snapMode: ListView.SnapToItem
// snapMode: ListView.SnapOneItem
cacheBuffer: width
model : ListModel{}
delegate: BabeAlbum
{
id: delegate
itemHeight: coverSize
itemWidth: coverSize + space.huge
itemWidth: coverSize + space.big
albumSize : coverSize
albumRadius : 0
showLabels: false
showIndicator: true
hideRepeated: true
anchors.verticalCenter: parent.verticalCenter
increaseCurrentItem : true
Connections
{
target: delegate
......
......@@ -43,12 +43,12 @@ Item
onSaveToClicked: table.saveList()
}
Rectangle
{
anchors.fill: parent
color: darkDarkColor
z: -999
}
// Rectangle
// {
// anchors.fill: parent
// color: darkDarkColor
// z: -999
// }
GridLayout
{
......@@ -73,46 +73,29 @@ Item
{
visible: cover.visible
anchors.fill: parent
color: darkDarkColor
color: "transparent"
z: -999
Image
{
id: artwork
visible: cover.visible
visible: false
anchors.fill: parent
//// sourceSize.height: coverSize
//// sourceSize.width: coverSize
// anchors.centerIn: parent
sourceSize.height: coverSize * 0.2
sourceSize.width: coverSize * 0.2
source: currentArtwork ? "file://"+encodeURIComponent(currentArtwork) : "qrc:/assets/cover.png"
fillMode: Image.PreserveAspectCrop
}
FastBlur
{
visible: cover.visible
visible: artwork.visible
anchors.fill: parent
source: artwork
radius: 100
transparentBorder: false
cached: true
}
MouseArea
{
anchors.fill: parent
onDoubleClicked: gomini()
onPressAndHold:
{
var query = Q.GET.albumTracks_.arg(currentTrack.album)
query = query.arg(currentTrack.artist)
var tracks = bae.get(query)
coverPressed(tracks)
}
}
}
}
Item
......@@ -127,6 +110,7 @@ Item
width: parent.width
anchors.verticalCenter: parent.vertical
}
}
}
......@@ -145,13 +129,13 @@ Item
leftPadding: 0
rightPadding: 0
Rectangle
{
anchors.fill: parent
color: darkDarkColor
opacity: opacityLevel
z: -999
}
// Rectangle
// {
// anchors.fill: parent
// color: darkDarkColor
// opacity: opacityLevel
// z: -999
// }
MouseArea
{
......@@ -191,7 +175,7 @@ Item
{
id: infoBtn
anchors.centerIn: parent
iconColor: darkTextColor
// iconColor: darkTextColor
iconName: stackView.currentItem === table ? "documentinfo" : "go-previous"
onClicked:
{
......@@ -214,7 +198,20 @@ Item
BabeButton
{
anchors.centerIn: parent
iconColor: darkTextColor
// iconColor: darkTextColor
iconName: "headphones"
onClicked: goFocusMode()
}
}
Item
{
Layout.fillWidth: true
BabeButton
{
anchors.centerIn: parent
// iconColor: darkTextColor
iconName: "videoclip-amarok"
onClicked:
{
......@@ -236,7 +233,7 @@ Item
Layout.fillWidth: true
iconName: "overflow-menu"
onClicked: isMobile ? playlistMenu.open() : playlistMenu.popup()
iconColor: darkTextColor
// iconColor: darkTextColor
}
}
......@@ -316,14 +313,14 @@ Item
holder.message : "<h2>Meh!</h2><p>Start putting together your playlist!</p>"
holder.emoji: "qrc:/assets/face-sleeping.png"
labelColor: darkTextColor
// labelColor: darkTextColor
Rectangle
{
anchors.fill: parent
z: -999
color: darkDarkColor
}
// Rectangle
// {
// anchors.fill: parent
// z: -999
// color: darkDarkColor
// }
onRowClicked: play(index)
......
......@@ -14,7 +14,6 @@ BabeTable
headerBarExit: false
coverArtVisible: false
section.property : "album"
section.criteria: ViewSection.FullString
section.delegate: BabeDelegate
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment