now I actually implemented the shuffle button
This commit is contained in:
@@ -70,7 +70,7 @@ void MusicPlayer::MoveSongInQueue(Song* songToMove, Song* otherSong, bool before
|
|||||||
songQueue->MoveSongInPriorityQueue(songToMove, otherSong, beforeElseAfter);
|
songQueue->MoveSongInPriorityQueue(songToMove, otherSong, beforeElseAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MusicPlayer::shuffleQueue( ) {
|
void MusicPlayer::shuffleHandler( ) {
|
||||||
shuffle ? songQueue->ShufflePlaylist( ) : songQueue->RestorePlaylist( );
|
shuffle ? songQueue->ShufflePlaylist( ) : songQueue->RestorePlaylist( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MusicPlayer( ) { }
|
MusicPlayer( ) : songQueue(new SongQueue( )) { }
|
||||||
|
|
||||||
// 0 no shuffle, 1 shuffling
|
// 0 no shuffle, 1 shuffling
|
||||||
int shuffle = 0;
|
int shuffle = 0;
|
||||||
@@ -36,7 +36,7 @@ private:
|
|||||||
|
|
||||||
Audio& audio = Audio::getInstance( );
|
Audio& audio = Audio::getInstance( );
|
||||||
|
|
||||||
void shuffleQueue( );
|
void shuffleHandler( );
|
||||||
void setQueueLoop( );
|
void setQueueLoop( );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -95,7 +95,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
Song* GetCurrentlyPlaying( );
|
Song* GetCurrentlyPlaying( );
|
||||||
|
|
||||||
void SetShuffle(bool shuffle) { this->shuffle = shuffle; }
|
void SetShuffle(bool shuffle) {
|
||||||
|
this->shuffle = shuffle;
|
||||||
|
shuffleHandler( );
|
||||||
|
}
|
||||||
bool GetShuffle( ) { return shuffle; }
|
bool GetShuffle( ) { return shuffle; }
|
||||||
void SetLoop(Loop loop) { this->loop = loop; }
|
void SetLoop(Loop loop) { this->loop = loop; }
|
||||||
Loop GetLoop( ) { return loop; }
|
Loop GetLoop( ) { return loop; }
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "ConditionalCircularLinkedList.h"
|
#include "ConditionalCircularLinkedList.h"
|
||||||
|
|
||||||
ConditionalCircularLinkedList::ConditionalCircularLinkedList( ) { }
|
|
||||||
|
|
||||||
void ConditionalCircularLinkedList::Append(Song* song) {
|
void ConditionalCircularLinkedList::Append(Song* song) {
|
||||||
Node* newNode = new Node(song);
|
Node* newNode = new Node(song);
|
||||||
if (head == nullptr) {
|
if (head == nullptr) {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ private:
|
|||||||
// Variable to either link or unlink the list
|
// Variable to either link or unlink the list
|
||||||
bool isLinked;
|
bool isLinked;
|
||||||
public:
|
public:
|
||||||
ConditionalCircularLinkedList( );
|
ConditionalCircularLinkedList( ) : head(nullptr), isLinked(false), current(nullptr) { }
|
||||||
ConditionalCircularLinkedList(bool isLinked) : head(nullptr), isLinked(isLinked) { }
|
ConditionalCircularLinkedList(bool isLinked) : head(nullptr), isLinked(isLinked), current(nullptr) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Append a new song to the queue
|
* @brief Append a new song to the queue
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "SongQueue.h"
|
#include "SongQueue.h"
|
||||||
|
|
||||||
SongQueue::SongQueue( ) {
|
SongQueue::SongQueue( ) {
|
||||||
queue = new ConditionalCircularLinkedList( );
|
queue = new ConditionalCircularLinkedList(false);
|
||||||
|
|
||||||
// Its never going to be linked, I'm just too lazy to make a new implementation thats almost the same
|
// Its never going to be linked, I'm just too lazy to make a new implementation thats almost the same
|
||||||
priorityQueue = new ConditionalCircularLinkedList(false);
|
priorityQueue = new ConditionalCircularLinkedList(false);
|
||||||
@@ -77,6 +77,7 @@ void SongQueue::MoveSongInPriorityQueue(Song* songToMove, Song* otherSong, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SongQueue::ShufflePlaylist( ) {
|
void SongQueue::ShufflePlaylist( ) {
|
||||||
|
if (queue && queue->IsEmpty( )) return;
|
||||||
//First backup the original list state
|
//First backup the original list state
|
||||||
queue_original = new ConditionalCircularLinkedList(queue);
|
queue_original = new ConditionalCircularLinkedList(queue);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user