mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 12:02:48 +01:00
Merge branch 'master' of https://code.google.com/r/asfa194-clementineremote
This commit is contained in:
commit
e6d16e7645
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.png</file>
|
||||
<file>volumeslider-inset.png</file>
|
||||
<file>clementine_remote_qr.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -31,6 +31,7 @@ enum MsgType {
|
||||
PLAYLIST_SONGS = 43;
|
||||
ENGINE_STATE_CHANGED = 44;
|
||||
KEEP_ALIVE = 45;
|
||||
UPDATE_TRACK_POSITION = 46;
|
||||
}
|
||||
|
||||
// Valid Engine states
|
||||
@ -56,6 +57,7 @@ message SongMetadata {
|
||||
optional int32 playcount = 11;
|
||||
optional string pretty_length = 12;
|
||||
optional bytes art = 13;
|
||||
optional int32 length = 14;
|
||||
}
|
||||
|
||||
// Playlist informations
|
||||
@ -139,9 +141,14 @@ message ResponseEngineStateChanged {
|
||||
optional EngineState state = 1;
|
||||
}
|
||||
|
||||
// Sends the current position of the track
|
||||
message ResponseUpdateTrackPosition {
|
||||
optional int32 position = 1;
|
||||
}
|
||||
|
||||
// The message itself
|
||||
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 RequestPlaylistSongs request_playlist_songs = 10;
|
||||
@ -154,4 +161,5 @@ message Message {
|
||||
optional ResponsePlaylists response_playlists = 17;
|
||||
optional ResponsePlaylistSongs response_playlist_songs = 18;
|
||||
optional ResponseEngineStateChanged response_engine_state_changed = 19;
|
||||
optional ResponseUpdateTrackPosition response_update_track_position = 20;
|
||||
}
|
||||
|
@ -108,8 +108,11 @@ Application::Application(QObject* parent)
|
||||
network_remote_ = new NetworkRemote(this);
|
||||
MoveToNewThread(network_remote_);
|
||||
|
||||
// This must be before libraray_->Init();
|
||||
// In the constructor the helper waits for the signal PlaylistManagerInitialized
|
||||
// to start the remote. Without the playlist manager clementine can
|
||||
// crash when a client connects before the manager is initialized!
|
||||
network_remote_helper_ = new NetworkRemoteHelper(this);
|
||||
network_remote_helper_->StartServer();
|
||||
|
||||
library_->Init();
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
const char* NetworkRemote::kSettingsGroup = "NetworkRemote";
|
||||
const quint16 NetworkRemote::kDefaultServerPort = 5500;
|
||||
const int NetworkRemote::kProtocolBufferVersion = 1;
|
||||
|
||||
NetworkRemote::NetworkRemote(Application* app, QObject* parent)
|
||||
: QObject(parent),
|
||||
|
@ -17,7 +17,6 @@ class NetworkRemote : public QObject {
|
||||
public:
|
||||
static const char* kSettingsGroup;
|
||||
static const quint16 kDefaultServerPort;
|
||||
static const int kProtocolBufferVersion;
|
||||
|
||||
explicit NetworkRemote(Application* app, QObject* parent = 0);
|
||||
~NetworkRemote();
|
||||
|
@ -33,6 +33,10 @@ NetworkRemoteHelper::NetworkRemoteHelper(Application* app)
|
||||
connect(this, SIGNAL(SetupServerSig()),
|
||||
app_->network_remote(), SLOT(SetupServer()));
|
||||
|
||||
// Start the server once the playlistmanager is initialized
|
||||
connect(app_->playlist_manager(), SIGNAL(PlaylistManagerInitialized()),
|
||||
this, SLOT(StartServer()));
|
||||
|
||||
sInstance = this;
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,11 @@ public:
|
||||
NetworkRemoteHelper(Application* app);
|
||||
~NetworkRemoteHelper();
|
||||
|
||||
void StartServer();
|
||||
void ReloadSettings();
|
||||
|
||||
private slots:
|
||||
void StartServer();
|
||||
|
||||
signals:
|
||||
void SetupServerSig();
|
||||
void StartServerSig();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "outgoingdatacreator.h"
|
||||
#include "networkremote.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/timeconstants.h"
|
||||
|
||||
OutgoingDataCreator::OutgoingDataCreator(Application* app)
|
||||
: app_(app)
|
||||
@ -26,6 +27,10 @@ OutgoingDataCreator::OutgoingDataCreator(Application* app)
|
||||
keep_alive_timer_ = new QTimer(this);
|
||||
connect(keep_alive_timer_, SIGNAL(timeout()), this, SLOT(SendKeepAlive()));
|
||||
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() {
|
||||
@ -44,9 +49,6 @@ void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the Version number
|
||||
msg->set_version(NetworkRemote::kProtocolBufferVersion);
|
||||
|
||||
RemoteClient* client;
|
||||
foreach(client, *clients_) {
|
||||
// Check if the client is still active
|
||||
@ -166,6 +168,7 @@ void OutgoingDataCreator::CreateSong(
|
||||
song_metadata->set_artist(DataCommaSizeFromQString(song.artist()));
|
||||
song_metadata->set_album(DataCommaSizeFromQString(song.album()));
|
||||
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_genre(DataCommaSizeFromQString(song.genre()));
|
||||
song_metadata->set_pretty_year(DataCommaSizeFromQString(song.PrettyYear()));
|
||||
@ -257,12 +260,16 @@ void OutgoingDataCreator::StateChanged(Engine::State state) {
|
||||
|
||||
switch (state) {
|
||||
case Engine::Playing: msg.set_type(pb::remote::PLAY);
|
||||
track_position_timer_->start(1000);
|
||||
break;
|
||||
case Engine::Paused: msg.set_type(pb::remote::PAUSE);
|
||||
track_position_timer_->stop();
|
||||
break;
|
||||
case Engine::Empty: msg.set_type(pb::remote::STOP); // Empty is called when player stopped
|
||||
track_position_timer_->stop();
|
||||
break;
|
||||
default: msg.set_type(pb::remote::STOP);
|
||||
track_position_timer_->stop();
|
||||
break;
|
||||
};
|
||||
|
||||
@ -318,3 +325,15 @@ void OutgoingDataCreator::SendKeepAlive() {
|
||||
msg.set_type(pb::remote::KEEP_ALIVE);
|
||||
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 SendRepeatMode(PlaylistSequence::RepeatMode mode);
|
||||
void SendShuffleMode(PlaylistSequence::ShuffleMode mode);
|
||||
void UpdateTrackPosition();
|
||||
|
||||
private:
|
||||
Application* app_;
|
||||
@ -45,6 +46,7 @@ private:
|
||||
QImage current_image_;
|
||||
Engine::State last_state_;
|
||||
QTimer* keep_alive_timer_;
|
||||
QTimer* track_position_timer_;
|
||||
int keep_alive_timeout_;
|
||||
|
||||
void SendDataToClients(pb::remote::Message* msg);
|
||||
|
@ -60,6 +60,9 @@ void NetworkRemoteSettingsPage::Load() {
|
||||
}
|
||||
|
||||
s.endGroup();
|
||||
|
||||
QPixmap android_qr_code(":clementine_remote_qr.png");
|
||||
ui_->android_app_qr->setPixmap(android_qr_code);
|
||||
}
|
||||
|
||||
void NetworkRemoteSettingsPage::Save() {
|
||||
|
@ -86,6 +86,33 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
|
Loading…
Reference in New Issue
Block a user