| 77 | } |
| 78 | |
| 79 | static void progressTrack(void *data) |
| 80 | { |
| 81 | JukeBoxImpl *jukebox = static_cast<JukeBoxImpl *>(data); |
| 82 | if (jukebox->trackList.empty()) |
| 83 | { |
| 84 | LogWarning("Trying to play empty jukebox"); |
| 85 | return; |
| 86 | } |
| 87 | if (jukebox->position >= jukebox->trackList.size()) |
| 88 | { |
| 89 | LogInfo("End of jukebox playlist"); |
| 90 | return; |
| 91 | } |
| 92 | LogInfo("Playing track %u (%s)", jukebox->position, |
| 93 | jukebox->trackList[jukebox->position]->getName()); |
| 94 | jukebox->fw.soundBackend->setTrack(jukebox->trackList[jukebox->position]); |
| 95 | |
| 96 | jukebox->position++; |
| 97 | if (jukebox->position >= jukebox->trackList.size()) |
| 98 | { |
| 99 | if (jukebox->mode == PlayMode::Loop) |
| 100 | { |
| 101 | jukebox->position = 0; |
| 102 | } |
| 103 | else if (jukebox->mode == PlayMode::Shuffle) |
| 104 | { |
| 105 | jukebox->position = 0; |
| 106 | jukebox->shuffle(); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | void stop() override |
| 112 | { |