-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
53 lines (49 loc) · 1.42 KB
/
mainwindow.cpp
File metadata and controls
53 lines (49 loc) · 1.42 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
#include <QDebug>
#include <QDir>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
currentFile = "/home/luke/Music/Ott/Mir/02 Adrift In Hilbert Space.mp3"; // for faster iteration
// currentFile = ""
ui->label->setText("No File Selected");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionLoad_triggered()
{
currentFile = QFileDialog::getOpenFileName(this,
"open an audio file",
QString(),
QString(),
nullptr,
QFileDialog::DontUseNativeDialog);
ui->label->setText(currentFile);
ui->openGLWidget->newAudioFileFlag();
}
void MainWindow::on_playButton_clicked()
{
if (QFile(currentFile).exists())
{
player.setMedia(QUrl::fromLocalFile(currentFile));
player.setVolume(50);
player.play();
} else {
ui->label->setText("Can't Play File");
}
if (probe.setSource(&player))
{
connect(&probe, SIGNAL(audioBufferProbed(QAudioBuffer)),
ui->openGLWidget, SLOT(processAudioBuffer(QAudioBuffer)));
}
}
void MainWindow::on_stopButton_clicked()
{
player.stop();
}