1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com> 4 // 5 6 #include "PlaybackSoundCueItem.h" 7 8 #include "GeoDataSoundCue.h" 9 10 #ifdef HAVE_PHONON 11 #include <phonon/AudioOutput> 12 #endif 13 14 #include <QUrl> 15 16 namespace Marble 17 { PlaybackSoundCueItem(const GeoDataSoundCue * soundCue)18PlaybackSoundCueItem::PlaybackSoundCueItem( const GeoDataSoundCue* soundCue ) : 19 m_soundCue( soundCue ), 20 m_href( soundCue->href() ) 21 { 22 #ifdef HAVE_PHONON 23 Phonon::createPath( &m_mediaObject, new Phonon::AudioOutput( Phonon::MusicCategory, this ) ); 24 m_mediaObject.setCurrentSource( QUrl( m_href ) ); 25 #endif 26 } 27 soundCue() const28const GeoDataSoundCue* PlaybackSoundCueItem::soundCue() const 29 { 30 return m_soundCue; 31 } 32 duration() const33double PlaybackSoundCueItem::duration() const 34 { 35 #ifdef HAVE_PHONON 36 return m_mediaObject.totalTime() * 1.0 / 1000; 37 #else 38 return 0; 39 #endif 40 } 41 play()42void PlaybackSoundCueItem::play() 43 { 44 #ifdef 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 pause()54void PlaybackSoundCueItem::pause() 55 { 56 #ifdef HAVE_PHONON 57 m_mediaObject.pause(); 58 #endif 59 } 60 seek(double progress)61void PlaybackSoundCueItem::seek( double progress ) 62 { 63 #ifdef HAVE_PHONON 64 m_mediaObject.seek( progress * 1000 ); 65 #else 66 Q_UNUSED( progress ) 67 #endif 68 } 69 stop()70void PlaybackSoundCueItem::stop() 71 { 72 #ifdef HAVE_PHONON 73 m_mediaObject.stop(); 74 #endif 75 } 76 77 } 78 79 #include "moc_PlaybackSoundCueItem.cpp" 80