Beispiel #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]);
    }
Beispiel #2
0
    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]);
    }