actually finally send an event to queue a song, tested, debugged

This commit is contained in:
Blue 2018-11-29 22:41:53 +03:00 committed by Gitea
parent ec349d9bb4
commit fd255bad0a
5 changed files with 35 additions and 11 deletions

View File

@ -15,7 +15,7 @@ ProxySong::ProxySong(const W::Uint64& p_id, const W::Address& p_address, QObject
insert(W::String(u"id"), p_id); insert(W::String(u"id"), p_id);
insert(W::String(u"artist"), new W::String(u"undefined")); insert(W::String(u"artist"), new W::String(u"undefined"));
insert(W::String(u"album"), new W::String(u"undefined")); insert(W::String(u"album"), new W::String(u"undefined"));
insert(W::String(u"name"), new W::String(u"undefined")); insert(W::String(u"song"), new W::String(u"undefined"));
insert(W::String(u"image"), new W::Uint64(0)); insert(W::String(u"image"), new W::Uint64(0));
} }
@ -31,7 +31,7 @@ ProxySong::~ProxySong()
void ProxySong::onSongNewElement(const W::String& key, const W::Object& element) void ProxySong::onSongNewElement(const W::String& key, const W::Object& element)
{ {
if (key == u"name") { if (key == u"name") {
insert(key, element); insert(W::String(u"song"), element);
} else if (key == u"audio") { } else if (key == u"audio") {
if (_ready) { if (_ready) {
_ready = false; _ready = false;

View File

@ -36,10 +36,10 @@ var ImagePane = Vocabulary.inherit({
this.trigger("seviceMessage", "Action " + act + " is not supported in ImagePanel, skipping"); this.trigger("seviceMessage", "Action " + act + " is not supported in ImagePanel, skipping");
supported = false; supported = false;
} }
var model = new LM(""); var model = new LM(actionProps, "");
model.enabled = true; model.enabled = true;
model.hasLabel = true; model.hasLabel = true;
model.label = new LM(actObj.name); model.label = new LM(actionLabelProps, actObj.name);
model.addController(model.label); model.addController(model.label);
model.activate = this._actionActivate.bind(this, act); model.activate = this._actionActivate.bind(this, act);
@ -111,10 +111,21 @@ var ImagePane = Vocabulary.inherit({
var standardActions = { var standardActions = {
"play": { "play": {
handler: function (obj) { handler: function (obj) {
window.play(obj); var id = obj._pairAddress.back(); //todo it's a kind of crutch, need to do something about it in the future
window.play(id);
id.destructor();
}, },
name: "Play" name: "Play"
} }
}; };
var actionProps = {
"backgroundColor": "primaryColor"
};
var actionLabelProps = {
"fontFamily": "casualFont",
"fontSize": "casualFontSize",
"color": "primaryFontColor"
}
module.exports = ImagePane; module.exports = ImagePane;

View File

@ -232,7 +232,17 @@
this._body.setSize(document.body.offsetWidth, document.body.offsetHeight); this._body.setSize(document.body.offsetWidth, document.body.offsetHeight);
}, },
"play": function(id) { "play": function(id) {
console.log("Need to play " + id.toString()); if (this._nodes.Corax && this._nodes.Corax.connected) {
var vc = new Vocabulary();
vc.insert("id", id.clone());
var ev = new Event(this._playerCtl.getPairAddress()["+="](queue), vc);
var socket = this._nodes.Corax.socket;
ev.setSenderId(socket.getId().clone());
socket.send(ev);
ev.destructor();
}
}, },
"_prepareNode": function(name, address, port) { "_prepareNode": function(name, address, port) {
if (this._nodes[name]) { if (this._nodes[name]) {
@ -338,6 +348,8 @@
SocketState.add("connecting", {description: "Socket is connecting to remote host"}); SocketState.add("connecting", {description: "Socket is connecting to remote host"});
SocketState.add("connected", {description: "Socket is connected"}); SocketState.add("connected", {description: "Socket is connected"});
var queue = new Address(["queue"]);
return Lorgar; return Lorgar;
}); });
})(); })();

View File

@ -48,10 +48,11 @@
Layout.fn._onChildChangeLimits.call(this, child); Layout.fn._onChildChangeLimits.call(this, child);
}, },
"_onClick": function() { "_onClick": function(e) {
if (this._enabled) { if (this._enabled) {
this._f.activate(); this._f.activate();
} }
e.stopPropagation();
}, },
"_onSetEnabled": function(enabled) { "_onSetEnabled": function(enabled) {
if (this._enabled !== enabled) { if (this._enabled !== enabled) {

View File

@ -42,10 +42,10 @@
var song = new Label(this._infoModels.song); var song = new Label(this._infoModels.song);
var spacer = new View(helper); var spacer = new View(helper);
this.append(artist, 0, 2, 1, 1) this.append(artist, 0, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(song, 1, 2, 1, 1) this.append(song, 1, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(album, 2, 2, 1, 1) this.append(album, 2, 2, 1, 1, GridLayout.Aligment.LeftCenter);
this.append(spacer, 0, 3, 3, 1); this.append(spacer, 0, 3, 3, 1, GridLayout.Aligment.LeftCenter);
this._uncyclic.push(this._infoModels.artist.destructor.bind(this._infoModels.artist)); this._uncyclic.push(this._infoModels.artist.destructor.bind(this._infoModels.artist));
this._uncyclic.push(this._infoModels.song.destructor.bind(this._infoModels.song)); this._uncyclic.push(this._infoModels.song.destructor.bind(this._infoModels.song));