• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

libkonq

  • sources
  • kde-4.12
  • applications
  • kde-baseapps
  • lib
  • konq
konq_sound.cc
Go to the documentation of this file.
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>
4 
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.
8 
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.
13 
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.
18 */
19 
20 #include <phonon/mediaobject.h>
21 #include <phonon/backendcapabilities.h>
22 #include <kdebug.h>
23 
24 #include "konq_sound.h"
25 #include <kurl.h>
26 #include <kpluginfactory.h>
27 
28 using namespace std;
29 
30 class KonqSoundPlayerImpl : public KonqSoundPlayer
31 {
32 public:
33  KonqSoundPlayerImpl();
34  virtual ~KonqSoundPlayerImpl() {}
35 
36  virtual bool isMimeTypeKnown(const QString& mimeType);
37  virtual void setUrl(const KUrl &url);
38  virtual void play();
39  virtual void stop();
40  virtual bool isPlaying();
41 
42 private:
43  Phonon::MediaObject *m_player;
44 };
45 
46 KonqSoundPlayerImpl::KonqSoundPlayerImpl()
47  : m_player(0)
48 {
49 }
50 
51 bool KonqSoundPlayerImpl::isMimeTypeKnown(const QString& mimeType)
52 {
53  kDebug() << mimeType << Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
54  return Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType);
55 }
56 
57 void KonqSoundPlayerImpl::setUrl(const KUrl &url)
58 {
59  kDebug() ;
60  if (!m_player) {
61  kDebug() << "create AudioPlayer";
62  m_player = Phonon::createPlayer(Phonon::MusicCategory);
63  m_player->setParent(this);
64  }
65  m_player->setCurrentSource(url);
66 }
67 
68 void KonqSoundPlayerImpl::play()
69 {
70  kDebug() ;
71  if (m_player)
72  m_player->play();
73 }
74 
75 void KonqSoundPlayerImpl::stop()
76 {
77  kDebug() ;
78  if (m_player)
79  m_player->stop();
80 }
81 
82 bool KonqSoundPlayerImpl::isPlaying()
83 {
84  if (m_player) {
85  const bool isPlaying = (m_player->state() == Phonon::PlayingState || m_player->state() == Phonon::BufferingState);
86  kDebug() << isPlaying;
87  return isPlaying;
88  }
89  kDebug() << false;
90  return false;
91 }
92 
93 class KonqSoundFactory : public KPluginFactory
94 {
95 public:
96  KonqSoundFactory(QObject *parent = 0)
97  : KPluginFactory(0, 0, parent) {}
98  virtual ~KonqSoundFactory() {}
99 
100 protected:
101  virtual QObject *create(const char *iface,
102  QWidget *parentWidget,
103  QObject *parent,
104  const QVariantList &args,
105  const QString &keyword);
106 };
107 
108 QObject *KonqSoundFactory::create(const char *iface, QWidget *, QObject *, const QVariantList &, const QString &)
109 {
110  if (qstrcmp(iface, "KonqSoundPlayer") == 0)
111  return new KonqSoundPlayerImpl();
112  return 0;
113 }
114 
115 K_EXPORT_PLUGIN(KonqSoundFactory)
116 
117 // vim: ts=4 sw=4 noet
QWidget
QObject
konq_sound.h
KonqSoundPlayer
Definition: konq_sound.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkonq

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal