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>
24 #include "konq_sound.h"
29 class KonqSoundPlayerImpl
: public KonqSoundPlayer
32 KonqSoundPlayerImpl();
33 virtual ~KonqSoundPlayerImpl() {}
35 virtual bool isMimeTypeKnown(const QString
& mimeType
);
36 virtual void setUrl(const KUrl
&url
);
39 virtual bool isPlaying();
42 Phonon::MediaObject
*m_player
;
45 KonqSoundPlayerImpl::KonqSoundPlayerImpl()
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
)
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()
74 void KonqSoundPlayerImpl::stop()
81 bool KonqSoundPlayerImpl::isPlaying()
84 const bool isPlaying
= (m_player
->state() == Phonon::PlayingState
|| m_player
->state() == Phonon::BufferingState
);
85 kDebug() << isPlaying
;
92 class KonqSoundFactory
: public KLibFactory
95 KonqSoundFactory(QObject
*parent
= 0)
96 : KLibFactory(parent
) {}
97 virtual ~KonqSoundFactory() {}
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();
114 KDE_EXPORT KLibFactory
*init_konq_sound()
116 return new KonqSoundFactory();
120 // vim: ts=4 sw=4 noet