#ifndef PLAYERDEMOWINDOW_H #define PLAYERDEMOWINDOW_H #include "AvPlayer/FFmpegVideoPuller.h" #pragma once #include #include #include #include #include #include #include #include #include #include "AudioPlayer.h" #include "AvRecorder/ui/opengl_video_widget.h" #include "VideoPlayer.h" extern "C" { #include } struct sonicStreamStruct; class PlayerDemoWindow : public QWidget { Q_OBJECT public: explicit PlayerDemoWindow(QWidget* parent = nullptr); ~PlayerDemoWindow(); void startPlay(const QString& url); void stopPlay(); void setSpeed(float speed); private slots: void onProgressSliderMoved(int value); void onProgressSliderReleased(); void onSpeedChanged(int index); void onPlayClicked(); private: FFmpegVideoPuller* m_puller = nullptr; AudioPlayer* m_audioPlayer = nullptr; VideoPlayer* m_videoPlayer = nullptr; QThread* m_syncPlayThread = nullptr; std::atomic m_syncPlayRunning{false}; void syncPlayLoop(); OpenGLVideoWidget* m_videoWidget = nullptr; // UI QSlider* m_progressSlider = nullptr; QLabel* m_timeLabel = nullptr; QComboBox* m_speedCombo = nullptr; QPushButton* m_playBtn = nullptr; QCheckBox* m_keepAspectCheck = nullptr; // 进度相关 bool m_sliderPressed = false; double m_firstPts = 0.0; double m_lastPts = 0.0; double m_duration = 0.0; bool m_playing = false; void updateProgress(); QString formatTime(double seconds) const; private: SwrContext* m_swrCtx = nullptr; uint8_t* m_swrBuffer = nullptr; int m_swrBufferSize = 0; }; #endif // PLAYERDEMOWINDOW_H