This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcue.cpp
102 lines (85 loc) · 3.01 KB
/
cue.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef CUE_C
#define CUE_C
#include <QObject> // for popup function
#include <QMessageBox> // for popup function
#include <QDebug> // uhhhh, for debuging
#include <QFileDialog> // used in ActionPlayAudioFile's constructor
#include "cue.h"
void Cue::read(const QJsonObject &json) {
note = json["note"].toString();
}
void Cue::write(QJsonObject &json) const {
json["note"] = note;
json["type"] = cue_type;
}
int ActionPopup::go() {
QMessageBox box;
box.setWindowTitle(title);
box.setText(text);
return box.exec(); // will stop execution until dismissed
}
int ActionPopup::show_ui(Ui::MainWindow * ui) {
ui->actionPopupTextEntry->setText(text);
ui->actionPopupTitleEntry->setText(title);
ui->actionPopupSettings->show();
return 1;
}
void ActionPopup::hide_ui(Ui::MainWindow *ui) {
ui->actionPopupSettings->hide();
}
void ActionPopup::read(const QJsonObject &json) {
Cue::read(json); // call the base class's read function
text = json["text"].toString();
title = json["title"].toString();
}
void ActionPopup::write(QJsonObject &json) const {
Cue::write(json);
json["text"] = text;
json["title"] = title;
}
// ActionPlayAudioFile is not blocking, the next cue can begin while the file is playing
ActionPlayAudioFile::ActionPlayAudioFile() {
player->setVolume(50); // default volume
}
QString ActionPlayAudioFile::askAudioFileName() {
audio_file_name = QFileDialog::getOpenFileName(nullptr, // parent
QObject::tr("Select Audio File"), // caption
QString(), // directory
QObject::tr("Audio files (*.mp3 *.aiff *.au. *avi *midi *.snd *wav)")); // filter
return audio_file_name;
}
int ActionPlayAudioFile::go() {
player->setMedia(QUrl::fromLocalFile(audio_file_name));
//player->Flag = QMediaPlayer::LowLatency;
// if we are before the begin_time, go to the begin time
if (player->position() < begin_time) player->setPosition((qint64)begin_time);
player->play(); // not blocking
return 1;
}
int ActionPlayAudioFile::show_ui(Ui::MainWindow * ui) {
ui->action_play_audio_file_gui->show(); // shows the ui
ui->action_play_audio_file_gui->start(this); // give ponter to self to the ui
return 1;
}
void ActionPlayAudioFile::hide_ui(Ui::MainWindow *ui) {
ui->action_play_audio_file_gui->hide();
ui->action_play_audio_file_gui->stop();
}
void ActionPlayAudioFile::read(const QJsonObject &json) {
Cue::read(json);
muted = json["muted"].toBool();
audio_file_name = json["audio_file_name"].toString();
player->setVolume(json["volume"].toInt());
begin_time = json["begin_time"].toInt();
stop_time = json["stop_time"].toInt();
}
void ActionPlayAudioFile::write(QJsonObject &json) const {
Cue::write(json);
json["muted"] = muted;
json["audio_file_name"] = audio_file_name;
json["volume"] = player->volume();
json["begin_time"] = begin_time;
json["stop_time"] = stop_time;
}
// end ActionPlayAudioFile child class functions
#endif // CUE_C