aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-01-05 15:26:23 -0600
committerGitHub <noreply@github.com>2021-01-05 15:26:23 -0600
commit9adfa291913a2d262208003fb79e957037893285 (patch)
tree37a11dad3bec6e15892279f811a4c4e6d97cba60 /src
parentf77ae093e3d5fd86e029cb6309fa3ca34b84fddb (diff)
parent371ca313e60fe07d678f2b8f15eed8f4a28785f5 (diff)
Merge pull request #372 from skyedeving/add-music-streaming
Add in support for streaming music with bass
Diffstat (limited to 'src')
-rw-r--r--src/aomusicplayer.cpp22
-rw-r--r--src/path_functions.cpp3
2 files changed, 20 insertions, 5 deletions
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp
index 6c61b9ad..585a7f42 100644
--- a/src/aomusicplayer.cpp
+++ b/src/aomusicplayer.cpp
@@ -23,14 +23,26 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop,
unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE |
BASS_UNICODE | BASS_ASYNCFILE;
- if (loop)
+ unsigned int streaming_flags = BASS_STREAM_AUTOFREE;
+ if (loop) {
flags |= BASS_SAMPLE_LOOP;
+ streaming_flags |= BASS_SAMPLE_LOOP;
+ }
DWORD newstream;
- if (f_path.endsWith(".opus"))
- newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
- else
- newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
+ if (f_path.startsWith("http")) {
+ if (f_path.endsWith(".opus"))
+ newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
+ else
+ newstream = BASS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
+
+ } else {
+ if (f_path.endsWith(".opus"))
+ newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
+ else
+ newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
+ }
+
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
diff --git a/src/path_functions.cpp b/src/path_functions.cpp
index b1d79762..c6c73a8b 100644
--- a/src/path_functions.cpp
+++ b/src/path_functions.cpp
@@ -73,6 +73,9 @@ QString AOApplication::get_sounds_path(QString p_file)
QString AOApplication::get_music_path(QString p_song)
{
+ if (p_song.startsWith("http")) {
+ return p_song; // url
+ }
QString path = get_base_path() + "sounds/music/" + p_song;
return get_case_sensitive_path(path);
}