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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • routing
AudioOutput.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "AudioOutput.h"
12 
13 #include "MarbleDirs.h"
14 #include "MarbleDebug.h"
15 #include "routing/VoiceNavigationModel.h"
16 
17 #include <QDirIterator>
18 #include <QUrl>
19 #include <phonon/MediaObject>
20 #include <phonon/MediaSource>
21 #include <phonon/AudioOutput>
22 
23 namespace Marble
24 {
25 
26 class AudioOutputPrivate
27 {
28 public:
29  AudioOutput *q;
30 
31  Phonon::MediaObject *m_output;
32 
33  bool m_muted;
34 
35  VoiceNavigationModel m_voiceNavigation;
36 
37  AudioOutputPrivate( AudioOutput* parent );
38 
39  void audioOutputFinished();
40 
41  void setupAudio();
42 
43  void reset();
44 
45  void playInstructions();
46 };
47 
48 AudioOutputPrivate::AudioOutputPrivate( AudioOutput* parent ) :
49  q( parent ), m_output( 0 ), m_muted( false )
50 {
51  QObject::connect( &m_voiceNavigation, SIGNAL(instructionChanged()),
52  q, SLOT(playInstructions()) );
53 }
54 
55 void AudioOutputPrivate::audioOutputFinished()
56 {
57  m_output->setCurrentSource( Phonon::MediaSource() );
58  m_output->clearQueue();
59 }
60 
61 void AudioOutputPrivate::setupAudio()
62 {
63  if ( !m_output ) {
64  m_output = new Phonon::MediaObject( q );
65  Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput( Phonon::VideoCategory, q );
66  Phonon::createPath( m_output, audioOutput );
67 
68  q->connect( m_output, SIGNAL(finished()), q, SLOT(audioOutputFinished()) );
69  }
70 }
71 
72 void AudioOutputPrivate::reset()
73 {
74  if ( m_output ) {
75  m_output->stop();
76  m_output->setCurrentSource( Phonon::MediaSource() );
77  m_output->clearQueue();
78  }
79 
80  m_voiceNavigation.reset();
81 }
82 
83 void AudioOutputPrivate::playInstructions()
84 {
85  setupAudio();
86  if ( m_output ) {
87  m_output->enqueue( QUrl::fromLocalFile( m_voiceNavigation.instruction() ) );
88  m_output->play();
89  }
90 }
91 
92 AudioOutput::AudioOutput( QObject* parent ) : QObject( parent ),
93  d( new AudioOutputPrivate( this ) )
94 {
95  setSoundEnabled( false );
96 }
97 
98 AudioOutput::~AudioOutput()
99 {
100  delete d;
101 }
102 
103 void AudioOutput::update(const Route &route, qreal distanceManeuver, qreal distanceTarget, bool deviated )
104 {
105  d->m_voiceNavigation.update( route, distanceManeuver, distanceTarget, deviated );
106 }
107 
108 void AudioOutput::setMuted( bool muted )
109 {
110  d->m_muted = muted;
111 }
112 
113 bool AudioOutput::isMuted() const
114 {
115  return d->m_muted;
116 }
117 
118 void AudioOutput::setSpeaker( const QString &speaker )
119 {
120  d->m_voiceNavigation.setSpeaker( speaker );
121 }
122 
123 QString AudioOutput::speaker() const
124 {
125  return d->m_voiceNavigation.speaker();
126 }
127 
128 void AudioOutput::setSoundEnabled( bool enabled )
129 {
130  d->m_voiceNavigation.setSpeakerEnabled( !enabled );
131 }
132 
133 bool AudioOutput::isSoundEnabled() const
134 {
135  return !d->m_voiceNavigation.isSpeakerEnabled();
136 }
137 
138 }
139 
140 #include "AudioOutput.moc"
VoiceNavigationModel.h
Marble::AudioOutput::setMuted
void setMuted(bool muted)
Toggle muting (neither sound nor voice output)
Definition: AudioOutput.cpp:108
Marble::AudioOutput::setSoundEnabled
void setSoundEnabled(bool enabled)
Toggle whether sound output is used instead of a speaker.
Definition: AudioOutput.cpp:128
Marble::AudioOutput::~AudioOutput
~AudioOutput()
Destructor.
Definition: AudioOutput.cpp:98
MarbleDebug.h
Marble::AudioOutput::speaker
QString speaker() const
Definition: AudioOutput.cpp:123
Marble::AudioOutput::setSpeaker
void setSpeaker(const QString &speaker)
Change the speaker to use.
Definition: AudioOutput.cpp:118
QObject
Phonon::MediaObject
MarbleDirs.h
Phonon::MediaSource
QString
Marble::AudioOutput::isSoundEnabled
bool isSoundEnabled() const
Definition: AudioOutput.cpp:133
Marble::AudioOutput::update
void update(const Route &route, qreal distanceManeuver, qreal distanceTarget, bool deviated)
Generate an audible notification (if needed) after the position on the route has changed.
Definition: AudioOutput.cpp:103
Phonon::createPath
Path createPath(MediaNode *source, MediaNode *sink)
AudioOutput.h
Marble::AudioOutput::isMuted
bool isMuted() const
Definition: AudioOutput.cpp:113
Marble::Route
Definition: Route.h:20
Phonon::AudioOutput
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QUrl::fromLocalFile
QUrl fromLocalFile(const QString &localFile)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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