tPlayList Class Reference

#include <tPlayList.h>

List of all members.

Public Member Functions

 tPlayList ()
bool LoadPlaylist (const char *playlist)
void Randomize ()
const tSongGetNextSong ()
const tSongGetPreviousSong ()
bool empty ()
void SetPlaylist (int i)

Private Attributes

std::deque< tSongm_Playlist
std::deque< tSong >::iterator m_CurrentSong
int usePlaylist


Detailed Description

Definition at line 58 of file tPlayList.h.


Constructor & Destructor Documentation

tPlayList::tPlayList (  ) 

Definition at line 50 of file tPlayList.cpp.

00050                      {
00051 }


Member Function Documentation

bool tPlayList::LoadPlaylist ( const char *  playlist  ) 

Definition at line 85 of file tPlayList.cpp.

References tDirectories::Data(), tPath::GetReadPath(), tString::Len(), tSong::location, m_CurrentSong, m_Playlist, PLAYLIST_INTERNAL, tString::ReadLine(), tString::StartsWith(), tString::Trim(), and usePlaylist.

Referenced by eMusicTrack::LoadPlaylist().

00085                                                  {
00086     std::ifstream playList(playlist);
00087     if(playList.good() ) {
00088         std::cout << "Opened playlist\n";
00089     } else {
00090         std::cout << "Couldn't open playlist\n";
00091         return false;
00092     }
00093     while(! playList.eof() && playList.good() ) {
00094         tString oneLine;
00095 
00096         oneLine.ReadLine( playList );
00097         oneLine = oneLine.Trim();
00098 
00099         // We only care about lines that start with '#', those are music files
00100         // Also, we require a playlist entry to be at least 2 characters long
00101         if(! oneLine.StartsWith("#") && oneLine.Len() > 2) {
00102             const tPath& vpath = tDirectories::Data();
00103             tSong newSong(oneLine);
00104             if(usePlaylist == PLAYLIST_INTERNAL) {
00105                 newSong.location = vpath.GetReadPath(oneLine);
00106                 //std::cout << newSong.location << "\n";
00107             }
00108             m_Playlist.push_back( newSong );
00109             //std::cout << newSong.location.GetFileMimeExtension() << "\n";
00110             tSong last = m_Playlist.back();
00111         }
00112     }
00113 
00114     m_CurrentSong = m_Playlist.begin();
00115 
00116     /*/ add at least one song
00117     if ( m_Playlist.empty() )
00118         m_Playlist.push_back( tSong() );*/
00119 
00120     return true;
00121 }

Here is the call graph for this function:

Here is the caller graph for this function:

void tPlayList::Randomize (  ) 

Definition at line 53 of file tPlayList.cpp.

References m_CurrentSong, and m_Playlist.

Referenced by eMusicTrack::LoadPlaylist().

00053                           {
00054     std::random_shuffle(m_Playlist.begin(), m_Playlist.end());
00055     m_CurrentSong = m_Playlist.begin();
00056 }

Here is the caller graph for this function:

const tSong & tPlayList::GetNextSong (  ) 

Definition at line 58 of file tPlayList.cpp.

References m_CurrentSong, and m_Playlist.

Referenced by eMusicTrack::Next().

00058                                     {
00059     std::cout << "Getting next song from playlist\n";
00060     if(m_CurrentSong == m_Playlist.end() ) {
00061         m_CurrentSong = m_Playlist.begin();
00062     } else {
00063         if(m_Playlist.size() > 1)
00064             m_CurrentSong++;
00065         if(m_CurrentSong == m_Playlist.end() )
00066             m_CurrentSong = m_Playlist.begin();
00067     }
00068     std::cout << "Got song:" << (*m_CurrentSong).location << "\n";
00069     return (*m_CurrentSong);
00070 }

Here is the caller graph for this function:

const tSong & tPlayList::GetPreviousSong (  ) 

Definition at line 72 of file tPlayList.cpp.

References m_CurrentSong, and m_Playlist.

Referenced by eMusicTrack::Previous().

00072                                         {
00073     std::cout << "Getting previous song from playlist\n";
00074     if(m_CurrentSong == m_Playlist.begin() ) {
00075         m_CurrentSong = m_Playlist.end();
00076         m_CurrentSong--;
00077     } else {
00078         if(m_Playlist.size() > 1)
00079             m_CurrentSong--;
00080     }
00081     std::cout << "Got song:" << (*m_CurrentSong).location << "\n";
00082     return (*m_CurrentSong);
00083 }

Here is the caller graph for this function:

bool tPlayList::empty (  ) 

Definition at line 123 of file tPlayList.cpp.

References m_Playlist.

Referenced by eMusicTrack::LoadPlaylist(), eMusicTrack::Next(), and eMusicTrack::Previous().

00123                       {
00124     return m_Playlist.empty();
00125 }

Here is the caller graph for this function:

void tPlayList::SetPlaylist ( int  i  )  [inline]

Definition at line 67 of file tPlayList.h.

References usePlaylist.

Referenced by eMusicTrack::LoadPlaylist(), and eMusicTrack::SetPlaylist().

00067 { usePlaylist = i; };

Here is the caller graph for this function:


Member Data Documentation

std::deque<tSong> tPlayList::m_Playlist [private]

Definition at line 67 of file tPlayList.h.

Referenced by empty(), GetNextSong(), GetPreviousSong(), LoadPlaylist(), and Randomize().

std::deque<tSong>::iterator tPlayList::m_CurrentSong [private]

Definition at line 71 of file tPlayList.h.

Referenced by GetNextSong(), GetPreviousSong(), LoadPlaylist(), and Randomize().

int tPlayList::usePlaylist [private]

Definition at line 73 of file tPlayList.h.

Referenced by LoadPlaylist(), and SetPlaylist().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:58:13 2008 for Armagetron Advanced by  doxygen 1.5.4