#ifndef MEDIAPREVIEWDIALOG_H
#define MEDIAPREVIEWDIALOG_H

#include <QDialog>

class QKeyEvent;

QT_BEGIN_NAMESPACE
class QVideoWidget;
class QVideoSink;
class QMediaPlayer;
class QAudioOutput;
class QPushButton;
QT_END_NAMESPACE

class MediaPreviewDialog : public QDialog
{
  Q_OBJECT

public:
  explicit MediaPreviewDialog(QWidget *parent = nullptr);

  /// Video sink for live camera feed during recording
  QVideoSink *videoSink() const;

  /// Show dialog in recording mode (live camera preview, buttons hidden)
  void showRecording();

  /// Transition to preview mode: loop playback, show Cancel/Send buttons
  void showPreview(const QUrl &mediaUrl);

  /// Stop playback and reset state
  void reset();

signals:
  void spaceReleased();

protected:
  void keyReleaseEvent(QKeyEvent *event) override;

private:
  QVideoWidget *m_videoWidget;
  QMediaPlayer *m_player;
  QAudioOutput *m_audioOutput;
  QPushButton *m_cancelButton;
  QPushButton *m_sendButton;
};

#endif // MEDIAPREVIEWDIALOG_H
