-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
media-control.hpp
68 lines (60 loc) · 1.67 KB
/
media-control.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include <QTimer>
#include <obs.hpp>
#include <qicon.h>
#include <QLabel>
#include <QPushButton>
#include "media-slider.hpp"
class MediaControl : public QWidget {
Q_OBJECT
private:
OBSWeakSource weakSource;
QLabel *nameLabel;
MediaSlider *slider;
QPushButton *restartButton;
QPushButton *playPauseButton;
QPushButton *previousButton;
QPushButton *stopButton;
QPushButton *nextButton;
QLabel *timeLabel;
QLabel *durationLabel;
QTimer *timer;
QTimer *seekTimer;
int seek;
int lastSeek;
bool prevPaused = false;
bool showTimeDecimals = false;
bool showTimeRemaining = false;
QString FormatSeconds(float totalSeconds);
void StartTimer();
void StopTimer();
void RefreshControls();
void timeContextMenuRequested();
static void OBSMediaStopped(void *data, calldata_t *calldata);
static void OBSMediaPlay(void *data, calldata_t *calldata);
static void OBSMediaPause(void *data, calldata_t *calldata);
static void OBSMediaStarted(void *data, calldata_t *calldata);
private slots:
void on_restartButton_clicked();
void on_playPauseButton_clicked();
void on_stopButton_clicked();
void on_nextButton_clicked();
void on_previousButton_clicked();
void SliderClicked();
void SliderReleased();
void SliderHovered(int val);
void SliderMoved(int val);
void SetSliderPosition();
void SetPlayingState();
void SetPausedState();
void SetRestartState();
void SeekTimerCallback();
public:
explicit MediaControl(OBSWeakSource source, bool showMs,
bool showTimeRemaining);
~MediaControl();
OBSWeakSource GetSource();
void SetSource(OBSWeakSource source);
bool GetShowMs() { return showTimeDecimals; }
bool GetShowTimeRemaining() { return showTimeRemaining; }
};