MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / play

Method play

player/NymphCastPlayer/mainwindow.cpp:915–1040  ·  view source on GitHub ↗

--- PLAY ---

Source from the content-addressed store, hash-verified

913
914// --- PLAY ---
915void MainWindow::play() {
916 // Play selected track back on selected remote. Connect if necessary.
917 // Immediately fail if:
918 // * No remotes available.
919 // * No remote or group selected.
920 if (remotes.empty()) {
921 QMessageBox::warning(this, tr("No remotes found"), tr("Please refresh and try again."));
922 return;
923 }
924
925 // Get currently selected remote or group, connect if necessary.
926 if (ui->remotesComboBox->count() == 0) {
927 QMessageBox::warning(this, tr("No remotes found"), tr("Please refresh and try again."));
928 return;
929 }
930 else if (ui->remotesComboBox->currentIndex() == -1) {
931 QMessageBox::warning(this, tr("No remote selected"), tr("Please select a target receiver."));
932 return;
933 }
934
935 // Obtain selected ID.
936 int index = ui->remotesComboBox->currentIndex();
937
938 // If a group is selected, pick the first remote in the group as master.
939 if (index > separatorIndex) {
940 // Get the group and set up the master & any slave receivers.
941 NCRemoteGroup& group = groups[ui->remotesComboBox->currentData().toUInt()];
942 if (group.remotes.size() < 1) {
943 // Error: no remotes in group.
944 QMessageBox::warning(this, tr("No remotes"), tr("Group contains no remotes."));
945 return;
946 }
947
948 if (!group.remotes[0].connected) {
949 if (!connectRemote(group.remotes[0])) {
950 QMessageBox::warning(this, tr("Connect fail."), tr("Unable to connect to group."));
951 return;
952 }
953 }
954
955 // Start playing the currently selected track if it isn't already playing.
956 // Else pause or unpause playback.
957 if (playingTrack || group.remotes[0].paused) {
958 //client.playbackStart(group.remotes[0].handle);
959 client.playbackPause(group.remotes[0].handle);
960 }
961 else {
962 QListWidgetItem* item = ui->mediaListWidget->currentItem();
963 if (item == 0) {
964 // If files are loaded in the playlist, start playing from the top, and set the
965 // track as selected.
966 if (ui->mediaListWidget->count() > 0) {
967 ui->mediaListWidget->setCurrentRow(0);
968 item = ui->mediaListWidget->currentItem();
969 }
970 else {
971 QMessageBox::warning(this, tr("No files"), tr("Please first add a file to play."));
972 return;

Callers

nothing calls this directly

Calls 6

dataMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
castFileMethod · 0.45

Tested by

no test coverage detected