#ifndef AVPLAYER2_PLAYWIDGET_H
#define AVPLAYER2_PLAYWIDGET_H
#pragma once
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QSlider>
#include <QVBoxLayout>
#include <QWidget>

class PlayerController;
class AudioEffectGL;
class OpenGLVideoWidget;

class PlayWidget : public QWidget
{
    Q_OBJECT
public:
    explicit PlayWidget(QWidget* parent = nullptr);
    ~PlayWidget();

    void startToPlay(const QString& url);

    bool isPlaying() const;

private:
    std::unique_ptr<OpenGLVideoWidget> m_videoWidget;
    QSlider* m_sliderProgress;
    QLabel* m_labelTime;
    QPushButton* m_btnPlayPause;
    QComboBox* m_comboSpeed;
    QSlider* m_sliderVolume;
    QLabel* m_labelVolume;
    std::unique_ptr<AudioEffectGL> m_audioEffect;
    PlayerController* m_playerController = nullptr;

    void setupUi();
    void setupConnections();
    void setPlayerController(PlayerController* controller);

private slots:
    void onPlayPauseClicked();
    void onProgressChanged(int value);
    void onSpeedChanged(int index);
    void onVolumeChanged(int value);
};

#endif // AVPLAYER2_PLAYWIDGET_H
