#ifndef NOWPLAYING_H
#define NOWPLAYING_H

#include <QWidget>
#include <QLabel>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QTimer>

#include "src/data/albumInformation.h"
#include "src/components/nowPlaying/spinningAlbumArt/spinningAlbumArt.h"
#include "src/components/nowPlaying/tracklistWidget/tracklistWidget.h"
#include "src/components/nowPlaying/timePlayedWidget/timePlayedWidget.h"

class NowPlaying : public QWidget
{
    Q_OBJECT
    QSlider* volumeSlider_;
    TimePlayedWidget* timeIndicator_;

public:
    explicit NowPlaying(const AlbumData& item, QWidget* parent = nullptr);
    void setCurrentRow(int row);

protected:
    void closeEvent(QCloseEvent* event) override;

private:
    void playTrack(int index);
    void handleTrackFinished();

    AlbumData item_;
    int index_ = 0;   // active track index

    SpinningAlbumArt* spinningArt_;
    QLabel* trackLabel_;
    TrackListWidget* trackList_;

    QMediaPlayer* player_;
    QAudioOutput* audio_;
};

#endif
