StelAudioMgr.cpp   StelAudioMgr.cpp 
skipping to change at line 24 skipping to change at line 24
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelAudioMgr.hpp" #include "StelAudioMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#ifdef ENABLE_SOUND #ifdef ENABLE_MEDIA
#include <QMediaPlayer> #include <QMediaPlayer>
StelAudioMgr::StelAudioMgr() StelAudioMgr::StelAudioMgr()
{ {
} }
StelAudioMgr::~StelAudioMgr() StelAudioMgr::~StelAudioMgr()
{ {
foreach(const QString& id, audioObjects.keys()) foreach(const QString& id, audioObjects.keys())
skipping to change at line 57 skipping to change at line 57
QMediaPlayer* sound = new QMediaPlayer(); QMediaPlayer* sound = new QMediaPlayer();
QString path = QFileInfo(filename).absoluteFilePath(); QString path = QFileInfo(filename).absoluteFilePath();
sound->setMedia(QMediaContent(QUrl::fromLocalFile(path))); sound->setMedia(QMediaContent(QUrl::fromLocalFile(path)));
audioObjects[id] = sound; audioObjects[id] = sound;
} }
void StelAudioMgr::playSound(const QString& id) void StelAudioMgr::playSound(const QString& id)
{ {
if (audioObjects.contains(id)) if (audioObjects.contains(id))
{
if (audioObjects[id]!=NULL) if (audioObjects[id]!=NULL)
{ {
// if already playing, stop and play from the start // if already playing, stop and play from the start
if (audioObjects[id]->state()==QMediaPlayer::Playing State) if (audioObjects[id]->state()==QMediaPlayer::Playing State)
audioObjects[id]->stop(); audioObjects[id]->stop();
// otherwise just play it // otherwise just play it
audioObjects[id]->play(); audioObjects[id]->play();
} }
else
qDebug() << "StelAudioMgr: Cannot play sound, " << i
d << "not correctly loaded.";
}
else
qDebug() << "StelAudioMgr: Cannot play sound, " << id << "no
t loaded.";
} }
void StelAudioMgr::pauseSound(const QString& id) void StelAudioMgr::pauseSound(const QString& id)
{ {
if (audioObjects.contains(id)) if (audioObjects.contains(id))
{
if (audioObjects[id]!=NULL) if (audioObjects[id]!=NULL)
audioObjects[id]->pause(); audioObjects[id]->pause();
else
qDebug() << "StelAudioMgr: Cannot pause sound, " <<
id << "not correctly loaded.";
}
else
qDebug() << "StelAudioMgr: Cannot pause sound, " << id << "n
ot loaded.";
} }
void StelAudioMgr::stopSound(const QString& id) void StelAudioMgr::stopSound(const QString& id)
{ {
if (audioObjects.contains(id)) if (audioObjects.contains(id))
{
if (audioObjects[id]!=NULL) if (audioObjects[id]!=NULL)
audioObjects[id]->stop(); audioObjects[id]->stop();
else
qDebug() << "StelAudioMgr: Cannot stop sound, " << i
d << "not correctly loaded.";
}
else
qDebug() << "StelAudioMgr: Cannot stop sound, " << id << "no
t loaded.";
} }
void StelAudioMgr::dropSound(const QString& id) void StelAudioMgr::dropSound(const QString& id)
{ {
if (!audioObjects.contains(id)) if (!audioObjects.contains(id))
{
qDebug() << "StelAudioMgr: Cannot drop sound, " << id << "no
t loaded.";
return; return;
}
if (audioObjects[id]!=NULL) if (audioObjects[id]!=NULL)
{ {
audioObjects[id]->stop(); audioObjects[id]->stop();
delete audioObjects[id]; delete audioObjects[id];
audioObjects.remove(id); audioObjects.remove(id);
} }
} }
qint64 StelAudioMgr::position(const QString& id)
{
if (!audioObjects.contains(id))
{
qDebug() << "StelAudioMgr: Cannot report position for sound,
" << id << "not loaded.";
return(-1);
}
if (audioObjects[id]!=NULL)
{
return audioObjects[id]->position();
}
return (-1);
}
qint64 StelAudioMgr::duration(const QString& id)
{
if (!audioObjects.contains(id))
{
qDebug() << "StelAudioMgr: Cannot report duration for sound,
" << id << "not loaded.";
return(-1);
}
if (audioObjects[id]!=NULL)
{
return audioObjects[id]->duration();
}
return (-1);
}
#else #else
void StelAudioMgr::loadSound(const QString& filename, const QString& id) void StelAudioMgr::loadSound(const QString& filename, const QString& id)
{ {
qWarning() << "This build of Stellarium does not support sound - can not load audio" << QDir::toNativeSeparators(filename) << id; qWarning() << "This build of Stellarium does not support sound - can not load audio" << QDir::toNativeSeparators(filename) << id;
} }
StelAudioMgr::StelAudioMgr() {} StelAudioMgr::StelAudioMgr() {}
StelAudioMgr::~StelAudioMgr() {;} StelAudioMgr::~StelAudioMgr() {;}
void StelAudioMgr::playSound(const QString&) {;} void StelAudioMgr::playSound(const QString&) {;}
void StelAudioMgr::pauseSound(const QString&) {;} void StelAudioMgr::pauseSound(const QString&) {;}
void StelAudioMgr::stopSound(const QString&) {;} void StelAudioMgr::stopSound(const QString&) {;}
void StelAudioMgr::dropSound(const QString&) {;} void StelAudioMgr::dropSound(const QString&) {;}
qint64 StelAudioMgr::position(const QString&){return -1;}
qint64 StelAudioMgr::duration(const QString&){return -1;}
#endif #endif
 End of changes. 11 change blocks. 
1 lines changed or deleted 61 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/