Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[920a14]: src / PlaybackController.cpp Maximize Restore History

Download this file

PlaybackController.cpp    193 lines (161 with data), 5.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***************************************************************************
PlaybackController.cpp - Interface for generic playback control
-------------------
begin : Nov 15 2000
copyright : (C) 2000 by Thomas Eschenbacher
email : Thomas Eschenbacher <Thomas.Eschenbacher@gmx.de>
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "PlaybackController.h"
//***************************************************************************
PlaybackController::PlaybackController()
{
m_loop_mode = false;
m_paused = false;
m_playing = false;
m_playback_position = 0;
m_playback_start = 0;
}
//***************************************************************************
PlaybackController::~PlaybackController()
{
playbackStop();
}
//***************************************************************************
void PlaybackController::playbackStart()
{
if (m_playing) {
// first stop playback
emit sigStopPlayback();
emit sigPlaybackStopped();
}
// (re)start from beginning without loop mode
m_playback_position = m_playback_start;
emit sigPlaybackPos(m_playback_position);
m_loop_mode = false;
m_paused = false;
emit sigStartPlayback();
m_playing = true;
emit sigPlaybackStarted();
}
//***************************************************************************
void PlaybackController::playbackLoop()
{
if (m_playing) {
// first stop playback
emit sigStopPlayback();
m_playing = false;
emit sigPlaybackStopped();
}
// (re)start from beginning without loop mode
m_playback_position = m_playback_start;
emit sigPlaybackPos(m_playback_position);
m_loop_mode = true;
m_paused = false;
emit sigStartPlayback();
m_playing = true;
emit sigPlaybackStarted();
}
//***************************************************************************
void PlaybackController::playbackPause()
{
if (!m_playing) return; // no effect if not playing
m_paused = true;
// stop playback for now and set the paused flag
emit sigStopPlayback();
}
//***************************************************************************
void PlaybackController::playbackContinue()
{
// if not paused, do the same as start
if (!m_paused) {
playbackStart();
return;
}
// else reset the paused flag and start from current position
emit sigStartPlayback();
m_paused = false;
m_playing=true;
emit sigPlaybackStarted();
}
//***************************************************************************
void PlaybackController::playbackStop()
{
// stopped in pause state
if (m_paused) {
m_playing = false;
m_paused = false;
emit sigPlaybackStopped();
}
if (!m_playing) return; // already stopped
emit sigStopPlayback();
}
//***************************************************************************
void PlaybackController::updatePlaybackPos(const unsigned int pos)
{
m_playback_position = pos;
emit sigPlaybackPos(m_playback_position);
}
//***************************************************************************
void PlaybackController::playbackDone()
{
m_playing = false;
if (m_paused)
emit sigPlaybackPaused();
else {
m_playback_position = m_playback_start;
emit sigPlaybackPos(m_playback_position);
emit sigPlaybackStopped();
}
}
//***************************************************************************
void PlaybackController::reset()
{
m_playback_start = 0;
m_playback_position = 0;
m_loop_mode = false;
m_playing = false;
m_paused = false;
emit sigPlaybackPos(0);
emit sigPlaybackStopped();
}
//***************************************************************************
bool PlaybackController::loop()
{
return m_loop_mode;
}
//***************************************************************************
bool PlaybackController::running()
{
return m_playing;
}
//***************************************************************************
bool PlaybackController::paused()
{
return m_paused;
}
//***************************************************************************
void PlaybackController::setStartPos(unsigned long int pos)
{
m_playback_start = pos;
}
//***************************************************************************
unsigned long int PlaybackController::startPos()
{
return m_playback_start;
}
//***************************************************************************
unsigned long int PlaybackController::currentPos()
{
return m_playback_position;
}
//***************************************************************************
//***************************************************************************
/* end of src/PlaybackController.h */