Marble

PlaybackSoundCueItem.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <[email protected]>
4 //
5 
6 #include "PlaybackSoundCueItem.h"
7 
8 #include "GeoDataSoundCue.h"
9 
10 #if HAVE_PHONON
11 #include <phonon/AudioOutput>
12 #endif
13 
14 #include <QUrl>
15 
16 namespace Marble
17 {
18 PlaybackSoundCueItem::PlaybackSoundCueItem( const GeoDataSoundCue* soundCue ) :
19  m_soundCue( soundCue ),
20  m_href( soundCue->href() )
21 {
22 #if HAVE_PHONON
23  Phonon::createPath( &m_mediaObject, new Phonon::AudioOutput( Phonon::MusicCategory, this ) );
24  m_mediaObject.setCurrentSource( QUrl( m_href ) );
25 #endif
26 }
27 
28 const GeoDataSoundCue* PlaybackSoundCueItem::soundCue() const
29 {
30  return m_soundCue;
31 }
32 
33 double PlaybackSoundCueItem::duration() const
34 {
35 #if HAVE_PHONON
36  return m_mediaObject.totalTime() * 1.0 / 1000;
37 #else
38  return 0;
39 #endif
40 }
41 
42 void PlaybackSoundCueItem::play()
43 {
44 #if HAVE_PHONON
45  if( m_href != m_soundCue->href() ) {
46  m_mediaObject.setCurrentSource( QUrl( soundCue()->href() ) );
47  }
48  if( m_mediaObject.isValid() ) {
49  m_mediaObject.play();
50  }
51 #endif
52 }
53 
55 {
56 #if HAVE_PHONON
57  m_mediaObject.pause();
58 #endif
59 }
60 
61 void PlaybackSoundCueItem::seek( double progress )
62 {
63 #if HAVE_PHONON
64  m_mediaObject.seek( progress * 1000 );
65 #else
66  Q_UNUSED( progress )
67 #endif
68 }
69 
71 {
72 #if HAVE_PHONON
73  m_mediaObject.stop();
74 #endif
75 }
76 
77 }
78 
79 #include "moc_PlaybackSoundCueItem.cpp"
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void pause()
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.