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