Music Manager functionality: Local Soundtrack Global Soundtracks Play() Stop() Pause() IsPaused() IsPlaying() GetSoundtrackCount() AddLocalSong() AddLocalSongDir() Get/SetGlobal() Get/SetRandom() Get/SetEnable() Get/SetVolume() Song ordering: int GetValidSoundtrack( int iSelection ) { int iReturn = -1; if ( m_fGlobal ) { iSelection %= m_iSndtrackCount; iReturn = iSelection; if ( GetSongCount( iReturn ) == 0 ) { iReturn++; iReturn %= m_iSndtrackCount; while( ( GetSongCount( iReturn ) == 0 ) && ( iReturn != iSelection ) ) { iReturn++; iReturn %= m_iSndtrackCount; } if ( GetSongCount( iReturn ) == 0 ) { iReturn = -1; } } } else { if ( GetSongCount( 0 ) ) { iReturn = 0; } } return iReturn; } SetFirstSong() { int isndTrack = GetValidSoundtrack(0), iSong = 0; if ( m_fEnabled ) { if ( m_fRandom ) { iSndTrack = GetValidSoundtrack( random(10000) ); if ( iSndTrack >= 0 ) { iSong = GetValidSong( iSndTrack, random(10000) ); } } if ( iSndTrack >= 0 && iSong >= 0 ) { SelectSong( iSndTrack, iSong ); } else { // There are no valid songs. // Stop player Stop(); SetEnable( FALSE ); } } } void SetNextSong( void ) { if ( m_fRandom ) { // This function does what this one does... SetFirstSong(); } else { int iSong, iSndTrack; iSndTrack = GetCurrSoundtrack(); iSong = GetValidSong(iSndTrack, GetCurrSong()+1); if ( iSong < 1 ) { // If not global, this will always return 0 or -1 iSndTrack = GetValidSoundtrack(iSndTrack+1); iSong = 0; } if ( iSndTrack >= 0 && iSong >= 0 ) { SelectSong( iSndTrack, iSong ); } else { // There are no valid songs. // Stop player Stop(); SetEnable( FALSE ); } } }