StelAudioMgr.cpp   StelAudioMgr.cpp 
skipping to change at line 20 skipping to change at line 20
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#ifdef ENABLE_SOUND
#include <QMediaPlayer>
StelAudioMgr::StelAudioMgr() StelAudioMgr::StelAudioMgr()
{ {
} }
#ifdef HAVE_QT_PHONON
StelAudioMgr::~StelAudioMgr() StelAudioMgr::~StelAudioMgr()
{ {
foreach(QString id, audioObjects.keys()) foreach(const QString& id, audioObjects.keys())
{ {
dropSound(id); dropSound(id);
} }
} }
void StelAudioMgr::loadSound(const QString& filename, const QString& id) void StelAudioMgr::loadSound(const QString& filename, const QString& id)
{ {
if (audioObjects.contains(id)) if (audioObjects.contains(id))
{ {
qWarning() << "Audio object with ID" << id << "already exist s, dropping it"; qWarning() << "Audio object with ID" << id << "already exist s, dropping it";
dropSound(id); dropSound(id);
} }
Phonon::MediaObject* sound = Phonon::createPlayer(Phonon::GameCatego QMediaPlayer* sound = new QMediaPlayer();
ry, Phonon::MediaSource(filename)); QString path = QFileInfo(filename).absoluteFilePath();
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() == Phonon::PlayingStat e) 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();
} }
} }
void StelAudioMgr::pauseSound(const QString& id) void StelAudioMgr::pauseSound(const QString& id)
{ {
if (audioObjects.contains(id)) if (audioObjects.contains(id))
skipping to change at line 88 skipping to change at line 94
if (!audioObjects.contains(id)) if (!audioObjects.contains(id))
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);
} }
} }
#else // HAVE_QT_PHONON #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() {;}
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&) {;}
#endif // HAVE_QT_PHONON #endif
 End of changes. 9 change blocks. 
6 lines changed or deleted 12 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/