diff options
| -rw-r--r-- | about.ui | 12 | ||||
| -rw-r--r-- | main.cpp | 1 | ||||
| -rw-r--r-- | player.cpp | 20 | ||||
| -rw-r--r-- | player.h | 6 | ||||
| -rw-r--r-- | player.ui | 30 |
5 files changed, 57 insertions, 12 deletions
@@ -17,9 +17,9 @@ <property name="geometry"> <rect> <x>90</x> - <y>60</y> - <width>231</width> - <height>18</height> + <y>80</y> + <width>215</width> + <height>30</height> </rect> </property> <property name="font"> @@ -35,9 +35,9 @@ <property name="geometry"> <rect> <x>30</x> - <y>20</y> - <width>351</width> - <height>31</height> + <y>40</y> + <width>340</width> + <height>30</height> </rect> </property> <property name="font"> @@ -1,5 +1,6 @@ #include <iostream> #include "player.h" +#include <QMessageBox> #include <QApplication> @@ -3,6 +3,7 @@ #include "ui_player.h" #include "about.h" #include <QMediaPlayer> +#include <QFileDialog> Player::Player(QWidget *parent) @@ -24,11 +25,12 @@ void Player::on_actionQuit_triggered() close(); } -void Player::on_pushButton_pressed() +void Player::on_playButton_pressed() { + QPushButton mPlay; + std::cout << "Playing music...\n"; - mPlayer->setMedia(QUrl::fromLocalFile("/home/andrew/Music/4616-werq-by-kevin-macleod.mp3")); - mPlayer->setVolume(50); + mPlayer->play(); } @@ -39,3 +41,15 @@ void Player::on_actionAbout_triggered() about.setModal(true); about.exec(); } + +void Player::on_pauseButton_pressed() +{ + mPlayer->pause(); +} + +void Player::on_pushButton_pressed() +{ + QString mFile; + mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3)")); + mPlayer->setMedia(QUrl::fromLocalFile(mFile)); +} @@ -20,10 +20,14 @@ public: private slots: void on_actionQuit_triggered(); - void on_pushButton_pressed(); + void on_playButton_pressed(); void on_actionAbout_triggered(); + void on_pauseButton_pressed(); + + void on_pushButton_pressed(); + private: Ui::Player *ui; }; @@ -14,10 +14,10 @@ <string>AleePlayer</string> </property> <widget class="QWidget" name="centralwidget"> - <widget class="QPushButton" name="pushButton"> + <widget class="QPushButton" name="playButton"> <property name="geometry"> <rect> - <x>10</x> + <x>20</x> <y>20</y> <width>88</width> <height>34</height> @@ -27,6 +27,32 @@ <string>Play Audio</string> </property> </widget> + <widget class="QPushButton" name="pauseButton"> + <property name="geometry"> + <rect> + <x>130</x> + <y>20</y> + <width>88</width> + <height>34</height> + </rect> + </property> + <property name="text"> + <string>Pause</string> + </property> + </widget> + <widget class="QPushButton" name="pushButton"> + <property name="geometry"> + <rect> + <x>240</x> + <y>20</y> + <width>88</width> + <height>34</height> + </rect> + </property> + <property name="text"> + <string>Set Media</string> + </property> + </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> |
