Exemple #1
0
    void SoundManager::startRandomTitle()
    {
        Ogre::StringVector filelist;
        if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end())
        {
            Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
            for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
            {
                Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it,
                                                                                            "Music/"+mCurrentPlaylist+"/*");
                filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end());
            }
            mMusicFiles[mCurrentPlaylist] = filelist;
        }
        else
            filelist = mMusicFiles[mCurrentPlaylist];

        if(!filelist.size())
            return;

        int i = rand()%filelist.size();

        // Don't play the same music track twice in a row
        if (filelist[i] == mLastPlayedMusic)
        {
            i = (i+1) % filelist.size();
        }

        streamMusicFull(filelist[i]);
    }
Exemple #2
0
 void SoundManager::streamMusic(const std::string& filename)
 {
     std::string filePath = mMusicLibrary.locate(filename, mFSStrict, true).string();
     if(!filePath.empty())
     {
         streamMusicFull(filePath);
     }
 }
Exemple #3
0
    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();
        streamMusicFull((*filelist)[i]);
    }
    void SoundManager::startRandomTitle()
    {
        Ogre::StringVector filelist;

        Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
        for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
        {
            Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it,
                                                                                        "Music/"+mCurrentPlaylist+"/*");
            filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end());
        }

        if(!filelist.size())
            return;

        int i = rand()%filelist.size();
        streamMusicFull(filelist[i]);
    }
    void SoundManager::startRandomTitle()
    {
        std::vector<std::string> filelist;
        if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end())
        {
            const std::map<std::string, VFS::File*>& index = mVFS->getIndex();

            std::string pattern = "Music/" + mCurrentPlaylist;
            mVFS->normalizeFilename(pattern);

            std::map<std::string, VFS::File*>::const_iterator found = index.lower_bound(pattern);
            while (found != index.end())
            {
                if (found->first.size() >= pattern.size() && found->first.substr(0, pattern.size()) == pattern)
                    filelist.push_back(found->first);
                else
                    break;
                ++found;
            }

            mMusicFiles[mCurrentPlaylist] = filelist;

        }
        else
            filelist = mMusicFiles[mCurrentPlaylist];

        if(!filelist.size())
            return;

        int i = Misc::Rng::rollDice(filelist.size());

        // Don't play the same music track twice in a row
        if (filelist[i] == mLastPlayedMusic)
        {
            i = (i+1) % filelist.size();
        }

        streamMusicFull(filelist[i]);
    }
Exemple #6
0
  void SoundManager::startRandomTitle()
  {
    if(mCurrentPlaylist && !mCurrentPlaylist->empty())
    {
        Files::PathContainer::const_iterator fileIter = mCurrentPlaylist->begin();
        srand( time(NULL) );
        int r = rand() % mCurrentPlaylist->size() + 1;        //old random code

        std::advance(fileIter, r - 1);
        std::string music = fileIter->string();
        std::cout << "Playing " << music << "\n";

        try
        {
            streamMusicFull(music);
        }
        catch (std::exception &e)
        {
            std::cout << "  Music Error: " << e.what() << "\n";
        }
    }
  }
 void SoundManager::streamMusic(const std::string& filename)
 {
     streamMusicFull("Music/"+filename);
 }