Added Qt Multimedia support in order to replace Phonon. Currently does not work on Mac.
This commit is contained in:
@@ -41,6 +41,10 @@
|
||||
|
||||
#include "JAudio.h"
|
||||
#include "JMP3.h"
|
||||
#elif defined QT_CONFIG
|
||||
#include "QMediaPlayer"
|
||||
#include "QMediaPlaylist"
|
||||
#include "QSoundEffect"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FMOD
|
||||
@@ -82,6 +86,10 @@ public:
|
||||
SLPlayItf playInterface;
|
||||
SLSeekItf seekInterface;
|
||||
SLVolumeItf musicVolumeInterface;
|
||||
#elif defined QT_CONFIG
|
||||
QMediaPlaylist* playlist;
|
||||
QMediaPlayer* player;
|
||||
string fullpath;
|
||||
#else
|
||||
void* mTrack;
|
||||
#endif //WITH_FMOD
|
||||
@@ -97,8 +105,10 @@ class JSample
|
||||
~JSample();
|
||||
|
||||
unsigned long fileSize();
|
||||
|
||||
#if defined (PSP)
|
||||
#ifdef QT_CONFIG
|
||||
QSoundEffect effect;
|
||||
void* mSample;
|
||||
#elif defined (PSP)
|
||||
WAVDATA *mSample;
|
||||
#elif defined (IOS)
|
||||
std::string filename;
|
||||
@@ -242,9 +252,10 @@ protected:
|
||||
void DestroySoundSystem();
|
||||
|
||||
private:
|
||||
|
||||
#ifdef PSP
|
||||
JMusic *mCurrentMusic;
|
||||
JSample *mCurrentSample;
|
||||
#endif
|
||||
|
||||
int mVolume;
|
||||
int mMusicVolume;
|
||||
@@ -256,3 +267,4 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
JMusic::JMusic()
|
||||
#ifdef USE_PHONON
|
||||
: mOutput(0), mMediaObject(0)
|
||||
#elif defined QT_CONFIG
|
||||
: playlist(0), player(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
@@ -40,7 +42,12 @@ int JMusic::getPlayTime(){
|
||||
|
||||
JMusic::~JMusic()
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
#ifdef QT_CONFIG
|
||||
if(player)
|
||||
delete player;
|
||||
if(playlist)
|
||||
delete playlist;
|
||||
#elif defined USE_PHONON
|
||||
if(mOutput)
|
||||
delete mOutput;
|
||||
if(mMediaObject)
|
||||
@@ -144,8 +151,20 @@ void JSoundSystem::DestroySoundSystem()
|
||||
|
||||
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
JMusic* music = new JMusic();
|
||||
JMusic* music = NULL;
|
||||
#ifdef QT_CONFIG
|
||||
music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
music->player = new QMediaPlayer;
|
||||
music->player->setVolume(100);
|
||||
music->playlist = new QMediaPlaylist;
|
||||
music->fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
||||
music->playlist->addMedia(QUrl(music->fullpath.c_str()));
|
||||
music->playlist->setCurrentIndex(0);
|
||||
}
|
||||
#elif defined USE_PHONON
|
||||
music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
music->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||
@@ -155,9 +174,8 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
Phonon::Path mediapath = Phonon::createPath(music->mMediaObject, music->mOutput);
|
||||
Q_ASSERT(mediapath.isValid());
|
||||
}
|
||||
return music;
|
||||
#elif (defined WITH_FMOD)
|
||||
JMusic* music = new JMusic();
|
||||
music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
@@ -172,17 +190,29 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
fileSystem->CloseFile();
|
||||
}
|
||||
}
|
||||
return music;
|
||||
#else
|
||||
cerr << fileName << endl;
|
||||
return NULL;
|
||||
#endif
|
||||
return music;
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
#ifdef QT_CONFIG
|
||||
if(music && music->player && music->playlist)
|
||||
{
|
||||
if(looping)
|
||||
music->playlist->setPlaybackMode(QMediaPlaylist::Loop);
|
||||
|
||||
// music->player->setPlaylist(music->playlist);
|
||||
music->player->setMedia(QUrl(music->fullpath.c_str()));
|
||||
music->player->play();
|
||||
stringstream stream;
|
||||
stream << "Player state : " << music->player->state();
|
||||
DebugTrace(stream.str());
|
||||
}
|
||||
#elif USE_PHONON
|
||||
if (music && music->mMediaObject && music->mOutput)
|
||||
{
|
||||
if(looping)
|
||||
@@ -213,7 +243,12 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
|
||||
void JSoundSystem::StopMusic(JMusic *music)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
#ifdef QT_CONFIG
|
||||
if (music && music->player && music->playlist)
|
||||
{
|
||||
music->player->stop();
|
||||
}
|
||||
#elif defined USE_PHONON
|
||||
if (music && music->mMediaObject && music->mOutput)
|
||||
{
|
||||
music->mMediaObject->stop();
|
||||
@@ -264,8 +299,19 @@ void JSoundSystem::SetSfxVolume(int volume){
|
||||
|
||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
{
|
||||
#if (defined USE_PHONON)
|
||||
JSample* sample = new JSample();
|
||||
JSample* sample = NULL;
|
||||
#ifdef QT_CONFIG
|
||||
sample = new JSample();
|
||||
if (sample)
|
||||
{
|
||||
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
||||
sample->effect.setSource(QUrl::fromLocalFile(fullpath.c_str()));
|
||||
sample->effect.setLoopCount(0);
|
||||
sample->effect.setVolume(1);
|
||||
sample->mSample = &(sample->effect);
|
||||
}
|
||||
#elif (defined USE_PHONON)
|
||||
sample = new JSample();
|
||||
if (sample)
|
||||
{
|
||||
sample->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||
@@ -275,9 +321,8 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
Phonon::Path mediapath = Phonon::createPath(sample->mMediaObject, sample->mOutput);
|
||||
Q_ASSERT(mediapath.isValid());
|
||||
}
|
||||
return sample;
|
||||
#elif (defined WITH_FMOD)
|
||||
JSample* sample = new JSample();
|
||||
sample = new JSample();
|
||||
if (sample)
|
||||
{
|
||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||
@@ -294,17 +339,21 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
sample->mSample = NULL;
|
||||
|
||||
}
|
||||
return sample;
|
||||
#else
|
||||
cerr << fileName << endl;
|
||||
return NULL;
|
||||
#endif
|
||||
return sample;
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::PlaySample(JSample *sample)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
#ifdef QT_CONFIG
|
||||
if(sample)
|
||||
{
|
||||
sample->effect.play();
|
||||
}
|
||||
#elif defined USE_PHONON
|
||||
if (sample && sample->mMediaObject && sample->mOutput)
|
||||
{
|
||||
sample->mOutput->setVolume((qreal)mSampleVolume*0.01);
|
||||
|
||||
@@ -17,7 +17,7 @@ else:CONFIG(graphics, graphics|console){
|
||||
folder_01.source = qml/QmlWagic
|
||||
folder_01.target = /usr/share
|
||||
DEPLOYMENTFOLDERS = folder_01
|
||||
QT += core gui opengl network
|
||||
QT += core gui opengl network multimedia
|
||||
QT -= declarative quick qml
|
||||
#maemo5:DEFINES += QT_WIDGET
|
||||
DEFINES += QT_WIDGET
|
||||
@@ -46,6 +46,7 @@ CONFIG(graphics, graphics|console){
|
||||
../../JGE/src/qt/corewrapper.cpp\
|
||||
../../JGE/src/Qtmain.cpp\
|
||||
../../JGE/src/JMD2Model.cpp\
|
||||
../../JGE/src/pc/JSfx.cpp\
|
||||
../../JGE/src/pc/JGfx.cpp
|
||||
}
|
||||
else:CONFIG(console, graphics|console){
|
||||
|
||||
@@ -303,7 +303,6 @@ SOURCES += \
|
||||
../../JGE/src/JSpline.cpp\
|
||||
../../JGE/src/JNetwork.cpp\
|
||||
../../JGE/src/pc/JSocket.cpp\
|
||||
../../JGE/src/pc/JSfx.cpp\
|
||||
../../JGE/src/JSprite.cpp\
|
||||
../../JGE/src/Vector2D.cpp\
|
||||
../../JGE/src/tinyxml/tinystr.cpp\
|
||||
|
||||
Reference in New Issue
Block a user