ui->setupUi(this);
setWindowTitle("Vlc remote");
-
+ mIsFirstStatusCall = true;
mTimer = new QTimer(this);
mNetManager = new QNetworkAccessManager(this);
// check for network
if (AppSettings::isConnected()) {
QSettings settings;
- QString last_ip = AccountDialog::currentIp();
+ QString last_ip = AppSettings::getCurrentIp(); // AccountDialog::currentIp();
if (!last_ip.isNull() && !last_ip.isEmpty()) {
QTcpSocket * socket = new QTcpSocket;
if(last_ip.contains(":"))
else {
socket->connectToHost(last_ip,8080);
}
- if (!socket->waitForConnected(1000)) {
+ if (!socket->waitForConnected(AppSettings::getConnectionTimeout())) {
showConfig();
}
else {
mPlayListMainWindow->init();
mBrowserMainWindow->init();
- mTimer->start(5000);
+ mTimer->start(AppSettings::getStatusPollTimeout());
askStatus();
}
delete socket;
AccountDialog * dialog = new AccountDialog(this);
dialog->exec();
- mIp= AccountDialog::currentIp();
+ mIp= AppSettings::getCurrentIp(); //AccountDialog::currentIp();
mPlayListMainWindow->init();
mBrowserMainWindow->init();
- mTimer->start(5000);
+ mTimer->start(AppSettings::getStatusPollTimeout());
askStatus();
}
else {
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
QMaemo5InformationBox::information(this, tr("Network unavailable!"), QMaemo5InformationBox::DefaultTimeout);
#endif
- QTimer::singleShot(20000, this, SLOT(showConfig()));
+ QTimer::singleShot(AppSettings::getRetryNetworkTimeout(), this, SLOT(showConfig()));
}
}
void PlayerMainWindow::showAbout()
doc.setContent(reply->readAll());
delete reply;
QDomElement docElem = doc.documentElement();
+ VlcStatusState oldState = mCurrentStatus.state;
// Get the raw values
int volume = docElem.namedItem("volume").toElement().text().toInt();
int length = docElem.namedItem("length").toElement().text().toInt();
// now would be a good time to work out if we are a new track / file or not.
// key if we are going to look for album art later
// for now we check length and title this will require further examination later
- mCurrentStatus.newtrack = true;
- if (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) {
- mCurrentStatus.newtrack = false;
- }
- mCurrentStatus.volume = volume;
- mCurrentStatus.length = length;
- mCurrentStatus.time = time;
- mCurrentStatus.position = position;
- mCurrentStatus.random = (1 == random);
- mCurrentStatus.loop = (1 == loop);
- mCurrentStatus.repeat = (1 == repeat);
- mCurrentStatus.title = title;
- mCurrentStatus.artist = artist;
- mCurrentStatus.album = album;
- mCurrentStatus.nowplaying = now_playing;
- mCurrentStatus.hasart = (!art_url.isNull() && !art_url.isEmpty());
if (!state.isNull() && !state.isEmpty()) {
if (0 == QString::compare("playing", state, Qt::CaseInsensitive)) {
mCurrentStatus.state = PLAYING;
}
else {
mCurrentStatus.state = UNKNOWN;
+ mIsFirstStatusCall = true;
}
}
else {
mCurrentStatus.state = UNKNOWN;
+ mIsFirstStatusCall = true;
}
+ mCurrentStatus.newtrack = true;
+ if (mIsFirstStatusCall) {
+ mIsFirstStatusCall = false;
+ mCurrentStatus.newtrack = true; // unneeded but self-documenting
+ }
+ else if (STOP == oldState && STOP != mCurrentStatus.state) {
+ mCurrentStatus.newtrack = true; // unneeded but self-documenting
+ }
+ else {
+ if ( (0 == mCurrentStatus.length || STOP == mCurrentStatus.state) // stopped or null
+ || // same track as current playing
+ (mCurrentStatus.length == length && !mCurrentStatus.title.isNull() && !title.isNull() && 0 == QString::compare(mCurrentStatus.title, title)) ){
+ mCurrentStatus.newtrack = false;
+ }
+ }
+ mCurrentStatus.volume = volume;
+ mCurrentStatus.length = length;
+ mCurrentStatus.time = time;
+ mCurrentStatus.position = position;
+ mCurrentStatus.random = (1 == random);
+ mCurrentStatus.loop = (1 == loop);
+ mCurrentStatus.repeat = (1 == repeat);
+ mCurrentStatus.title = title;
+ mCurrentStatus.artist = artist;
+ mCurrentStatus.album = album;
+ mCurrentStatus.nowplaying = now_playing;
+ mCurrentStatus.hasart = (!art_url.isNull() && !art_url.isEmpty());
// What's our mute status?
if (0 < mCurrentStatus.volume) {
this->mVolume = mCurrentStatus.volume;
ui->playpauseButton->setIcon(QIcon::fromTheme("camera_playback"));
}
- if (mCurrentStatus.newtrack) {
+ if (STOP == mCurrentStatus.state) {
+ ui->labelArtPortrait->setVisible(false);
+ ui->labelArtLandscape->setVisible(false);
+ }
+
+ if (mCurrentStatus.newtrack && STOP != mCurrentStatus.state) {
// potential actions:
// rebuild display layout
// retrieve album art
mHasImage = false;
- QTimer::singleShot(500, mPlayListMainWindow, SLOT(requestPlayList()));
+ QTimer::singleShot(AppSettings::getRetrieveArtTimeout(), mPlayListMainWindow, SLOT(requestPlayList()));
}
// Update the buttons on the playlist window
if (NULL != this->mPlayListMainWindow) {