#include <tPlayList.h>
Public Member Functions | |
tPlayList () | |
bool | LoadPlaylist (const char *playlist) |
void | Randomize () |
const tSong & | GetNextSong () |
const tSong & | GetPreviousSong () |
bool | empty () |
void | SetPlaylist (int i) |
Private Attributes | |
std::deque< tSong > | m_Playlist |
std::deque< tSong >::iterator | m_CurrentSong |
int | usePlaylist |
Definition at line 58 of file tPlayList.h.
tPlayList::tPlayList | ( | ) |
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 }
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 }
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 }
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 }
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 }
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; };
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] |