Marble

PlaybackSoundCueItem.cpp
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#if HAVE_PHONON
11#include <phonon/AudioOutput>
12#endif
13
14#include <QUrl>
15
16namespace Marble
17{
18PlaybackSoundCueItem::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
28const GeoDataSoundCue *PlaybackSoundCueItem::soundCue() const
29{
30 return m_soundCue;
31}
32
33double 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
42void 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
54void PlaybackSoundCueItem::pause()
55{
56#if HAVE_PHONON
57 m_mediaObject.pause();
58#endif
59}
60
61void 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
70void PlaybackSoundCueItem::stop()
71{
72#if HAVE_PHONON
73 m_mediaObject.stop();
74#endif
75}
76
77}
78
79#include "moc_PlaybackSoundCueItem.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.