So this is "Random"?
Posted by tim in I hate technology. on January 9, 2005

I have my entire music collection queued up in WMP10, and it plays the same ~40 songs out of ~2100 over and over and over...

My solution:

C++ class playlistItem { public:     string     m_songTitle;     int     m_songLength;    // In seconds // Other member functions/variables left out for simplicity }; int playlistLength = 0; playlistItem myPlaylist[]; // Initialize the list here by reading the music directory // // Also set the value of playlistLength according to the   // // number of subscripts in the array.                      // // Pick a random subscript from the array                  // srand(rand());            // Seed the random number generator int playThisSong = rand() % playlistLength; playlistItem randomSong = myPlaylist[playThisSong]; // Play the song!                                          // randomSong.play();
 
Comments
There aren't any comments here yet. Maybe you should add one!
Add a comment