--- UPDATE PLAYER UI ---
| 473 | |
| 474 | // --- UPDATE PLAYER UI --- |
| 475 | void MainWindow::updatePlayerUI(NymphPlaybackStatus status, NCRemoteInstance* ris) { |
| 476 | // Update the UI. |
| 477 | bool paused = false; |
| 478 | if (status.status == NYMPH_PLAYBACK_STATUS_PLAYING) { |
| 479 | ris->paused = false; |
| 480 | ui->remoteStatusLabel->setText("Playing: " + QString::fromStdString(status.artist) |
| 481 | + " - " + QString::fromStdString(status.title)); |
| 482 | } |
| 483 | else if (status.status == NYMPH_PLAYBACK_STATUS_PAUSED) { |
| 484 | ui->remoteStatusLabel->setText("Paused."); |
| 485 | ris->paused = true; |
| 486 | paused = true; |
| 487 | } |
| 488 | else { |
| 489 | ui->remoteStatusLabel->setText("Stopped."); |
| 490 | ris->paused = false; |
| 491 | } |
| 492 | |
| 493 | // Manage muted state. |
| 494 | if (muted && status.volume > 0) { |
| 495 | muted = false; |
| 496 | ui->soundToolButton->setIcon(QIcon(":/icons/icons/high-volume.png")); |
| 497 | } |
| 498 | else if (!muted && status.volume == 0) { |
| 499 | muted = true; |
| 500 | ui->soundToolButton->setIcon(QIcon(":/icons/icons/mute.png")); |
| 501 | } |
| 502 | |
| 503 | if (ris->init && status.playing) { |
| 504 | // If this is the initial connect, but the remote is already playing, treat init |
| 505 | // as already done, as we want to update the UI to reflect the remote status. |
| 506 | ris->init = false; |
| 507 | } |
| 508 | |
| 509 | if (ris->init) { |
| 510 | // Initial callback for this remote on connect. Just set safe defaults. |
| 511 | std::cout << "Initial remote status callback on connect." << std::endl; |
| 512 | |
| 513 | ris->init = false; |
| 514 | |
| 515 | playingTrack = false; |
| 516 | if (posTimer.isActive()) { |
| 517 | // Stop timer. |
| 518 | posTimer.stop(); |
| 519 | } |
| 520 | |
| 521 | ui->playToolButton->setEnabled(true); |
| 522 | ui->playToolButton->setVisible(true); |
| 523 | ui->stopToolButton->setEnabled(false); |
| 524 | ui->pauseToolButton->setEnabled(false); |
| 525 | ui->pauseToolButton->setVisible(false); |
| 526 | |
| 527 | ui->menuCast->setEnabled(true); |
| 528 | ui->sharesPlayButton->setEnabled(true); |
| 529 | |
| 530 | ui->durationLabel->setText("0:00 / 0:00"); |
| 531 | ui->positionSlider->setValue(0); |
| 532 |
nothing calls this directly
no test coverage detected