-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayList.cpp
More file actions
36 lines (29 loc) · 907 Bytes
/
Copy pathPlayList.cpp
File metadata and controls
36 lines (29 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "PlayList.h"
#include <iostream>
void PlayList::AddTrack(const Track& t) { tracks.push_back(t); }
void PlayList::DeleteTrack(size_t index) {
if (index < tracks.size()) tracks.erase(tracks.begin() + index);
}
void PlayList::ClearPlayList() { tracks.clear(); }
void PlayList::NextTrack() {
if (!tracks.empty()) {
currentIndex = (currentIndex + 1) % tracks.size();
}
}
void PlayList::PreviousTrack() {
if (!tracks.empty()) {
currentIndex = (currentIndex == 0) ? tracks.size() - 1 : currentIndex - 1;
}
}
void PlayList::Log() const {
system("cls");
if (tracks.empty()) {
std::cout << "[PlayList is empty]\n";
return;
}
std::cout << "PlayList:\n";
for (size_t i = 0; i < tracks.size(); ++i) {
std::cout << (i == currentIndex ? " > " : " ");
std::cout << "[" << i << "] " << tracks[i].title << "\n";
}
}