added music playing, not properly tested
This commit is contained in:
parent
0fb38b5573
commit
a97f223390
@ -38,7 +38,8 @@ SOURCES += main.cpp\
|
||||
aocharmovie.cpp \
|
||||
aoemotebutton.cpp \
|
||||
emotes.cpp \
|
||||
aosfxplayer.cpp
|
||||
aosfxplayer.cpp \
|
||||
aomusicplayer.cpp
|
||||
|
||||
HEADERS += lobby.h \
|
||||
aoimage.h \
|
||||
@ -60,6 +61,7 @@ HEADERS += lobby.h \
|
||||
aocharmovie.h \
|
||||
aoemotebutton.h \
|
||||
bass.h \
|
||||
aosfxplayer.h
|
||||
aosfxplayer.h \
|
||||
aomusicplayer.h
|
||||
|
||||
unix:LIBS += -L/home/omnitroid/lib/bass_linux -lbass
|
||||
unix:LIBS += -L/home/omnitroid/Project/Attorney_Online_2/src -lbass
|
||||
|
52
aomusicplayer.cpp
Normal file
52
aomusicplayer.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include "aomusicplayer.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
|
||||
|
||||
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AOMusicPlayer::play(QString p_song)
|
||||
{
|
||||
|
||||
BASS_ChannelStop(m_stream);
|
||||
|
||||
QString f_path = ao_app->get_music_path(p_song);
|
||||
|
||||
m_stream = BASS_StreamCreateFile(FALSE, f_path.toStdString().c_str(), 0, 0, BASS_STREAM_PRESCAN);
|
||||
|
||||
/*
|
||||
if ((BASS_StreamPutFileData(
|
||||
m_stream,
|
||||
p_path.toStdString().c_str(),
|
||||
BASS_FILEDATA_END
|
||||
) == -1))
|
||||
{
|
||||
qDebug() << "BASS_StreamPutFileData failllled!";
|
||||
qDebug() << "Error: " << QString::number(BASS_ErrorGetCode());
|
||||
}
|
||||
|
||||
if (m_stream == 0)
|
||||
{
|
||||
qDebug() << "OHSHIT something broke. error code: " << QString::number(BASS_ErrorGetCode());
|
||||
}
|
||||
*/
|
||||
|
||||
//m_stream = BASS_StreamCreateFileUser(STREAMFILE_BUFFERPUSH, BASS_STREAM_AUTOFREE, nullptr, p_path.toStdString().c_str());
|
||||
|
||||
if (BASS_ChannelPlay(m_stream, true))
|
||||
qDebug() <<"success.";
|
||||
else
|
||||
qDebug() <<"error";
|
||||
|
||||
qDebug() << QString::number(BASS_ErrorGetCode());
|
||||
}
|
23
aomusicplayer.h
Normal file
23
aomusicplayer.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef AOMUSICPLAYER_H
|
||||
#define AOMUSICPLAYER_H
|
||||
|
||||
#include "bass.h"
|
||||
#include "aoapplication.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class AOMusicPlayer
|
||||
{
|
||||
public:
|
||||
AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||
|
||||
void play(QString p_song);
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
|
||||
HSTREAM m_stream;
|
||||
};
|
||||
|
||||
#endif // AOMUSICPLAYER_H
|
@ -2,12 +2,51 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||
{
|
||||
m_parent = parent;
|
||||
ao_app = p_ao_app;
|
||||
|
||||
std::basic_string<char> path = ao_app->get_sounds_path().toStdString() + "sfx-squee.wav";
|
||||
|
||||
m_stream = BASS_StreamCreateFile(FALSE, path.c_str(), 0, 0, 0);
|
||||
BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AOSfxPlayer::play(QString p_path)
|
||||
{
|
||||
|
||||
BASS_Stop();
|
||||
|
||||
m_stream = BASS_StreamCreateFile(FALSE, p_path.toStdString().c_str(), 0, 0, BASS_STREAM_PRESCAN);
|
||||
|
||||
/*
|
||||
if ((BASS_StreamPutFileData(
|
||||
m_stream,
|
||||
p_path.toStdString().c_str(),
|
||||
BASS_FILEDATA_END
|
||||
) == -1))
|
||||
{
|
||||
qDebug() << "BASS_StreamPutFileData failllled!";
|
||||
qDebug() << "Error: " << QString::number(BASS_ErrorGetCode());
|
||||
}
|
||||
|
||||
if (m_stream == 0)
|
||||
{
|
||||
qDebug() << "OHSHIT something broke. error code: " << QString::number(BASS_ErrorGetCode());
|
||||
}
|
||||
*/
|
||||
|
||||
//m_stream = BASS_StreamCreateFileUser(STREAMFILE_BUFFERPUSH, BASS_STREAM_AUTOFREE, nullptr, p_path.toStdString().c_str());
|
||||
|
||||
if (BASS_ChannelPlay(m_stream, true))
|
||||
qDebug() <<"success.";
|
||||
else
|
||||
qDebug() <<"error";
|
||||
|
||||
BASS_Start();
|
||||
|
||||
qDebug() << QString::number(BASS_ErrorGetCode());
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ class AOSfxPlayer
|
||||
public:
|
||||
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
|
||||
|
||||
void play(QString p_path);
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
|
@ -31,6 +31,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
char_button_mapper = new QSignalMapper(this);
|
||||
|
||||
sfx_player = new QSoundEffect(this);
|
||||
music_player = new AOMusicPlayer(this, ao_app);
|
||||
|
||||
ui_background = new AOImage(this, ao_app);
|
||||
|
||||
@ -1271,7 +1272,7 @@ void Courtroom::handle_song(QStringList *p_contents)
|
||||
if (f_contents.size() < 2)
|
||||
return;
|
||||
|
||||
//T0D0: add audio implementation
|
||||
music_player->play(f_contents.at(0));
|
||||
|
||||
int n_char = f_contents.at(1).toInt();
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "aoscene.h"
|
||||
#include "aomovie.h"
|
||||
#include "aocharmovie.h"
|
||||
#include "aomusicplayer.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
@ -160,6 +161,7 @@ private:
|
||||
QString current_background = "gs4";
|
||||
|
||||
QSoundEffect *sfx_player;
|
||||
AOMusicPlayer *music_player;
|
||||
|
||||
AOImage *ui_background;
|
||||
|
||||
|
12
lobby.cpp
12
lobby.cpp
@ -3,6 +3,7 @@
|
||||
#include "debug_functions.h"
|
||||
#include "aoapplication.h"
|
||||
#include "networkmanager.h"
|
||||
#include "aosfxplayer.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
@ -205,13 +206,22 @@ void Lobby::on_add_to_fav_pressed()
|
||||
|
||||
void Lobby::on_add_to_fav_released()
|
||||
{
|
||||
ui_add_to_fav->set_image("addtofav.png");
|
||||
AOSfxPlayer *sfx = new AOSfxPlayer(this, ao_app);
|
||||
|
||||
QString path = ao_app->get_music_path("Mystery Skulls - Money.mp3");
|
||||
|
||||
qDebug() << "path: " << path;
|
||||
|
||||
sfx->play(path);
|
||||
|
||||
ui_add_to_fav->set_image("addtofav.png");
|
||||
/*
|
||||
//you cant add favorites from favorites m8
|
||||
if (!public_servers_selected)
|
||||
return;
|
||||
|
||||
ao_app->add_favorite_server(ui_server_list->currentRow());
|
||||
*/
|
||||
}
|
||||
|
||||
void Lobby::on_connect_pressed()
|
||||
|
Loading…
Reference in New Issue
Block a user