mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Restore music playback
This commit is contained in:
parent
5ae47f783e
commit
fc27d5cc19
@ -157,6 +157,7 @@ namespace MWSound
|
||||
|
||||
void SoundManager::streamMusic(const std::string& filename)
|
||||
{
|
||||
std::cout <<"Playing "<<filename<< std::endl;
|
||||
try
|
||||
{
|
||||
if(mMusic)
|
||||
@ -171,6 +172,14 @@ namespace MWSound
|
||||
|
||||
void SoundManager::startRandomTitle()
|
||||
{
|
||||
Ogre::StringVectorPtr filelist;
|
||||
filelist = mResourceMgr->findResourceNames(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
"Music/"+mCurrentPlaylist+"/*");
|
||||
if(!filelist->size())
|
||||
return;
|
||||
|
||||
int i = rand()%filelist->size();
|
||||
streamMusic((*filelist)[i]);
|
||||
}
|
||||
|
||||
bool SoundManager::isMusicPlaying()
|
||||
@ -178,8 +187,10 @@ namespace MWSound
|
||||
return mMusic && mMusic->isPlaying();
|
||||
}
|
||||
|
||||
void SoundManager::playPlaylist(std::string playlist)
|
||||
void SoundManager::playPlaylist(const std::string &playlist)
|
||||
{
|
||||
mCurrentPlaylist = playlist;
|
||||
startRandomTitle();
|
||||
}
|
||||
|
||||
void SoundManager::say(MWWorld::Ptr ptr, const std::string& filename)
|
||||
@ -385,7 +396,7 @@ namespace MWSound
|
||||
timePassed = 0.0f;
|
||||
|
||||
// Make sure music is still playing
|
||||
if(!mMusic || !mMusic->isPlaying())
|
||||
if(!isMusicPlaying())
|
||||
startRandomTitle();
|
||||
|
||||
Ogre::Camera *cam = mEnvironment.mWorld->getPlayer().getRenderer()->getCamera();
|
||||
|
@ -44,6 +44,7 @@ namespace MWSound
|
||||
std::auto_ptr<Sound_Output> mOutput;
|
||||
|
||||
boost::shared_ptr<Sound> mMusic;
|
||||
std::string mCurrentPlaylist;
|
||||
|
||||
typedef boost::shared_ptr<Sound> SoundPtr;
|
||||
typedef std::map<std::string,SoundPtr> IDMap;
|
||||
@ -83,7 +84,7 @@ namespace MWSound
|
||||
bool isMusicPlaying();
|
||||
///< Returns true if music is playing
|
||||
|
||||
void playPlaylist(std::string playlist);
|
||||
void playPlaylist(const std::string &playlist);
|
||||
///< Start playing music from the selected folder
|
||||
/// \param name of the folder that contains the playlist
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user