blob: 4db4811ff61e3d6dfb7f62aa1dbcdb8cf50f265c (
plain) (
blame)
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
|
#include "player.h"
#include "ui_player.h"
#include "about.h"
#include <QMediaPlayer>
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
void Player::mFileDialog()
{
QString mFile;
QMessageBox msgbox;
mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3 *.wav *.ogg)"));
if (mFile == NULL) {
qDebug() << "File cannot be found";
msgbox.setText("File is invalid.");
msgbox.exec();
return;
} else {
mPlayer->setMedia(QUrl::fromLocalFile(mFile));
qDebug() << "Opening" << mFile;
msgbox.setText("This audio file has been loaded.");
msgbox.exec();
return;
}
}
Player::Player(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::Player)
{
ui->setupUi(this);
}
Player::~Player()
{
qInfo() << "Closing AleePlayer...";
mPlayer->deleteLater();
delete ui;
}
void Player::on_actionQuit_triggered()
{
close();
}
void Player::on_playButton_pressed()
{
QPushButton playButton;
if (mPlayer->state() == mPlayer->PlayingState) {
qDebug() << "Pausing music...";
mPlayer->pause();
playButton.setText("Pause");
} else {
qDebug() << "Playing music...";
mPlayer->play();
playButton.setText("Play");
}
}
void Player::on_stopButton_pressed()
{
qInfo() << "Stopping music...";
mPlayer->stop();
}
void Player::on_actionAbout_triggered()
{
qDebug() << "Opening dialog";
About about;
about.exec();
}
void Player::on_mediaButton_pressed()
{
mFileDialog();
}
void Player::on_actionOpen_triggered()
{
mFileDialog();
}
|