#ifndef PLAYERDEMOWINDOW_H #define PLAYERDEMOWINDOW_H #pragma once #include #include #include #include #include #include #include #include "AvRecorder/ui/opengl_video_widget.h" #include "Avplayer/FFmpegVideoPuller.h" extern "C" { #include } class PlayerDemoWindow : public QWidget { Q_OBJECT public: explicit PlayerDemoWindow(QWidget* parent = nullptr); ~PlayerDemoWindow(); void startPlay(const QString& url); private slots: void onProgressSliderMoved(int value); void onProgressSliderReleased(); void onSpeedChanged(int index); void onPlayClicked(); private: FFmpegVideoPuller* m_puller = nullptr; OpenGLVideoWidget* m_videoWidget = nullptr; // 音频相关 QAudioOutput* m_audioOutput = nullptr; QIODevice* m_audioDevice = nullptr; int m_audioSampleRate = 0; int m_audioChannels = 0; AVSampleFormat m_audioFormat = AV_SAMPLE_FMT_NONE; // UI QSlider* m_progressSlider = nullptr; QLabel* m_timeLabel = nullptr; QComboBox* m_speedCombo = nullptr; QPushButton* m_playBtn = nullptr; // 进度相关 bool m_sliderPressed = false; double m_firstPts = 0.0; double m_lastPts = 0.0; double m_duration = 0.0; bool m_playing; void initAudio(const AVFrame* frame); void playAudioFrame(AVFrame* frame); void updateProgress(); QString formatTime(double seconds) const; private: SwrContext* m_swrCtx = nullptr; uint8_t* m_swrBuffer = nullptr; int m_swrBufferSize = 0; }; #endif // PLAYERDEMOWINDOW_H