finished the floating controlls for now, the audio backend will change later and the music player controller too
This commit is contained in:
@@ -87,6 +87,10 @@ bool MusicPlayer::IsPlaying( ) {
|
|||||||
return audio.IsMusicPaused( );
|
return audio.IsMusicPaused( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MusicPlayer::IsActive( ) {
|
||||||
|
return audio.IsMusicPlaying( );
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap MusicPlayer::GetAlbumArt( ) {
|
QPixmap MusicPlayer::GetAlbumArt( ) {
|
||||||
return audio.GetAlbumCover( );
|
return audio.GetAlbumCover( );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,11 +109,13 @@ public:
|
|||||||
this->shuffle = shuffle;
|
this->shuffle = shuffle;
|
||||||
shuffleHandler( );
|
shuffleHandler( );
|
||||||
}
|
}
|
||||||
|
bool IsActive( );
|
||||||
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; }
|
||||||
u_short GetVolume( ) { return audio.GetVolume( ); }
|
u_short GetVolume( ) { return audio.GetVolume( ); }
|
||||||
void SetVolume(u_short volume) { audio.SetVolume(volume); }
|
void SetVolume(u_short volume) { audio.SetVolume(volume); }
|
||||||
|
int GetSongDuration( ) { return audio.GetMusicDuration( ); }
|
||||||
|
|
||||||
void AddSongToQueue(Song* song);
|
void AddSongToQueue(Song* song);
|
||||||
void RemoveSongFromQueue(Song* song);
|
void RemoveSongFromQueue(Song* song);
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ FloatingControls::FloatingControls(QWidget* parent) :
|
|||||||
color: #D7D7D7;
|
color: #D7D7D7;
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
connect(&musicPlayer, &MusicPlayer::SongChanged, this, &FloatingControls::setSongDur);
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region Song Progress Bar
|
#pragma region Song Progress Bar
|
||||||
@@ -304,6 +305,27 @@ FloatingControls::FloatingControls(QWidget* parent) :
|
|||||||
mainLayout->setSpacing(10);
|
mainLayout->setSpacing(10);
|
||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
|
m_progressUpdateTimer = new QTimer( );
|
||||||
|
connect(m_progressUpdateTimer, &QTimer::timeout, this, [this]( ) {
|
||||||
|
if (!musicPlayer.IsActive( )) {
|
||||||
|
m_songProgress->setValue(0);
|
||||||
|
m_songPos->setText("-:--");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_short sec = musicPlayer.GetSongProgression( );
|
||||||
|
|
||||||
|
m_songPos->setText(
|
||||||
|
QTime(
|
||||||
|
0,
|
||||||
|
sec / 60,
|
||||||
|
sec % 60
|
||||||
|
).toString("mm:ss"));
|
||||||
|
|
||||||
|
m_songProgress->setValue(sec);
|
||||||
|
});
|
||||||
|
m_progressUpdateTimer->start(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingControls::~FloatingControls( ) { }
|
FloatingControls::~FloatingControls( ) { }
|
||||||
@@ -412,7 +434,6 @@ void FloatingControls::playPause( ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FloatingControls::setTitle( ) {
|
void FloatingControls::setTitle( ) {
|
||||||
std::cout << musicPlayer.GetCurrentlyPlaying( )->GetTitle( ) << std::endl;
|
|
||||||
m_title->setText(QString::fromStdString(musicPlayer.GetCurrentlyPlaying( )->GetTitle( )));
|
m_title->setText(QString::fromStdString(musicPlayer.GetCurrentlyPlaying( )->GetTitle( )));
|
||||||
m_artist->setText(QString::fromStdString(musicPlayer.GetCurrentlyPlaying( )->GetArtist( )));
|
m_artist->setText(QString::fromStdString(musicPlayer.GetCurrentlyPlaying( )->GetArtist( )));
|
||||||
|
|
||||||
@@ -429,3 +450,14 @@ void FloatingControls::setTitle( ) {
|
|||||||
|
|
||||||
m_albumArt->setPixmap(m_albumArt->pixmap( ).copy(targetRect).scaled(QSize(64, 64), Qt::KeepAspectRatio));
|
m_albumArt->setPixmap(m_albumArt->pixmap( ).copy(targetRect).scaled(QSize(64, 64), Qt::KeepAspectRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FloatingControls::setSongDur( ) {
|
||||||
|
u_short sec = musicPlayer.GetSongDuration( );
|
||||||
|
|
||||||
|
m_songDur->setText(
|
||||||
|
QTime(
|
||||||
|
0,
|
||||||
|
sec / 60,
|
||||||
|
sec % 60
|
||||||
|
).toString("mm:ss"));
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ private:
|
|||||||
QSlider* m_songProgress;
|
QSlider* m_songProgress;
|
||||||
QSlider* m_volumeSlider;
|
QSlider* m_volumeSlider;
|
||||||
|
|
||||||
|
// Timer to update the song's duration and slider
|
||||||
|
QTimer* m_progressUpdateTimer;
|
||||||
|
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -70,4 +73,5 @@ private slots:
|
|||||||
void playPause( );
|
void playPause( );
|
||||||
|
|
||||||
void setTitle( );
|
void setTitle( );
|
||||||
|
void setSongDur( );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user