Add musclist streaming support
Attempt Nr. 2 - Based on #548 and #501 + Allows client to use a remote source as a last resort if the file can't be found locally. + Adds a check if the target file is missing. This implementation assumed the streaming source to be structured like a webao content respository
This commit is contained in:
parent
004bf12428
commit
b8b6d3cbb3
@ -25,7 +25,7 @@ public:
|
|||||||
int loop_end[4] = {0, 0, 0, 0};
|
int loop_end[4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void play(QString p_song, int channel = 0, bool loop = false,
|
int play(QString p_song, int channel = 0, bool loop = false,
|
||||||
int effect_flags = 0);
|
int effect_flags = 0);
|
||||||
void stop(int channel = 0);
|
void stop(int channel = 0);
|
||||||
|
|
||||||
|
@ -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)
|
int effect_flags)
|
||||||
{
|
{
|
||||||
channel = channel % m_channelmax;
|
channel = channel % m_channelmax;
|
||||||
if (channel < 0) // wtf?
|
if (channel < 0) // wtf?
|
||||||
return;
|
return BASS_ERROR_NOCHAN;
|
||||||
QString f_path = ao_app->get_music_path(p_song);
|
QString f_path = ao_app->get_music_path(p_song);
|
||||||
|
|
||||||
unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE |
|
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
|
this->set_looping(loop, channel); // Have to do this here due to any
|
||||||
// crossfading-related changes, etc.
|
// crossfading-related changes, etc.
|
||||||
|
return BASS_ErrorGetCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMusicPlayer::stop(int channel)
|
void AOMusicPlayer::stop(int channel)
|
||||||
|
@ -3824,6 +3824,11 @@ void Courtroom::handle_song(QStringList *p_contents)
|
|||||||
return;
|
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");
|
bool is_stop = (f_song == "~stop.mp3");
|
||||||
if (n_char >= 0 && n_char < char_list.size()) {
|
if (n_char >= 0 && n_char < char_list.size()) {
|
||||||
QString str_char = char_list.at(n_char).name;
|
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) {
|
if (is_stop) {
|
||||||
ui_music_name->setText(tr("None"));
|
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"))
|
if (error_code == BASS_ERROR_HANDLE) { // Cheap hack to see if file missing
|
||||||
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));
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user