an image to player, first ideas to make a playback

This commit is contained in:
Blue 2018-12-02 18:07:43 +03:00
parent 43d0a1dfe9
commit 98a443e298
10 changed files with 192 additions and 10 deletions

View file

@ -8,7 +8,9 @@ M::Player::Player(const W::Address& address, QObject* parent):
_queueView(new M::List(address + W::Address{u"queueView"})),
_queue(),
current(0),
counter(0)
counter(0),
mode(playBack),
playing(false)
{
W::Handler* get = W::Handler::create(address + W::Address({u"get"}), this, &M::Player::_h_get);
W::Handler* hqueue = W::Handler::create(address + W::Address({u"queue"}), this, &M::Player::_h_queue);
@ -83,13 +85,32 @@ void M::Player::h_get(const W::Event& ev)
res->insert(u"controls", ctrls);
res->insert(u"views", vws);
res->insert(u"mode", new W::Uint64(mode));
response(res, W::Address({u"get"}), ev);
}
void M::Player::onPlayPauseBtn()
{
if (playing) {
playPauseBtn->setLabel(W::String(u"Pause"));
playing = false;
switch (mode) {
case playBack:
broadcast(new W::Vocabulary(), W::Address{u"pause"});
break;
}
} else {
playPauseBtn->setLabel(W::String(u"Play"));
playing = true;
switch (mode) {
case playBack:
broadcast(new W::Vocabulary(), W::Address{u"play"});
break;
}
}
}
void M::Player::h_queue(const W::Event& ev)

View file

@ -31,7 +31,12 @@ namespace M {
enum ItemType {
playPause,
currentPlayback,
queue
queue,
picture
};
enum Mode {
playBack
};
protected:
@ -51,6 +56,8 @@ namespace M {
Queue _queue;
ProxySong* current;
uint64_t counter;
Mode mode;
bool playing;
private slots:
void onPlayPauseBtn();

View file

@ -17,6 +17,7 @@ ProxySong::ProxySong(const W::Uint64& p_id, const W::Address& p_address, QObject
insert(W::String(u"album"), 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"audio"), new W::Uint64(0));
}
bool ProxySong::isReady() const
@ -39,6 +40,7 @@ void ProxySong::onSongNewElement(const W::String& key, const W::Object& element)
}
fileId = static_cast<const W::Uint64&>(element);
insert(key, element);
_ready = true;
emit ready();
} else if (key == u"artist") {
@ -73,6 +75,7 @@ void ProxySong::onSongRemoveElement(const W::String& key)
if (key == u"name") {
insert(key, new W::String(u"undefined"));
} else if (key == u"audio") {
insert(key, new W::Uint64(0));
if (_ready) {
_ready = false;
fileId = W::Uint64(0);