• 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
  • lib
  • marble
PlaybackWaitItem.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 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
9 //
10 
11 #include "PlaybackWaitItem.h"
12 
13 #include <QTimer>
14 
15 namespace Marble
16 {
17 
18 PlaybackWaitItem::PlaybackWaitItem( const GeoDataWait* wait )
19 {
20  m_wait = wait;
21  m_isPlaying = false;
22 }
23 const GeoDataWait* PlaybackWaitItem::wait() const
24 {
25  return m_wait;
26 }
27 double PlaybackWaitItem::duration() const
28 {
29  return m_wait->duration();
30 }
31 
32 void PlaybackWaitItem::play()
33 {
34  if( m_isPlaying ){
35  return;
36  } else {
37  m_isPlaying = true;
38  if ( !( m_start.isValid() ) ){
39  m_start = QDateTime::currentDateTime();
40  Q_ASSERT( m_start.isValid() );
41  } else {
42  m_start = m_start.addMSecs( m_pause.msecsTo( QDateTime::currentDateTime() ) );
43  }
44  playNext();
45  }
46 }
47 
48 void PlaybackWaitItem::playNext()
49 {
50  if( !m_start.isValid() ){
51  return;
52  }
53  double const progress = m_start.msecsTo( QDateTime::currentDateTime() ) / 1000.0;
54  Q_ASSERT( progress >= 0.0 );
55  double const t = progress / duration();
56  if( t <= 1 ){
57  if( m_isPlaying ){
58  emit progressChanged( progress );
59  QTimer::singleShot( 20, this, SLOT( playNext() ) );
60  }
61  } else {
62  stop();
63  emit finished();
64  }
65 }
66 
67 void PlaybackWaitItem::pause()
68 {
69  m_isPlaying = false;
70  m_pause = QDateTime::currentDateTime();
71 }
72 
73 void PlaybackWaitItem::seek( double t )
74 {
75  m_start = QDateTime::currentDateTime().addMSecs( -t * duration() * 1000 );
76  m_pause = QDateTime::currentDateTime();
77 }
78 
79 void PlaybackWaitItem::stop()
80 {
81  m_isPlaying = false;
82  m_start = QDateTime();
83  m_pause = QDateTime();
84 }
85 
86 }
87 
88 #include "PlaybackWaitItem.moc"
Marble::PlaybackWaitItem::wait
const GeoDataWait * wait() const
Definition: PlaybackWaitItem.cpp:23
Marble::PlaybackWaitItem::stop
void stop()
Definition: PlaybackWaitItem.cpp:79
Marble::PlaybackItem::finished
void finished()
Marble::PlaybackWaitItem::duration
double duration() const
Definition: PlaybackWaitItem.cpp:27
Marble::PlaybackWaitItem::play
void play()
Definition: PlaybackWaitItem.cpp:32
Marble::GeoDataWait::duration
double duration() const
Definition: GeoDataWait.cpp:42
Marble::PlaybackWaitItem::PlaybackWaitItem
PlaybackWaitItem(const GeoDataWait *wait)
Definition: PlaybackWaitItem.cpp:18
Marble::PlaybackWaitItem::pause
void pause()
Definition: PlaybackWaitItem.cpp:67
Marble::PlaybackItem::progressChanged
void progressChanged(double seconds)
Marble::GeoDataWait
Definition: GeoDataWait.h:19
PlaybackWaitItem.h
QDateTime::isValid
bool isValid() const
Marble::PlaybackWaitItem::seek
void seek(double position)
Definition: PlaybackWaitItem.cpp:73
QDateTime::currentDateTime
QDateTime currentDateTime()
QDateTime
QDateTime::msecsTo
qint64 msecsTo(const QDateTime &other) const
QTimer::singleShot
singleShot
QDateTime::addMSecs
QDateTime addMSecs(qint64 msecs) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 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