MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Play

Method Play

src/music_gui.cpp:239–255  ·  view source on GitHub ↗

Start/restart playback at current song */

Source from the content-addressed store, hash-verified

237
238/** Start/restart playback at current song */
239void MusicSystem::Play()
240{
241 /* Always set the playing flag, even if there is no music */
242 _settings_client.music.playing = true;
243 MusicDriver::GetInstance()->StopSong();
244 /* Make sure playlist_position is a valid index, if playlist has changed etc. */
245 this->ChangePlaylistPosition(0);
246
247 /* If there is no music, don't try to play it */
248 if (this->active_playlist.empty()) return;
249
250 MusicSongInfo song = this->active_playlist[this->playlist_position];
251 if (_game_mode == GM_MENU && this->selected_playlist == PLCH_THEMEONLY) song.loop = true;
252 MusicDriver::GetInstance()->PlaySong(song);
253
254 InvalidateWindowData(WC_MUSIC_WINDOW, 0);
255}
256
257/** Stop playback and set flag that we don't intend to play music */
258void MusicSystem::Stop()

Callers 6

ChangePlaylistMethod · 0.95
NextMethod · 0.95
PrevMethod · 0.95
PlaylistAddMethod · 0.95
PlaylistRemoveMethod · 0.95
OnClickMethod · 0.80

Calls 5

InvalidateWindowDataFunction · 0.70
StopSongMethod · 0.45
emptyMethod · 0.45
PlaySongMethod · 0.45

Tested by

no test coverage detected