Add in support for streaming music with bass
This commit is contained in:
		
							parent
							
								
									f77ae093e3
								
							
						
					
					
						commit
						371ca313e6
					
				@ -23,14 +23,26 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE |
 | 
					  unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE |
 | 
				
			||||||
                       BASS_UNICODE | BASS_ASYNCFILE;
 | 
					                       BASS_UNICODE | BASS_ASYNCFILE;
 | 
				
			||||||
  if (loop)
 | 
					  unsigned int streaming_flags = BASS_STREAM_AUTOFREE;
 | 
				
			||||||
 | 
					  if (loop) {
 | 
				
			||||||
    flags |= BASS_SAMPLE_LOOP;
 | 
					    flags |= BASS_SAMPLE_LOOP;
 | 
				
			||||||
 | 
					    streaming_flags |= BASS_SAMPLE_LOOP;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DWORD newstream;
 | 
					  DWORD newstream;
 | 
				
			||||||
  if (f_path.endsWith(".opus"))
 | 
					  if (f_path.startsWith("http")) {
 | 
				
			||||||
    newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
 | 
					    if (f_path.endsWith(".opus"))
 | 
				
			||||||
  else
 | 
					      newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0);
 | 
				
			||||||
    newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags);
 | 
					    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")
 | 
					  if (ao_app->get_audio_output_device() != "default")
 | 
				
			||||||
    BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
 | 
					    BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice());
 | 
				
			||||||
 | 
				
			|||||||
@ -73,6 +73,9 @@ QString AOApplication::get_sounds_path(QString p_file)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_music_path(QString p_song)
 | 
					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;
 | 
					  QString path = get_base_path() + "sounds/music/" + p_song;
 | 
				
			||||||
  return get_case_sensitive_path(path);
 | 
					  return get_case_sensitive_path(path);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user