summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h4
2 files changed, 10 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 586870c..22451b7 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,258 +1,264 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/qlibrary.h> 37#include <qpe/qlibrary.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qvaluelist.h> 39#include <qvaluelist.h>
40#include <qobject.h> 40#include <qobject.h>
41#include <qdir.h> 41#include <qdir.h>
42#include "mediaplayerstate.h" 42#include "mediaplayerstate.h"
43 43
44 44
45 45
46//#define MediaPlayerDebug(x) qDebug x 46//#define MediaPlayerDebug(x) qDebug x
47#define MediaPlayerDebug(x) 47#define MediaPlayerDebug(x)
48 48
49 49
50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
51 : QObject( parent, name ) { 51 : QObject( parent, name ) {
52 Config cfg( "OpiePlayer" ); 52 Config cfg( "OpiePlayer" );
53 readConfig( cfg ); 53 readConfig( cfg );
54 streaming = false; 54 streaming = false;
55 seekable = true; 55 seekable = true;
56} 56}
57 57
58 58
59MediaPlayerState::~MediaPlayerState() { 59MediaPlayerState::~MediaPlayerState() {
60} 60}
61 61
62 62
63void MediaPlayerState::readConfig( Config& cfg ) { 63void MediaPlayerState::readConfig( Config& cfg ) {
64 cfg.setGroup("Options"); 64 cfg.setGroup("Options");
65 fullscreen = cfg.readBoolEntry( "FullScreen" ); 65 fullscreen = cfg.readBoolEntry( "FullScreen" );
66 scaled = cfg.readBoolEntry( "Scaling" ); 66 scaled = cfg.readBoolEntry( "Scaling" );
67 looping = cfg.readBoolEntry( "Looping" ); 67 looping = cfg.readBoolEntry( "Looping" );
68 shuffled = cfg.readBoolEntry( "Shuffle" ); 68 shuffled = cfg.readBoolEntry( "Shuffle" );
69 videoGamma = cfg.readNumEntry( "VideoGamma" ); 69 videoGamma = cfg.readNumEntry( "VideoGamma" );
70 playing = FALSE; 70 playing = FALSE;
71 streaming = FALSE; 71 streaming = FALSE;
72 paused = FALSE; 72 paused = FALSE;
73 curPosition = 0; 73 curPosition = 0;
74 curLength = 0; 74 curLength = 0;
75 curView = 'l'; 75 curView = 'l';
76} 76}
77 77
78 78
79void MediaPlayerState::writeConfig( Config& cfg ) const { 79void MediaPlayerState::writeConfig( Config& cfg ) const {
80 cfg.setGroup( "Options" ); 80 cfg.setGroup( "Options" );
81 cfg.writeEntry( "FullScreen", fullscreen ); 81 cfg.writeEntry( "FullScreen", fullscreen );
82 cfg.writeEntry( "Scaling", scaled ); 82 cfg.writeEntry( "Scaling", scaled );
83 cfg.writeEntry( "Looping", looping ); 83 cfg.writeEntry( "Looping", looping );
84 cfg.writeEntry( "Shuffle", shuffled ); 84 cfg.writeEntry( "Shuffle", shuffled );
85 cfg.writeEntry( "VideoGamma", videoGamma ); 85 cfg.writeEntry( "VideoGamma", videoGamma );
86} 86}
87 87
88MediaPlayerState::MediaType MediaPlayerState::mediaType() const
89{
90 return view() == 'a' ? MediaPlayerState::Audio : MediaPlayerState::Video;
91}
92
88// slots 93// slots
89void MediaPlayerState::setIsStreaming( bool b ) { 94void MediaPlayerState::setIsStreaming( bool b ) {
90 streaming = b; 95 streaming = b;
91} 96}
92 97
93void MediaPlayerState::setIsSeekable( bool b ) { 98void MediaPlayerState::setIsSeekable( bool b ) {
94 seekable = b; 99 seekable = b;
95 emit isSeekableToggled(b); 100 emit isSeekableToggled(b);
96} 101}
97 102
98 103
99void MediaPlayerState::setFullscreen( bool b ) { 104void MediaPlayerState::setFullscreen( bool b ) {
100 if ( fullscreen == b ) { 105 if ( fullscreen == b ) {
101 return; 106 return;
102 } 107 }
103 fullscreen = b; 108 fullscreen = b;
104 emit fullscreenToggled(b); 109 emit fullscreenToggled(b);
105} 110}
106 111
107 112
108void MediaPlayerState::setBlanked( bool b ) { 113void MediaPlayerState::setBlanked( bool b ) {
109 if ( blanked == b ) { 114 if ( blanked == b ) {
110 return; 115 return;
111 } 116 }
112 blanked = b; 117 blanked = b;
113 emit blankToggled(b); 118 emit blankToggled(b);
114} 119}
115 120
116 121
117void MediaPlayerState::setScaled( bool b ) { 122void MediaPlayerState::setScaled( bool b ) {
118 if ( scaled == b ) { 123 if ( scaled == b ) {
119 return; 124 return;
120 } 125 }
121 scaled = b; 126 scaled = b;
122 emit scaledToggled(b); 127 emit scaledToggled(b);
123} 128}
124 129
125void MediaPlayerState::setLooping( bool b ) { 130void MediaPlayerState::setLooping( bool b ) {
126 if ( looping == b ) { 131 if ( looping == b ) {
127 return; 132 return;
128 } 133 }
129 looping = b; 134 looping = b;
130 emit loopingToggled(b); 135 emit loopingToggled(b);
131} 136}
132 137
133void MediaPlayerState::setShuffled( bool b ) { 138void MediaPlayerState::setShuffled( bool b ) {
134 if ( shuffled == b ) { 139 if ( shuffled == b ) {
135 return; 140 return;
136 } 141 }
137 shuffled = b; 142 shuffled = b;
138 emit shuffledToggled(b); 143 emit shuffledToggled(b);
139} 144}
140 145
141void MediaPlayerState::setPaused( bool b ) { 146void MediaPlayerState::setPaused( bool b ) {
142 if ( paused == b ) { 147 if ( paused == b ) {
143 paused = FALSE; 148 paused = FALSE;
144 emit pausedToggled(FALSE); 149 emit pausedToggled(FALSE);
145 return; 150 return;
146 } 151 }
147 paused = b; 152 paused = b;
148 emit pausedToggled(b); 153 emit pausedToggled(b);
149} 154}
150 155
151void MediaPlayerState::setPlaying( bool b ) { 156void MediaPlayerState::setPlaying( bool b ) {
152 if ( playing == b ) { 157 if ( playing == b ) {
153 return; 158 return;
154 } 159 }
155 playing = b; 160 playing = b;
156 stopped = !b; 161 stopped = !b;
157 emit playingToggled(b); 162 emit playingToggled(b);
158} 163}
159 164
160void MediaPlayerState::setStopped( bool b ) { 165void MediaPlayerState::setStopped( bool b ) {
161 if ( stopped == b ) { 166 if ( stopped == b ) {
162 return; 167 return;
163 } 168 }
164 stopped = b; 169 stopped = b;
165 emit stopToggled(b); 170 emit stopToggled(b);
166} 171}
167 172
168void MediaPlayerState::setPosition( long p ) { 173void MediaPlayerState::setPosition( long p ) {
169 if ( curPosition == p ) { 174 if ( curPosition == p ) {
170 return; 175 return;
171 } 176 }
172 curPosition = p; 177 curPosition = p;
173 emit positionChanged(p); 178 emit positionChanged(p);
174} 179}
175 180
176void MediaPlayerState::updatePosition( long p ){ 181void MediaPlayerState::updatePosition( long p ){
177 if ( curPosition == p ) { 182 if ( curPosition == p ) {
178 return; 183 return;
179 } 184 }
180 curPosition = p; 185 curPosition = p;
181 emit positionUpdated(p); 186 emit positionUpdated(p);
182} 187}
183 188
184void MediaPlayerState::setVideoGamma( int v ){ 189void MediaPlayerState::setVideoGamma( int v ){
185 if ( videoGamma == v ) { 190 if ( videoGamma == v ) {
186 return; 191 return;
187 } 192 }
188 videoGamma = v; 193 videoGamma = v;
189 emit videoGammaChanged( v ); 194 emit videoGammaChanged( v );
190} 195}
191 196
192void MediaPlayerState::setLength( long l ) { 197void MediaPlayerState::setLength( long l ) {
193 if ( curLength == l ) { 198 if ( curLength == l ) {
194 return; 199 return;
195 } 200 }
196 curLength = l; 201 curLength = l;
197 emit lengthChanged(l); 202 emit lengthChanged(l);
198} 203}
199 204
200void MediaPlayerState::setView( char v ) { 205void MediaPlayerState::setView( char v ) {
201 if ( curView == v ) { 206 if ( curView == v ) {
202 return; 207 return;
203 } 208 }
204 curView = v; 209 curView = v;
205 emit viewChanged(v); 210 emit viewChanged(v);
211 emit mediaTypeChanged( mediaType() );
206} 212}
207 213
208void MediaPlayerState::setPrev(){ 214void MediaPlayerState::setPrev(){
209 emit prev(); 215 emit prev();
210} 216}
211 217
212void MediaPlayerState::setNext() { 218void MediaPlayerState::setNext() {
213 emit next(); 219 emit next();
214} 220}
215 221
216void MediaPlayerState::setList() { 222void MediaPlayerState::setList() {
217 setPlaying( FALSE ); 223 setPlaying( FALSE );
218 setView('l'); 224 setView('l');
219} 225}
220 226
221void MediaPlayerState::setVideo() { 227void MediaPlayerState::setVideo() {
222 setView('v'); 228 setView('v');
223} 229}
224 230
225void MediaPlayerState::setAudio() { 231void MediaPlayerState::setAudio() {
226 setView('a'); 232 setView('a');
227} 233}
228 234
229void MediaPlayerState::toggleFullscreen() { 235void MediaPlayerState::toggleFullscreen() {
230 setFullscreen( !fullscreen ); 236 setFullscreen( !fullscreen );
231} 237}
232 238
233void MediaPlayerState::toggleScaled() { 239void MediaPlayerState::toggleScaled() {
234 setScaled( !scaled); 240 setScaled( !scaled);
235} 241}
236 242
237void MediaPlayerState::toggleLooping() { 243void MediaPlayerState::toggleLooping() {
238 setLooping( !looping); 244 setLooping( !looping);
239} 245}
240 246
241void MediaPlayerState::toggleShuffled() { 247void MediaPlayerState::toggleShuffled() {
242 setShuffled( !shuffled); 248 setShuffled( !shuffled);
243} 249}
244 250
245void MediaPlayerState::togglePaused() { 251void MediaPlayerState::togglePaused() {
246 setPaused( !paused); 252 setPaused( !paused);
247} 253}
248 254
249void MediaPlayerState::togglePlaying() { 255void MediaPlayerState::togglePlaying() {
250 setPlaying( !playing); 256 setPlaying( !playing);
251} 257}
252 258
253void MediaPlayerState::toggleBlank() { 259void MediaPlayerState::toggleBlank() {
254 setBlanked( !blanked); 260 setBlanked( !blanked);
255} 261}
256 262
257 263
258 264
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index fc4e6cb..9474882 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,139 +1,143 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#ifndef MEDIA_PLAYER_STATE_H 36#ifndef MEDIA_PLAYER_STATE_H
37#define MEDIA_PLAYER_STATE_H 37#define MEDIA_PLAYER_STATE_H
38 38
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42 42
43class MediaPlayerDecoder; 43class MediaPlayerDecoder;
44class Config; 44class Config;
45 45
46 46
47class MediaPlayerState : public QObject { 47class MediaPlayerState : public QObject {
48Q_OBJECT 48Q_OBJECT
49public: 49public:
50 enum MediaType { Audio, Video };
51
50 MediaPlayerState( QObject *parent, const char *name ); 52 MediaPlayerState( QObject *parent, const char *name );
51 ~MediaPlayerState(); 53 ~MediaPlayerState();
52 54
53 bool isStreaming() const { return streaming; } 55 bool isStreaming() const { return streaming; }
54 bool isSeekable() const { return seekable; } 56 bool isSeekable() const { return seekable; }
55 bool isFullscreen() const { return fullscreen; } 57 bool isFullscreen() const { return fullscreen; }
56 bool isScaled() const { return scaled; } 58 bool isScaled() const { return scaled; }
57 bool isLooping() const { return looping; } 59 bool isLooping() const { return looping; }
58 bool isShuffled() const { return shuffled; } 60 bool isShuffled() const { return shuffled; }
59 bool isPaused() const { return paused; } 61 bool isPaused() const { return paused; }
60 bool isPlaying() const { return playing; } 62 bool isPlaying() const { return playing; }
61 bool isStopped() const { return stopped; } 63 bool isStopped() const { return stopped; }
62 long position() const { return curPosition; } 64 long position() const { return curPosition; }
63 long length() const { return curLength; } 65 long length() const { return curLength; }
64 char view() const { return curView; } 66 char view() const { return curView; }
67 MediaType mediaType() const;
65 68
66public slots: 69public slots:
67 void setIsStreaming( bool b ); 70 void setIsStreaming( bool b );
68 void setIsSeekable( bool b ); 71 void setIsSeekable( bool b );
69 void setFullscreen( bool b ); 72 void setFullscreen( bool b );
70 void setScaled( bool b ); 73 void setScaled( bool b );
71 void setLooping( bool b ); 74 void setLooping( bool b );
72 void setShuffled( bool b ); 75 void setShuffled( bool b );
73 void setPaused( bool b ); 76 void setPaused( bool b );
74 void setPlaying( bool b ); 77 void setPlaying( bool b );
75 void setStopped( bool b ); 78 void setStopped( bool b );
76 void setPosition( long p ); 79 void setPosition( long p );
77 void updatePosition( long p ); 80 void updatePosition( long p );
78 void setLength( long l ); 81 void setLength( long l );
79 void setView( char v ); 82 void setView( char v );
80 void setBlanked( bool b ); 83 void setBlanked( bool b );
81 void setVideoGamma( int v ); 84 void setVideoGamma( int v );
82 85
83 void setPrev(); 86 void setPrev();
84 void setNext(); 87 void setNext();
85 void setList(); 88 void setList();
86 void setVideo(); 89 void setVideo();
87 void setAudio(); 90 void setAudio();
88 91
89 void toggleFullscreen(); 92 void toggleFullscreen();
90 void toggleScaled(); 93 void toggleScaled();
91 void toggleLooping(); 94 void toggleLooping();
92 void toggleShuffled(); 95 void toggleShuffled();
93 void togglePaused(); 96 void togglePaused();
94 void togglePlaying(); 97 void togglePlaying();
95 void toggleBlank(); 98 void toggleBlank();
96 void writeConfig( Config& cfg ) const; 99 void writeConfig( Config& cfg ) const;
97 100
98 101
99signals: 102signals:
100 void fullscreenToggled( bool ); 103 void fullscreenToggled( bool );
101 void scaledToggled( bool ); 104 void scaledToggled( bool );
102 void loopingToggled( bool ); 105 void loopingToggled( bool );
103 void shuffledToggled( bool ); 106 void shuffledToggled( bool );
104 void pausedToggled( bool ); 107 void pausedToggled( bool );
105 void playingToggled( bool ); 108 void playingToggled( bool );
106 void stopToggled( bool ); 109 void stopToggled( bool );
107 void positionChanged( long ); // When the slider is moved 110 void positionChanged( long ); // When the slider is moved
108 void positionUpdated( long ); // When the media file progresses 111 void positionUpdated( long ); // When the media file progresses
109 void lengthChanged( long ); 112 void lengthChanged( long );
110 void viewChanged( char ); 113 void viewChanged( char );
114 void mediaTypeChanged( MediaType type );
111 void isSeekableToggled( bool ); 115 void isSeekableToggled( bool );
112 void blankToggled( bool ); 116 void blankToggled( bool );
113 void videoGammaChanged( int ); 117 void videoGammaChanged( int );
114 void prev(); 118 void prev();
115 void next(); 119 void next();
116 120
117private: 121private:
118 bool streaming : 1; 122 bool streaming : 1;
119 bool seekable : 1; 123 bool seekable : 1;
120 bool fullscreen: 1; 124 bool fullscreen: 1;
121 bool scaled : 1; 125 bool scaled : 1;
122 bool blanked : 1; 126 bool blanked : 1;
123 bool looping : 1; 127 bool looping : 1;
124 bool shuffled : 1; 128 bool shuffled : 1;
125 bool usePlaylist : 1; 129 bool usePlaylist : 1;
126 bool paused : 1; 130 bool paused : 1;
127 bool playing : 1; 131 bool playing : 1;
128 bool stopped : 1; 132 bool stopped : 1;
129 long curPosition; 133 long curPosition;
130 long curLength; 134 long curLength;
131 char curView; 135 char curView;
132 int videoGamma; 136 int videoGamma;
133 void readConfig( Config& cfg ); 137 void readConfig( Config& cfg );
134 138
135}; 139};
136 140
137 141
138#endif // MEDIA_PLAYER_STATE_H 142#endif // MEDIA_PLAYER_STATE_H
139 143