add more spacing
[personal-kdebase.git] / apps / lib / konq / konq_sound.cc
blobe44a42debdb3af34cbc1c76954d20d80cb22c71b
1 /* This file is part of the KDE Project
2 Copyright (c) 2001 Malte Starostik <malte@kde.org>
3 Copyright (c) 2006 Matthias Kretz <kretz@kde.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include <phonon/mediaobject.h>
21 #include <phonon/backendcapabilities.h>
22 #include <kdebug.h>
24 #include "konq_sound.h"
25 #include <kurl.h>
27 using namespace std;
29 class KonqSoundPlayerImpl : public KonqSoundPlayer
31 public:
32 KonqSoundPlayerImpl();
33 virtual ~KonqSoundPlayerImpl() {}
35 virtual bool isMimeTypeKnown(const QString& mimeType);
36 virtual void setUrl(const KUrl &url);
37 virtual void play();
38 virtual void stop();
39 virtual bool isPlaying();
41 private:
42 Phonon::MediaObject *m_player;
45 KonqSoundPlayerImpl::KonqSoundPlayerImpl()
46 : m_player(0)
50 bool KonqSoundPlayerImpl::isMimeTypeKnown(const QString& mimeType)
52 kDebug() << mimeType << Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
53 return Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
56 void KonqSoundPlayerImpl::setUrl(const KUrl &url)
58 kDebug() ;
59 if (!m_player) {
60 kDebug() << "create AudioPlayer";
61 m_player = Phonon::createPlayer(Phonon::MusicCategory);
62 m_player->setParent(this);
64 m_player->setCurrentSource(url);
67 void KonqSoundPlayerImpl::play()
69 kDebug() ;
70 if (m_player)
71 m_player->play();
74 void KonqSoundPlayerImpl::stop()
76 kDebug() ;
77 if (m_player)
78 m_player->stop();
81 bool KonqSoundPlayerImpl::isPlaying()
83 if (m_player) {
84 const bool isPlaying = (m_player->state() == Phonon::PlayingState || m_player->state() == Phonon::BufferingState);
85 kDebug() << isPlaying;
86 return isPlaying;
88 kDebug() << false;
89 return false;
92 class KonqSoundFactory : public KLibFactory
94 public:
95 KonqSoundFactory(QObject *parent = 0)
96 : KLibFactory(parent) {}
97 virtual ~KonqSoundFactory() {}
99 protected:
100 virtual QObject *createObject(QObject * = 0,
101 const char *className = "QObject", const QStringList &args = QStringList());
104 QObject *KonqSoundFactory::createObject(QObject *,
105 const char *className, const QStringList &)
107 if (qstrcmp(className, "KonqSoundPlayer") == 0)
108 return new KonqSoundPlayerImpl();
109 return 0;
112 extern "C"
114 KDE_EXPORT KLibFactory *init_konq_sound()
116 return new KonqSoundFactory();
120 // vim: ts=4 sw=4 noet