radio/corax/models/player.h

85 lines
1.8 KiB
C
Raw Normal View History

2018-08-04 21:52:16 +00:00
#ifndef PLAYER_H
#define PLAYER_H
#include <map>
#include <deque>
#include <wModel/model.h>
#include <wModel/button.h>
#include <wModel/modelstring.h>
#include <wModel/list.h>
#include <wType/vocabulary.h>
#include <wType/vector.h>
#include <wType/address.h>
#include "proxysong.h"
/**
* @todo write docs
*/
namespace M {
class Player : public M::Model {
Q_OBJECT
public:
Player(const W::Address& address, QObject* parent = 0);
~Player();
void set(const W::Object & value) override;
void set(W::Object * value) override;
M::Model::ModelType getType() const override;
enum ItemType {
playPause,
currentPlayback,
queue,
picture,
prev,
next
};
enum Mode {
playBack
2018-08-04 21:52:16 +00:00
};
void play();
void pause();
2018-08-04 21:52:16 +00:00
protected:
void h_subscribe(const W::Event & ev) override;
handler(get);
handler(queue);
private:
2018-10-28 21:32:44 +00:00
typedef std::map<ItemType, W::Address> ItemMap;
2018-08-04 21:52:16 +00:00
typedef std::deque<ProxySong*> Queue;
ItemMap controls;
ItemMap views;
M::Button* playPauseBtn;
M::Button* nextBtn;
M::Button* prevBtn;
2018-08-04 21:52:16 +00:00
M::List* _queueView;
Queue _queue;
ProxySong* current;
2018-10-28 21:32:44 +00:00
uint64_t counter;
uint64_t currentIndex;
Mode mode;
bool playing;
bool scheduledToplay;
void setActive(ProxySong* song);
void setActive(uint64_t index);
2018-08-04 21:52:16 +00:00
private slots:
void onPlayPauseBtn();
void onNextBtn();
void onPrevBtn();
void onSongReady();
void onSongNotReady();
2018-08-04 21:52:16 +00:00
};
}
#endif // PLAYER_H