avplayerwidget.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef AVPLAYERWIDGET_H
  2. #define AVPLAYERWIDGET_H
  3. #include <QWidget>
  4. #include <QPushButton>
  5. #include <QVBoxLayout>
  6. #include <QHBoxLayout>
  7. #include <QLabel>
  8. #include <QSlider>
  9. #include <QLineEdit>
  10. #include <QSharedPointer>
  11. class AVPlayer;
  12. class AVOpenGLWidget;
  13. class VideoFrame;
  14. class AVPlayerWidget : public QWidget
  15. {
  16. Q_OBJECT
  17. public:
  18. explicit AVPlayerWidget(QWidget *parent = nullptr);
  19. ~AVPlayerWidget();
  20. void play(const QString &url);
  21. void stop();
  22. void pause();
  23. void resume();
  24. private Q_SLOTS:
  25. void ptsChangedSlot(unsigned int duration);
  26. void durationChangedSlot(unsigned int pts);
  27. void terminateSlot();
  28. // UI控制槽函数
  29. void onPlayButtonClicked();
  30. void onStopButtonClicked();
  31. void onPauseButtonClicked();
  32. void onTestPlayButtonClicked();
  33. void onVolumeChanged(int volume);
  34. // 视频帧处理
  35. void onFrameChanged(QSharedPointer<VideoFrame> frame);
  36. signals:
  37. void playStateChanged(bool isPlaying);
  38. private:
  39. void setupUI();
  40. void connectSignals();
  41. AVPlayer *m_player;
  42. AVOpenGLWidget *m_openglWidget;
  43. // UI组件
  44. QVBoxLayout *m_mainLayout;
  45. QHBoxLayout *m_controlLayout;
  46. QPushButton *m_playButton;
  47. QPushButton *m_pauseButton;
  48. QPushButton *m_stopButton;
  49. QPushButton *m_testPlayButton;
  50. QLabel *m_timeLabel;
  51. QSlider *m_volumeSlider;
  52. QLineEdit *m_urlEdit;
  53. bool m_isPlaying;
  54. bool m_isPaused;
  55. };
  56. #endif // AVPLAYERWIDGET_H