avplayerwidget.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. // 兼容旧接口:基于房间ID控制播放
  25. void stopPlay();
  26. void setPlayRoomId(const QString &id);
  27. void startPlay();
  28. private Q_SLOTS:
  29. void ptsChangedSlot(unsigned int duration);
  30. void durationChangedSlot(unsigned int pts);
  31. void terminateSlot();
  32. // UI控制槽函数
  33. void onPlayButtonClicked();
  34. void onStopButtonClicked();
  35. void onPauseButtonClicked();
  36. void onTestPlayButtonClicked();
  37. void onVolumeChanged(int volume);
  38. // 视频帧处理
  39. void onFrameChanged(QSharedPointer<VideoFrame> frame);
  40. signals:
  41. void playStateChanged(bool isPlaying);
  42. private:
  43. void setupUI();
  44. void connectSignals();
  45. AVPlayer *m_player;
  46. AVOpenGLWidget *m_openglWidget;
  47. // UI组件
  48. QVBoxLayout *m_mainLayout;
  49. QHBoxLayout *m_controlLayout;
  50. QPushButton *m_playButton;
  51. QPushButton *m_pauseButton;
  52. QPushButton *m_stopButton;
  53. QPushButton *m_testPlayButton;
  54. QLabel *m_timeLabel;
  55. QSlider *m_volumeSlider;
  56. QLineEdit *m_urlEdit;
  57. bool m_isPlaying;
  58. bool m_isPaused;
  59. };
  60. #endif // AVPLAYERWIDGET_H