• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libkonq

konq_sound.cc

Go to the documentation of this file.
00001 /* This file is part of the KDE Project
00002    Copyright (c) 2001 Malte Starostik <malte@kde.org>
00003    Copyright (c) 2006 Matthias Kretz <kretz@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <phonon/mediaobject.h>
00021 #include <phonon/backendcapabilities.h>
00022 #include <kdebug.h>
00023 
00024 #include "konq_sound.h"
00025 #include <kurl.h>
00026 
00027 using namespace std;
00028 
00029 class KonqSoundPlayerImpl : public KonqSoundPlayer
00030 {
00031 public:
00032     KonqSoundPlayerImpl();
00033     virtual ~KonqSoundPlayerImpl() {}
00034 
00035     virtual bool isMimeTypeKnown(const QString& mimeType);
00036     virtual void setUrl(const KUrl &url);
00037     virtual void play();
00038     virtual void stop();
00039     virtual bool isPlaying();
00040 
00041 private:
00042     Phonon::MediaObject *m_player;
00043 };
00044 
00045 KonqSoundPlayerImpl::KonqSoundPlayerImpl()
00046     : m_player(0)
00047 {
00048 }
00049 
00050 bool KonqSoundPlayerImpl::isMimeTypeKnown(const QString& mimeType)
00051 {
00052     kDebug() << mimeType << Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
00053     return Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
00054 }
00055 
00056 void KonqSoundPlayerImpl::setUrl(const KUrl &url)
00057 {
00058     kDebug() ;
00059     if (!m_player) {
00060         kDebug() << "create AudioPlayer";
00061         m_player = Phonon::createPlayer(Phonon::MusicCategory);
00062         m_player->setParent(this);
00063     }
00064     m_player->setCurrentSource(url);
00065 }
00066 
00067 void KonqSoundPlayerImpl::play()
00068 {
00069     kDebug() ;
00070     if (m_player)
00071         m_player->play();
00072 }
00073 
00074 void KonqSoundPlayerImpl::stop()
00075 {
00076     kDebug() ;
00077     if (m_player)
00078         m_player->stop();
00079 }
00080 
00081 bool KonqSoundPlayerImpl::isPlaying()
00082 {
00083     if (m_player) {
00084         const bool isPlaying = (m_player->state() == Phonon::PlayingState || m_player->state() == Phonon::BufferingState);
00085         kDebug() << isPlaying;
00086         return isPlaying;
00087     }
00088     kDebug() << false;
00089     return false;
00090 }
00091 
00092 class KonqSoundFactory : public KLibFactory
00093 {
00094 public:
00095     KonqSoundFactory(QObject *parent = 0)
00096         : KLibFactory(parent) {}
00097     virtual ~KonqSoundFactory() {}
00098 
00099 protected:
00100     virtual QObject *createObject(QObject * = 0,
00101         const char *className = "QObject", const QStringList &args = QStringList());
00102 };
00103 
00104 QObject *KonqSoundFactory::createObject(QObject *,
00105     const char *className, const QStringList &)
00106 {
00107     if (qstrcmp(className, "KonqSoundPlayer") == 0)
00108         return new KonqSoundPlayerImpl();
00109     return 0;
00110 }
00111 
00112 extern "C"
00113 {
00114     KDE_EXPORT KLibFactory *init_konq_sound()
00115     {
00116         return new KonqSoundFactory();
00117     }
00118 }
00119 
00120 // vim: ts=4 sw=4 noet

libkonq

Skip menu "libkonq"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal