SimplePlayerWindow.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef SIMPLEPLAYERWINDOW_H
  2. #define SIMPLEPLAYERWINDOW_H
  3. #include <QApplication>
  4. #include <QDebug>
  5. #include <QFileDialog>
  6. #include <QHBoxLayout>
  7. #include <QLabel>
  8. #include <QMainWindow>
  9. #include <QMessageBox>
  10. #include <QPushButton>
  11. #include <QSlider>
  12. #include <QTimer>
  13. #include <QVBoxLayout>
  14. #include "player_adapter.h"
  15. #include "opengl_video_renderer.h"
  16. using namespace av::player;
  17. /**
  18. * @brief 简单的播放器UI示例
  19. *
  20. * 这个类展示了如何使用新的PlayerAdapter来构建播放器UI
  21. */
  22. class SimplePlayerWindow : public QMainWindow
  23. {
  24. Q_OBJECT
  25. public:
  26. explicit SimplePlayerWindow(QWidget* parent = nullptr);
  27. ~SimplePlayerWindow();
  28. private slots:
  29. void openFile();
  30. void playPause();
  31. void stop();
  32. void seek();
  33. void setVolume();
  34. void toggleMute();
  35. void setPlaybackSpeed();
  36. // 播放器事件处理
  37. void onStateChanged(PlayerState state);
  38. void onMediaInfoChanged(const MediaInfo& info);
  39. void onPositionChanged(qint64 position);
  40. void onVolumeChanged(double volume);
  41. void onMutedChanged(bool muted);
  42. void onPlaybackSpeedChanged(double speed);
  43. void onErrorOccurred(const QString& error);
  44. void onStatsUpdated(const PlaybackStats& stats);
  45. // 渲染器相关
  46. void onRendererTypeChanged(const QString& type);
  47. void onOpenGLRendererInitialized();
  48. private:
  49. void setupUI();
  50. void connectSignals();
  51. void updateUI();
  52. QString formatTime(qint64 microseconds);
  53. private:
  54. std::unique_ptr<PlayerAdapter> m_playerAdapter;
  55. OpenGLVideoRenderer* m_openGLVideoRenderer;
  56. // UI组件
  57. QLabel* m_fileLabel;
  58. QLabel* m_stateLabel;
  59. QLabel* m_infoLabel;
  60. QLabel* m_timeLabel;
  61. QLabel* m_volumeLabel;
  62. QLabel* m_speedLabel;
  63. QLabel* m_statsLabel;
  64. QPushButton* m_openButton;
  65. QPushButton* m_playPauseButton;
  66. QPushButton* m_stopButton;
  67. QPushButton* m_muteButton;
  68. QSlider* m_positionSlider;
  69. QSlider* m_volumeSlider;
  70. QSlider* m_speedSlider;
  71. bool m_seeking = false;
  72. };
  73. #endif // SIMPLEPLAYERWINDOW_H