- Display a qr code in the remote control settings to download the android app
- Transfer the current track position to clients
This commit is contained in:
parent
f7cccb26fa
commit
0828115c74
BIN
data/clementine_remote_qr.png
Normal file
BIN
data/clementine_remote_qr.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 501 B |
@ -358,5 +358,6 @@
|
|||||||
<file>volumeslider-handle_glow.png</file>
|
<file>volumeslider-handle_glow.png</file>
|
||||||
<file>volumeslider-handle.png</file>
|
<file>volumeslider-handle.png</file>
|
||||||
<file>volumeslider-inset.png</file>
|
<file>volumeslider-inset.png</file>
|
||||||
|
<file>clementine_remote_qr.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -31,6 +31,7 @@ enum MsgType {
|
|||||||
PLAYLIST_SONGS = 43;
|
PLAYLIST_SONGS = 43;
|
||||||
ENGINE_STATE_CHANGED = 44;
|
ENGINE_STATE_CHANGED = 44;
|
||||||
KEEP_ALIVE = 45;
|
KEEP_ALIVE = 45;
|
||||||
|
UPDATE_TRACK_POSITION = 46;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid Engine states
|
// Valid Engine states
|
||||||
@ -56,6 +57,7 @@ message SongMetadata {
|
|||||||
optional int32 playcount = 11;
|
optional int32 playcount = 11;
|
||||||
optional string pretty_length = 12;
|
optional string pretty_length = 12;
|
||||||
optional bytes art = 13;
|
optional bytes art = 13;
|
||||||
|
optional int32 length = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Playlist informations
|
// Playlist informations
|
||||||
@ -139,9 +141,14 @@ message ResponseEngineStateChanged {
|
|||||||
optional EngineState state = 1;
|
optional EngineState state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sends the current position of the track
|
||||||
|
message ResponseUpdateTrackPosition {
|
||||||
|
optional int32 position = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// The message itself
|
// The message itself
|
||||||
message Message {
|
message Message {
|
||||||
optional int32 version = 1 [default=1];
|
optional int32 version = 1 [default=2];
|
||||||
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
|
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
|
||||||
|
|
||||||
optional RequestPlaylistSongs request_playlist_songs = 10;
|
optional RequestPlaylistSongs request_playlist_songs = 10;
|
||||||
@ -154,4 +161,5 @@ message Message {
|
|||||||
optional ResponsePlaylists response_playlists = 17;
|
optional ResponsePlaylists response_playlists = 17;
|
||||||
optional ResponsePlaylistSongs response_playlist_songs = 18;
|
optional ResponsePlaylistSongs response_playlist_songs = 18;
|
||||||
optional ResponseEngineStateChanged response_engine_state_changed = 19;
|
optional ResponseEngineStateChanged response_engine_state_changed = 19;
|
||||||
|
optional ResponseUpdateTrackPosition response_update_track_position = 20;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
const char* NetworkRemote::kSettingsGroup = "NetworkRemote";
|
const char* NetworkRemote::kSettingsGroup = "NetworkRemote";
|
||||||
const quint16 NetworkRemote::kDefaultServerPort = 5500;
|
const quint16 NetworkRemote::kDefaultServerPort = 5500;
|
||||||
const int NetworkRemote::kProtocolBufferVersion = 1;
|
|
||||||
|
|
||||||
NetworkRemote::NetworkRemote(Application* app, QObject* parent)
|
NetworkRemote::NetworkRemote(Application* app, QObject* parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
@ -17,7 +17,6 @@ class NetworkRemote : public QObject {
|
|||||||
public:
|
public:
|
||||||
static const char* kSettingsGroup;
|
static const char* kSettingsGroup;
|
||||||
static const quint16 kDefaultServerPort;
|
static const quint16 kDefaultServerPort;
|
||||||
static const int kProtocolBufferVersion;
|
|
||||||
|
|
||||||
explicit NetworkRemote(Application* app, QObject* parent = 0);
|
explicit NetworkRemote(Application* app, QObject* parent = 0);
|
||||||
~NetworkRemote();
|
~NetworkRemote();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "outgoingdatacreator.h"
|
#include "outgoingdatacreator.h"
|
||||||
#include "networkremote.h"
|
#include "networkremote.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
#include "core/timeconstants.h"
|
||||||
|
|
||||||
OutgoingDataCreator::OutgoingDataCreator(Application* app)
|
OutgoingDataCreator::OutgoingDataCreator(Application* app)
|
||||||
: app_(app)
|
: app_(app)
|
||||||
@ -26,6 +27,10 @@ OutgoingDataCreator::OutgoingDataCreator(Application* app)
|
|||||||
keep_alive_timer_ = new QTimer(this);
|
keep_alive_timer_ = new QTimer(this);
|
||||||
connect(keep_alive_timer_, SIGNAL(timeout()), this, SLOT(SendKeepAlive()));
|
connect(keep_alive_timer_, SIGNAL(timeout()), this, SLOT(SendKeepAlive()));
|
||||||
keep_alive_timeout_ = 10000;
|
keep_alive_timeout_ = 10000;
|
||||||
|
|
||||||
|
// Create the song position timer
|
||||||
|
track_position_timer_ = new QTimer(this);
|
||||||
|
connect(track_position_timer_, SIGNAL(timeout()), this, SLOT(UpdateTrackPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingDataCreator::~OutgoingDataCreator() {
|
OutgoingDataCreator::~OutgoingDataCreator() {
|
||||||
@ -44,9 +49,6 @@ void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the Version number
|
|
||||||
msg->set_version(NetworkRemote::kProtocolBufferVersion);
|
|
||||||
|
|
||||||
RemoteClient* client;
|
RemoteClient* client;
|
||||||
foreach(client, *clients_) {
|
foreach(client, *clients_) {
|
||||||
// Check if the client is still active
|
// Check if the client is still active
|
||||||
@ -166,6 +168,7 @@ void OutgoingDataCreator::CreateSong(
|
|||||||
song_metadata->set_artist(DataCommaSizeFromQString(song.artist()));
|
song_metadata->set_artist(DataCommaSizeFromQString(song.artist()));
|
||||||
song_metadata->set_album(DataCommaSizeFromQString(song.album()));
|
song_metadata->set_album(DataCommaSizeFromQString(song.album()));
|
||||||
song_metadata->set_albumartist(DataCommaSizeFromQString(song.albumartist()));
|
song_metadata->set_albumartist(DataCommaSizeFromQString(song.albumartist()));
|
||||||
|
song_metadata->set_length(song.length_nanosec() / kNsecPerSec);
|
||||||
song_metadata->set_pretty_length(DataCommaSizeFromQString(song.PrettyLength()));
|
song_metadata->set_pretty_length(DataCommaSizeFromQString(song.PrettyLength()));
|
||||||
song_metadata->set_genre(DataCommaSizeFromQString(song.genre()));
|
song_metadata->set_genre(DataCommaSizeFromQString(song.genre()));
|
||||||
song_metadata->set_pretty_year(DataCommaSizeFromQString(song.PrettyYear()));
|
song_metadata->set_pretty_year(DataCommaSizeFromQString(song.PrettyYear()));
|
||||||
@ -257,12 +260,16 @@ void OutgoingDataCreator::StateChanged(Engine::State state) {
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Engine::Playing: msg.set_type(pb::remote::PLAY);
|
case Engine::Playing: msg.set_type(pb::remote::PLAY);
|
||||||
|
track_position_timer_->start(1000);
|
||||||
break;
|
break;
|
||||||
case Engine::Paused: msg.set_type(pb::remote::PAUSE);
|
case Engine::Paused: msg.set_type(pb::remote::PAUSE);
|
||||||
|
track_position_timer_->stop();
|
||||||
break;
|
break;
|
||||||
case Engine::Empty: msg.set_type(pb::remote::STOP); // Empty is called when player stopped
|
case Engine::Empty: msg.set_type(pb::remote::STOP); // Empty is called when player stopped
|
||||||
|
track_position_timer_->stop();
|
||||||
break;
|
break;
|
||||||
default: msg.set_type(pb::remote::STOP);
|
default: msg.set_type(pb::remote::STOP);
|
||||||
|
track_position_timer_->stop();
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -318,3 +325,15 @@ void OutgoingDataCreator::SendKeepAlive() {
|
|||||||
msg.set_type(pb::remote::KEEP_ALIVE);
|
msg.set_type(pb::remote::KEEP_ALIVE);
|
||||||
SendDataToClients(&msg);
|
SendDataToClients(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OutgoingDataCreator::UpdateTrackPosition() {
|
||||||
|
pb::remote::Message msg;
|
||||||
|
msg.set_type(pb::remote::UPDATE_TRACK_POSITION);
|
||||||
|
|
||||||
|
const int position = std::floor(
|
||||||
|
float(app_->player()->engine()->position_nanosec()) / kNsecPerSec + 0.5);
|
||||||
|
|
||||||
|
msg.mutable_response_update_track_position()->set_position(position);
|
||||||
|
|
||||||
|
SendDataToClients(&msg);
|
||||||
|
}
|
||||||
|
@ -36,6 +36,7 @@ public slots:
|
|||||||
void SendKeepAlive();
|
void SendKeepAlive();
|
||||||
void SendRepeatMode(PlaylistSequence::RepeatMode mode);
|
void SendRepeatMode(PlaylistSequence::RepeatMode mode);
|
||||||
void SendShuffleMode(PlaylistSequence::ShuffleMode mode);
|
void SendShuffleMode(PlaylistSequence::ShuffleMode mode);
|
||||||
|
void UpdateTrackPosition();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application* app_;
|
Application* app_;
|
||||||
@ -45,6 +46,7 @@ private:
|
|||||||
QImage current_image_;
|
QImage current_image_;
|
||||||
Engine::State last_state_;
|
Engine::State last_state_;
|
||||||
QTimer* keep_alive_timer_;
|
QTimer* keep_alive_timer_;
|
||||||
|
QTimer* track_position_timer_;
|
||||||
int keep_alive_timeout_;
|
int keep_alive_timeout_;
|
||||||
|
|
||||||
void SendDataToClients(pb::remote::Message* msg);
|
void SendDataToClients(pb::remote::Message* msg);
|
||||||
|
@ -60,6 +60,9 @@ void NetworkRemoteSettingsPage::Load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
|
QPixmap android_qr_code(":clementine_remote_qr.png");
|
||||||
|
ui_->android_app_qr->setPixmap(android_qr_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkRemoteSettingsPage::Save() {
|
void NetworkRemoteSettingsPage::Save() {
|
||||||
|
@ -86,6 +86,33 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>15</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Get the Android App now!</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="android_app_qr">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_5">
|
<spacer name="verticalSpacer_5">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user