| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef SIMPLEPLAYERWINDOW_H
- #define SIMPLEPLAYERWINDOW_H
- #include <QApplication>
- #include <QDebug>
- #include <QFileDialog>
- #include <QHBoxLayout>
- #include <QLabel>
- #include <QMainWindow>
- #include <QMessageBox>
- #include <QPushButton>
- #include <QSlider>
- #include <QTimer>
- #include <QVBoxLayout>
- #include "player_adapter.h"
- #include "video_renderer.h"
- using namespace av::player;
- /**
- * @brief 简单的播放器UI示例
- *
- * 这个类展示了如何使用新的PlayerAdapter来构建播放器UI
- */
- class SimplePlayerWindow : public QMainWindow
- {
- Q_OBJECT
- public:
- explicit SimplePlayerWindow(QWidget* parent = nullptr);
- ~SimplePlayerWindow();
- private slots:
- void openFile();
- void playPause();
- void stop();
- void seek();
- void setVolume();
- void toggleMute();
- void setPlaybackSpeed();
- // 播放器事件处理
- void onStateChanged(PlayerState state);
- void onMediaInfoChanged(const MediaInfo& info);
- void onPositionChanged(qint64 position);
- void onVolumeChanged(double volume);
- void onMutedChanged(bool muted);
- void onPlaybackSpeedChanged(double speed);
- void onErrorOccurred(const QString& error);
- void onStatsUpdated(const PlaybackStats& stats);
- private:
- void setupUI();
- void connectSignals();
- void updateUI();
- QString formatTime(qint64 microseconds);
- private:
- std::unique_ptr<PlayerAdapter> m_playerAdapter;
- VideoRenderer* m_videoRenderer;
- // UI组件
- QLabel* m_fileLabel;
- QLabel* m_stateLabel;
- QLabel* m_infoLabel;
- QLabel* m_timeLabel;
- QLabel* m_volumeLabel;
- QLabel* m_speedLabel;
- QLabel* m_statsLabel;
- QPushButton* m_openButton;
- QPushButton* m_playPauseButton;
- QPushButton* m_stopButton;
- QPushButton* m_muteButton;
- QSlider* m_positionSlider;
- QSlider* m_volumeSlider;
- QSlider* m_speedSlider;
- bool m_seeking = false;
- };
- #endif // SIMPLEPLAYERWINDOW_H
|