2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
10 #include "audioplayer.h"
12 #include <Phonon/MediaObject>
13 #include <KStandardDirs>
15 AudioPlayer::AudioPlayer(QObject
* parent
)
19 m_dir
= KStandardDirs::locate("appdata", "sounds/");
22 void AudioPlayer::play(Sea::Player player
, const HitInfo
& info
)
26 if (info
.type
== HitInfo::HIT
) {
27 if (info
.shipDestroyed
) {
28 sound
= "ship-sink.ogg";
31 sound
= player
== Sea::PLAYER_A
?
32 "ship-player1-shoot.ogg" :
33 "ship-player2-shoot.ogg";
37 sound
= "ship-player-shoot-water.ogg";
40 if (!sound
.isEmpty()) {
41 kDebug() << "****** playing" << m_dir
.filePath(sound
);
42 m_media
->setCurrentSource(m_dir
.filePath(sound
));
48 void AudioPlayer::setActive(bool value
)
52 m_media
= Phonon::createPlayer(Phonon::GameCategory
);
62 #include "audioplayer.moc"