diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aomusicplayer.cpp | 5 | ||||
| -rw-r--r-- | src/courtroom.cpp | 30 |
2 files changed, 25 insertions, 10 deletions
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 8a3142eb..e8bd690c 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -13,12 +13,12 @@ AOMusicPlayer::~AOMusicPlayer() } } -void AOMusicPlayer::play(QString p_song, int channel, bool loop, +int AOMusicPlayer::play(QString p_song, int channel, bool loop, int effect_flags) { channel = channel % m_channelmax; if (channel < 0) // wtf? - return; + return BASS_ERROR_NOCHAN; QString f_path = ao_app->get_music_path(p_song); unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | @@ -125,6 +125,7 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop, this->set_looping(loop, channel); // Have to do this here due to any // crossfading-related changes, etc. + return BASS_ErrorGetCode(); } void AOMusicPlayer::stop(int channel) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 82b98e34..a2dca896 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3824,6 +3824,11 @@ void Courtroom::handle_song(QStringList *p_contents) return; } + if(!file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http") + && f_song != "~stop.mp3" && ao_app->asset_url != NULL) { + f_song = (ao_app->asset_url + "sounds/music/" + f_song).toLower(); + } + bool is_stop = (f_song == "~stop.mp3"); if (n_char >= 0 && n_char < char_list.size()) { QString str_char = char_list.at(n_char).name; @@ -3845,17 +3850,26 @@ void Courtroom::handle_song(QStringList *p_contents) } } - music_player->play(f_song, channel, looping, effect_flags); + int error_code = music_player->play(f_song, channel, looping, effect_flags); + if (is_stop) { ui_music_name->setText(tr("None")); + return; } - else if (channel == 0) { - if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http")) - ui_music_name->setText(f_song_clear); - else if (f_song.startsWith("http")) - ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); - else - ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); + + if (error_code == BASS_ERROR_HANDLE) { // Cheap hack to see if file missing + ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); + return; + } + + if (f_song.startsWith("http") && channel == 0) { + ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); + return; + } + + if (channel == 0){ + ui_music_name->setText(f_song_clear); + return; } } |
