Commit ca9ebd91 authored by Camilo Higuita's avatar Camilo Higuita

move back to kirigai.icon implementation and for beta stop working on streaming feature

parent ea879126
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include <QtAndroid> #include <QtAndroid>
#include <QException> #include <QException>
#include <QAudioOutput>
#include <QAudioInput>
class InterfaceConnFailedException : public QException class InterfaceConnFailedException : public QException
{ {
public: public:
...@@ -69,10 +72,15 @@ Babe::Babe(QObject *parent) : CollectionDB(parent) ...@@ -69,10 +72,15 @@ Babe::Babe(QObject *parent) : CollectionDB(parent)
}); });
connect(&link, &Linking::parseAsk, this, &Babe::linkDecoder); connect(&link, &Linking::parseAsk, this, &Babe::linkDecoder);
connect(&link, &Linking::bytesFrame, [this](QByteArray array)
{
this->player.appendBuffe(array);
});
connect(&link, &Linking::arrayReady, [this](QByteArray array) connect(&link, &Linking::arrayReady, [this](QByteArray array)
{ {
qDebug()<<"trying to play the array"; qDebug()<<"trying to play the array";
this->player.playBuffer(array); this->player.playBuffer();
}); });
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)) #if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
...@@ -243,27 +251,49 @@ void Babe::linkDecoder(QString json) ...@@ -243,27 +251,49 @@ void Babe::linkDecoder(QString json)
auto code = ask[BAE::SLANG[BAE::W::CODE]].toInt(); auto code = ask[BAE::SLANG[BAE::W::CODE]].toInt();
auto msg = ask[BAE::SLANG[BAE::W::MSG]].toString(); auto msg = ask[BAE::SLANG[BAE::W::MSG]].toString();
if(code == LINK::CODE::CONNECTED) switch(static_cast<LINK::CODE>(code))
{
this->link.deviceName = msg;
emit this->link.serverConReady(msg);
}
else if(code == LINK::CODE::QUERY || code == LINK::CODE::FILTER)
{ {
auto res = this->getDBDataQML(msg); case LINK::CODE::CONNECTED :
link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res)); {
} this->link.deviceName = msg;
else if(code == LINK::CODE::SEARCHFOR) emit this->link.serverConReady(msg);
{ break;
auto res = this->searchFor(msg.split(",")); }
link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res)); case LINK::CODE::QUERY :
}else if(code == LINK::CODE::PLAY) case LINK::CODE::FILTER :
{ case LINK::CODE::PLAYLISTS :
QFile file(msg); // sound dir {
file.open(QIODevice::ReadOnly); auto res = this->getDBDataQML(msg);
QByteArray arr = file.readAll(); link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res));
qDebug()<<"Preparing track array"<<msg<<arr.size(); break;
link.sendArrayToClient(arr); }
case LINK::CODE::SEARCHFOR :
{
auto res = this->searchFor(msg.split(","));
link.sendToClient(link.packResponse(static_cast<LINK::CODE>(code), res));
break;
}
case LINK::CODE::PLAY :
{
QFile file(msg); // sound dir
file.open(QIODevice::ReadOnly);
QByteArray arr = file.readAll();
qDebug()<<"Preparing track array"<<msg<<arr.size();
link.sendArrayToClient(arr);
break;
}
case LINK::CODE::COLLECT :
{
auto devices = getDevices();
qDebug()<<"DEVICES:"<< devices;
if(!devices.isEmpty())
sendToDevice(devices.first().toMap().value("name").toString(),
devices.first().toMap().value("id").toString(), msg);
break;
}
default: break;
} }
} }
......
...@@ -84,8 +84,8 @@ int main(int argc, char *argv[]) ...@@ -84,8 +84,8 @@ int main(int argc, char *argv[])
KirigamiPlugin::getInstance().registerTypes(); KirigamiPlugin::getInstance().registerTypes();
QtWebView::initialize(); QtWebView::initialize();
#else #else
if(QQuickStyle::availableStyles().contains("nomad")) // if(QQuickStyle::availableStyles().contains("nomad"))
QQuickStyle::setStyle("nomad"); // QQuickStyle::setStyle("nomad");
QtWebEngine::initialize(); QtWebEngine::initialize();
#endif #endif
......
...@@ -5,11 +5,6 @@ import QtGraphicalEffects 1.0 ...@@ -5,11 +5,6 @@ import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material 2.1
import "services/local" import "services/local"
import org.kde.kirigami 2.2 as Kirigami
import Link.Codes 1.0
//import QtQuick.Controls.Imagine 2.3
import "utils" import "utils"
import "widgets" import "widgets"
...@@ -27,6 +22,10 @@ import "db/Queries.js" as Q ...@@ -27,6 +22,10 @@ import "db/Queries.js" as Q
import "utils/Player.js" as Player import "utils/Player.js" as Player
import "utils/Help.js" as H import "utils/Help.js" as H
import org.kde.kirigami 2.2 as Kirigami
import Link.Codes 1.0
Kirigami.ApplicationWindow Kirigami.ApplicationWindow
{ {
id: root id: root
......
...@@ -97,6 +97,7 @@ ColumnLayout ...@@ -97,6 +97,7 @@ ColumnLayout
coverArtVisible: false coverArtVisible: false
trackRating: true trackRating: true
trackDuration: false trackDuration: false
allowMenu: false
headerBarVisible: true headerBarVisible: true
headerBarExitIcon: "arrow-left" headerBarExitIcon: "arrow-left"
headerBarExit: !linkingPage.wideMode headerBarExit: !linkingPage.wideMode
...@@ -127,7 +128,11 @@ ColumnLayout ...@@ -127,7 +128,11 @@ ColumnLayout
onRowClicked: {} onRowClicked: {}
onQuickPlayTrack: onQuickPlayTrack:
{ {
link.collectTrack(filterList.model.get(index).url)
// link.collectTrack(filterList.model.get(index).url)
// player.playRemote("ftp://"+link.getIp()+filterList.model.get(index).url)
} }
onPlayAll: {} onPlayAll: {}
onPulled: {} onPulled: {}
...@@ -237,7 +242,7 @@ ColumnLayout ...@@ -237,7 +242,7 @@ ColumnLayout
linkingModel.model.remove(i) linkingModel.model.remove(i)
if(isLinked) if(isLinked)
link.ask(LINK.PLAYLISTS,Q.GET.playlists) link.ask(LINK.PLAYLISTS, Q.GET.playlists)
} }
function appendPlaylists(res) function appendPlaylists(res)
......
...@@ -47,16 +47,10 @@ Linking::Linking(QObject *parent) : QObject(parent) ...@@ -47,16 +47,10 @@ Linking::Linking(QObject *parent) : QObject(parent)
connect(&client, &QWebSocket::binaryFrameReceived, [this] (const QByteArray &frame, bool isLastFrame) connect(&client, &QWebSocket::binaryFrameReceived, [this] (const QByteArray &frame, bool isLastFrame)
{ {
qDebug()<<"binary frame recived"<<frame; emit this->bytesFrame(frame);
qDebug()<<"BYTEARRAY SO FAR:"<<arraySize<<trackArray;
arraySize += frame.size();
trackArray.append(frame);
if(isLastFrame) if(isLastFrame)
{ {
arraySize=0;
trackArray = QByteArray();
emit this->arrayReady(trackArray); emit this->arrayReady(trackArray);
} }
}); });
...@@ -114,7 +108,7 @@ void Linking::ask(int code, QString msg) ...@@ -114,7 +108,7 @@ void Linking::ask(int code, QString msg)
void Linking::collectTrack(QString url) void Linking::collectTrack(QString url)
{ {
qDebug()<<"Trying to collec track"<<url; qDebug()<<"Trying to collec track"<<url;
this->ask(LINK::CODE::PLAY, url); this->ask(LINK::CODE::COLLECT, url);
} }
QVariantMap Linking::decode(const QString &json) QVariantMap Linking::decode(const QString &json)
......
...@@ -22,6 +22,7 @@ namespace LINK ...@@ -22,6 +22,7 @@ namespace LINK
FILTER = 6, FILTER = 6,
QUERY = 7, QUERY = 7,
PLAY = 8, PLAY = 8,
COLLECT = 9
}; };
Q_ENUM_NS(CODE); Q_ENUM_NS(CODE);
...@@ -34,7 +35,8 @@ namespace LINK ...@@ -34,7 +35,8 @@ namespace LINK
{CODE::PLAYLISTS, "PLAYLISTS"}, {CODE::PLAYLISTS, "PLAYLISTS"},
{CODE::FILTER, "FILTER"}, {CODE::FILTER, "FILTER"},
{CODE::QUERY, "QUERY"}, {CODE::QUERY, "QUERY"},
{CODE::PLAY, "PLAY"} {CODE::PLAY, "PLAY"},
{CODE::COLLECT, "COLLECT"}
}; };
} }
...@@ -44,7 +46,6 @@ class Linking : public QObject ...@@ -44,7 +46,6 @@ class Linking : public QObject
Q_OBJECT Q_OBJECT
private: private:
Socket *server;
QWebSocket client; QWebSocket client;
QString IP; QString IP;
QString stringify(const QVariantMap &map); QString stringify(const QVariantMap &map);
...@@ -53,6 +54,8 @@ class Linking : public QObject ...@@ -53,6 +54,8 @@ class Linking : public QObject
public: public:
Socket *server;
explicit Linking(QObject *parent = nullptr); explicit Linking(QObject *parent = nullptr);
QString deviceName; QString deviceName;
...@@ -83,6 +86,8 @@ class Linking : public QObject ...@@ -83,6 +86,8 @@ class Linking : public QObject
void responseReady(QVariantMap res); void responseReady(QVariantMap res);
void arrayReady(QByteArray array); void arrayReady(QByteArray array);
void bytesFrame(QByteArray array);
public slots: public slots:
void handleError(QAbstractSocket::SocketError error); void handleError(QAbstractSocket::SocketError error);
......
...@@ -83,11 +83,29 @@ QString Player::transformTime(const int &pos) ...@@ -83,11 +83,29 @@ QString Player::transformTime(const int &pos)
auto time = BAE::transformTime(pos); auto time = BAE::transformTime(pos);
return time; return time;
} }
void Player::appendBuffe(QByteArray &array)
{
qDebug()<<"APENDING TO BUFFER"<< array << this->array;
this->array.append(array, array.length());
amountBuffers++;
if(amountBuffers == 1)
playBuffer();
}
void Player::playRemote(const QString &url)
{
qDebug()<<"Trying to play remote"<<url;
this->sourceurl = url;
this->player->setMedia(QUrl::fromUserInput(url));
this->play();
}
void Player::playBuffer(QByteArray &array) void Player::playBuffer()
{ {
buffer->setData(array); buffer->setData(array);
buffer->open(QIODevice::ReadOnly); buffer->open(QIODevice::ReadOnly);
if(!buffer->isReadable()) qDebug()<<"Cannot read buffer";
player->setMedia(QMediaContent(),buffer); player->setMedia(QMediaContent(),buffer);
this->sourceurl = "buffer"; this->sourceurl = "buffer";
this->play(); this->play();
......
...@@ -20,14 +20,17 @@ class Player : public QObject ...@@ -20,14 +20,17 @@ class Player : public QObject
Q_INVOKABLE int duration(); Q_INVOKABLE int duration();
Q_INVOKABLE bool isPaused(); Q_INVOKABLE bool isPaused();
Q_INVOKABLE QString transformTime(const int &pos); Q_INVOKABLE QString transformTime(const int &pos);
Q_INVOKABLE void playBuffer(QByteArray &array); Q_INVOKABLE void playBuffer();
Q_INVOKABLE void appendBuffe(QByteArray &array);
Q_INVOKABLE void playRemote(const QString &url);
private: private:
QMediaPlayer *player; QMediaPlayer *player;
QTimer *updater; QTimer *updater;
int amountBuffers =0;
void update(); void update();
QBuffer *buffer; QBuffer *buffer;
QByteArray array;
QString sourceurl; QString sourceurl;
......
...@@ -247,6 +247,7 @@ Page ...@@ -247,6 +247,7 @@ Page
trackRating: true trackRating: true
onExit: clearSearch() onExit: clearSearch()
isArtworkRemote: true isArtworkRemote: true
allowMenu: false
appendBtn.visible: false appendBtn.visible: false
playAllBtn.visible: false playAllBtn.visible: false
......
...@@ -14,26 +14,27 @@ ToolButton ...@@ -14,26 +14,27 @@ ToolButton
property bool anim : false property bool anim : false
icon.name: isMobile ? "" : babeButton.iconName // icon.name: isMobile ? "" : babeButton.iconName
icon.width: isMobile ? 0 : babeButton.iconSize // icon.width: isMobile ? 0 : babeButton.iconSize
icon.height: isMobile ? 0 : babeButton.iconSize // icon.height: isMobile ? 0 : babeButton.iconSize
icon.color: isMobile ? "transparent" : (iconColor || defaultColor) // icon.color: isMobile ? "transparent" : (iconColor || defaultColor)
onClicked: if(anim) animIcon.running = true onClicked: if(anim) animIcon.running = true
flat: true flat: true
highlighted: false highlighted: false
// Kirigami.Icon Kirigami.Icon
// { {
// id: kirigamIcon id: kirigamIcon
// anchors.centerIn: parent anchors.centerIn: parent
// width: iconSize width: iconSize
// height: iconSize height: iconSize
// visible: !isMobile visible: !isMobile
// source: isMobile ? "" : iconName source: isMobile ? "" : iconName
// isMask: false isMask: false
// color: iconColor || defaultColor color: iconColor || defaultColor
// } }
BabeIcon BabeIcon
{ {
......
...@@ -20,10 +20,11 @@ BabeList ...@@ -20,10 +20,11 @@ BabeList
property bool menuItemVisible : isMobile property bool menuItemVisible : isMobile
property bool trackDuration property bool trackDuration
property bool trackRating property bool trackRating
property bool allowMenu: true
property bool isArtworkRemote : false
property alias headerMenu: headerMenu property alias headerMenu: headerMenu
property alias contextMenu : contextMenu property alias contextMenu : contextMenu
property bool isArtworkRemote : false
property alias playAllBtn : playAllBtn property alias playAllBtn : playAllBtn
property alias appendBtn : appendBtn property alias appendBtn : appendBtn
...@@ -107,8 +108,8 @@ BabeList ...@@ -107,8 +108,8 @@ BabeList
{ {
target: delegate target: delegate
onPressAndHold: if(root.isMobile) openItemMenu(index) onPressAndHold: if(isMobile && allowMenu) openItemMenu(index)
onRightClicked: openItemMenu(index) onRightClicked: if(allowMenu) openItemMenu(index)
onClicked: onClicked:
{ {
......
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