| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef MEDIAPLAYER_H |
| 4 | #define MEDIAPLAYER_H |
| 5 | |
| 6 | #include "gui/mediaplayer/playerbackend.h" |
| 7 | #include "gui/tabcontent.h" |
| 8 | |
| 9 | #include "ui_mediaplayer.h" |
| 10 | |
| 11 | class MediaPlayer : public TabContent { |
| 12 | Q_OBJECT |
| 13 | |
| 14 | public: |
| 15 | explicit MediaPlayer(QWidget* parent = nullptr); |
| 16 | virtual ~MediaPlayer(); |
| 17 | |
| 18 | virtual WebBrowser* webBrowser() const; |
| 19 | |
| 20 | public slots: |
| 21 | void playUrl(const QString& url); |
| 22 | |
| 23 | private slots: |
| 24 | void playPause(); |
| 25 | void stop(); |
| 26 | void download(); |
| 27 | void muteUnmute(); |
| 28 | |
| 29 | // NOTE: 100 means standard speed, above that value means faster, below means slower. |
| 30 | void setSpeed(int speed); |
| 31 | |
| 32 | // NOTE: Volume is from 0 to 100 taken directly from slider or |
| 33 | // elsewhere. |
| 34 | void setVolume(int volume); |
| 35 | |
| 36 | // NOTE: We seek by second. |
| 37 | void seek(int position); |
| 38 | |
| 39 | void showPlayerNormal(); |
| 40 | void showPlayerFullscreen(); |
| 41 | void escapeFromFullscreen(); |
| 42 | void switchFullScreen(bool send_event_to_backend); |
| 43 | |
| 44 | void hideControls(); |
| 45 | void showControls(); |
| 46 | |
| 47 | void onFullscreenChanged(bool fullscreen); |
| 48 | void onMutedChanged(bool muted); |
| 49 | void onSpeedChanged(int speed); |
| 50 | void onDurationChanged(int duration); |
| 51 | void onPositionChanged(int position); |
| 52 | void onVolumeChanged(int volume); |
| 53 | void onErrorOccurred(const QString& error_string); |
| 54 | void onStatusChanged(const QString& status); |
| 55 | void onPlaybackStateChanged(PlayerBackend::PlaybackState state); |
| 56 | void onAudioAvailable(bool available); |
| 57 | void onVideoAvailable(bool available); |
| 58 | void onSeekableChanged(bool seekable); |
| 59 | |
| 60 | signals: |
| 61 | void urlDownloadRequested(const QUrl& url); |
| 62 | void closed(); |
| 63 | |
| 64 | private: |
| 65 | bool isFullScreen() const; |
| 66 | |
| 67 | void updateTimeAndProgress(int progress, int total); |
| 68 | void setupIcons(); |
| 69 | |
| 70 | void createBackendConnections(); |
| 71 | void createConnections(); |
| 72 | |
| 73 | private: |
| 74 | Ui::MediaPlayer m_ui; |
| 75 | |
| 76 | PlayerBackend* m_backend; |
| 77 | QIcon m_iconPlay; |
| 78 | QIcon m_iconPause; |
| 79 | QIcon m_iconMute; |
| 80 | QIcon m_iconUnmute; |
| 81 | bool m_muted; |
| 82 | }; |
| 83 | |
| 84 | #endif // MEDIAPLAYER_H |