File indexing completed on 2024-03-24 03:52:37
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com> 0004 // 0005 0006 #include "PlaybackSoundCueItem.h" 0007 0008 #include "GeoDataSoundCue.h" 0009 0010 #if HAVE_PHONON 0011 #include <phonon/AudioOutput> 0012 #endif 0013 0014 #include <QUrl> 0015 0016 namespace Marble 0017 { 0018 PlaybackSoundCueItem::PlaybackSoundCueItem( const GeoDataSoundCue* soundCue ) : 0019 m_soundCue( soundCue ), 0020 m_href( soundCue->href() ) 0021 { 0022 #if HAVE_PHONON 0023 Phonon::createPath( &m_mediaObject, new Phonon::AudioOutput( Phonon::MusicCategory, this ) ); 0024 m_mediaObject.setCurrentSource( QUrl( m_href ) ); 0025 #endif 0026 } 0027 0028 const GeoDataSoundCue* PlaybackSoundCueItem::soundCue() const 0029 { 0030 return m_soundCue; 0031 } 0032 0033 double PlaybackSoundCueItem::duration() const 0034 { 0035 #if HAVE_PHONON 0036 return m_mediaObject.totalTime() * 1.0 / 1000; 0037 #else 0038 return 0; 0039 #endif 0040 } 0041 0042 void PlaybackSoundCueItem::play() 0043 { 0044 #if HAVE_PHONON 0045 if( m_href != m_soundCue->href() ) { 0046 m_mediaObject.setCurrentSource( QUrl( soundCue()->href() ) ); 0047 } 0048 if( m_mediaObject.isValid() ) { 0049 m_mediaObject.play(); 0050 } 0051 #endif 0052 } 0053 0054 void PlaybackSoundCueItem::pause() 0055 { 0056 #if HAVE_PHONON 0057 m_mediaObject.pause(); 0058 #endif 0059 } 0060 0061 void PlaybackSoundCueItem::seek( double progress ) 0062 { 0063 #if HAVE_PHONON 0064 m_mediaObject.seek( progress * 1000 ); 0065 #else 0066 Q_UNUSED( progress ) 0067 #endif 0068 } 0069 0070 void PlaybackSoundCueItem::stop() 0071 { 0072 #if HAVE_PHONON 0073 m_mediaObject.stop(); 0074 #endif 0075 } 0076 0077 } 0078 0079 #include "moc_PlaybackSoundCueItem.cpp"