forked from AttorneyOnline/AO2-Client
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaomusicplayer.cpp
More file actions
39 lines (29 loc) · 910 Bytes
/
aomusicplayer.cpp
File metadata and controls
39 lines (29 loc) · 910 Bytes
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
#include "aomusicplayer.h"
#include <string.h>
#include <QDebug>
AOMusicPlayer::AOMusicPlayer(QObject *p_parent, AOApplication *p_ao_app)
: AOAbstractPlayer(p_parent, p_ao_app)
{}
void AOMusicPlayer::play(QString p_file)
{
QString f_file = ao_app->get_music_path(p_file);
stop();
m_file = f_file;
try { // create new song
AOBassHandle *handle = new AOBassHandle(m_file, false, this);
connect(this, &AOMusicPlayer::new_volume, handle, &AOBassHandle::set_volume);
connect(this, &AOMusicPlayer::stopping, handle, &AOBassHandle::stop);
// delete previous
if (m_handle)
delete m_handle;
m_handle = handle;
m_handle->set_volume(get_volume());
m_handle->play();
} catch(const std::exception &e_exception) {
qDebug() << e_exception.what();
}
}
void AOMusicPlayer::stop()
{
emit stopping();
}