-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of a larger restructure, added MusicPlayer which is the main con…
…troller and a structure for the song queue
- Loading branch information
Showing
67 changed files
with
1,218 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>aqua.jpg</file> | ||
<file>icons/songControl/shuffle.svg</file> | ||
<file>icons/songControl/prevSong.svg</file> | ||
<file>icons/songControl/nextSong.svg</file> | ||
<file>icons/songControl/play.svg</file> | ||
<file>icons/songControl/pause.svg</file> | ||
<file>icons/songControl/songRepeat.svg</file> | ||
<file>icons/songControl/repeat-once.svg</file> | ||
<file>icons/songControl/volume-high.svg</file> | ||
<file>icons/songControl/volume-low.svg</file> | ||
<file>icons/songControl/volume-mute.svg</file> | ||
<file>icons/songControl/volume-off.svg</file> | ||
<file>icons/songControl/volume-medium.svg</file> | ||
<file>icons/songControl/arrow-expand.svg</file> | ||
<file>icons/home.svg</file> | ||
<file>icons/songControl/magnify.svg</file> | ||
<file>icons/</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "MusicPlayer.h" | ||
|
||
MusicPlayer::~MusicPlayer( ) { } | ||
|
||
void MusicPlayer::PlaySong(Song* song) { | ||
songHistory->push(songQueue->Top( )); | ||
songQueue->SetTop(song); | ||
|
||
audio.PlaySong(songQueue->Top( )->GetPath( )); | ||
} | ||
|
||
void MusicPlayer::NextSong( ) { | ||
if (songQueue->IsEmpty( )) { | ||
audio.StopMusic( ); | ||
return; | ||
} | ||
|
||
songHistory->push(songQueue->Top( )); | ||
songQueue->Next( ); | ||
|
||
audio.PlaySong(songQueue->Top( )->GetPath( )); | ||
} | ||
|
||
void MusicPlayer::NextSong(Song* song, bool isPrioQueue) { | ||
if (songQueue->IsEmpty( )) { | ||
audio.StopMusic( ); | ||
return; | ||
} | ||
|
||
songHistory->push(songQueue->Top( )); | ||
songQueue->JumpToSong(song, isPrioQueue); | ||
|
||
audio.PlaySong(songQueue->Top( )->GetPath( )); | ||
} | ||
|
||
void MusicPlayer::PreviousSong( ) { | ||
if (songHistory->isEmpty( )) | ||
return; | ||
|
||
songQueue->SetTop(songHistory->top( )); | ||
songHistory->pop( ); | ||
|
||
audio.PlaySong(songQueue->Top( )->GetPath( )); | ||
} | ||
|
||
void MusicPlayer::SkipToTimestamp(unsigned const int& skipTo) { | ||
if (audio.IsMusicPlaying( ) == 0) return; | ||
|
||
audio.SetMusicPos(skipTo); | ||
} | ||
|
||
int MusicPlayer::GetSongProgression( ) { | ||
return audio.IsMusicPlaying( ) == 1 ? audio.GetMusicPos( ) : 0; | ||
} | ||
|
||
Song* MusicPlayer::GetCurrentlyPlaying( ) { | ||
return songQueue->Top( ); | ||
} | ||
|
||
//For the PriorityQueue | ||
void MusicPlayer::AddSongToQueue(Song* song) { | ||
songQueue->AddToPriorityQueue(song); | ||
} | ||
|
||
void MusicPlayer::RemoveSongFromQueue(Song* song) { | ||
songQueue->RemoveSongFromPriorityQueue(song); | ||
} | ||
|
||
void MusicPlayer::MoveSongInQueue(Song* songToMove, Song* otherSong, bool beforeElseAfter) { | ||
songQueue->MoveSongInPriorityQueue(songToMove, otherSong, beforeElseAfter); | ||
} | ||
|
||
void MusicPlayer::shuffleQueue( ) { | ||
shuffle ? songQueue->ShufflePlaylist( ) : songQueue->RestorePlaylist( ); | ||
} | ||
|
||
void MusicPlayer::setQueueLoop( ) { | ||
loop == All ? songQueue->LinkQueue(true) : songQueue->LinkQueue(false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#pragma once | ||
|
||
#include "../../core/audio/audio.h" | ||
#include "../../core/SongHistory/SongHistory.hpp" | ||
#include "../../core/SongQueue/SongQueue.h" | ||
#include "../../core/song/song.h" | ||
|
||
enum Loop { | ||
None, | ||
Once, | ||
All | ||
}; | ||
|
||
class MusicPlayer { | ||
public: | ||
static MusicPlayer& getInstance( ) { | ||
static MusicPlayer instance; | ||
return instance; | ||
} | ||
|
||
private: | ||
MusicPlayer( ); | ||
|
||
// 0 no shuffle, 1 shuffling | ||
int shuffle = 0; | ||
// None, Once, All | ||
Loop loop = None; | ||
// 0 stopped, 1 playing | ||
bool playing = 0; | ||
|
||
// Song queue, will be filled with the entire playlist by default | ||
SongQueue* songQueue; | ||
|
||
// Contain all played songs | ||
SongHistory<Song*>* songHistory; | ||
|
||
Audio& audio = Audio::getInstance( ); | ||
|
||
void shuffleQueue( ); | ||
void setQueueLoop( ); | ||
|
||
public: | ||
~MusicPlayer( ); | ||
|
||
MusicPlayer(MusicPlayer const&) = delete; | ||
void operator=(MusicPlayer const&) = delete; | ||
|
||
/** | ||
* @brief Will start playing the given song and put itself at the queue top. | ||
* | ||
* @param song Song that will start playing | ||
*/ | ||
void PlaySong(Song* song); | ||
|
||
/** | ||
* @brief Skip the current song and play the next in queue, | ||
* if nothing is in queue it will stop playing anything. | ||
* | ||
*/ | ||
void NextSong( ); | ||
|
||
/** | ||
* @brief Jumps the queue to the given song keeping the non altered queue intact | ||
* | ||
* @param song | ||
* @param isPrioQueue If the song is in the prio queue or normal queue | ||
*/ | ||
void NextSong(Song* song, bool isPrioQueue); | ||
|
||
/** | ||
* @brief Rewind the currently playing song to the beginning if playtime >= 5 seconds. | ||
* Otherwise play the top song in the history stack | ||
* | ||
*/ | ||
void PreviousSong( ); | ||
|
||
/** | ||
* @brief Skip the song to the given timestamp | ||
* | ||
* @param skipTo time as positive integer | ||
*/ | ||
void SkipToTimestamp(unsigned const int& skipTo); | ||
|
||
/** | ||
* @brief Get the current Song progression as an positive integer | ||
* | ||
* @return int current timestamp | ||
*/ | ||
int GetSongProgression( ); | ||
|
||
/** | ||
* @brief Get the Currently Playing Song | ||
* | ||
* @return Song& Song thats currently playing | ||
*/ | ||
Song* GetCurrentlyPlaying( ); | ||
|
||
void SetShuffle(bool shuffle) { this->shuffle = shuffle; } | ||
void SetLoop(Loop loop) { this->loop = loop; } | ||
|
||
void AddSongToQueue(Song* song); | ||
void RemoveSongFromQueue(Song* song); | ||
void MoveSongInQueue(Song* songToMove, Song* otherSong, bool beforeElseAfter); | ||
}; |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.