summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp32
-rw-r--r--core/multimedia/opieplayer/audiowidget.h2
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp3
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp3
-rw-r--r--core/multimedia/opieplayer/mediaplayer.h1
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp12
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp28
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h2
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp1
9 files changed, 65 insertions, 19 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index e2e3603..94b979f 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,348 +1,362 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qbutton.h> 25#include <qbutton.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h>
28 29
29#include "audiowidget.h" 30#include "audiowidget.h"
30#include "mediaplayerstate.h" 31#include "mediaplayerstate.h"
31 32
32extern MediaPlayerState *mediaPlayerState; 33extern MediaPlayerState *mediaPlayerState;
33 34
34 35
35static const int xo = -2; // movable x offset 36static const int xo = -2; // movable x offset
36static const int yo = 22; // movable y offset 37static const int yo = 22; // movable y offset
37 38
38 39
39struct MediaButton { 40struct MediaButton {
40 int xPos, yPos; 41 int xPos, yPos;
41 int color; 42 int color;
42 bool isToggle, isBig, isHeld, isDown; 43 bool isToggle, isBig, isHeld, isDown;
43}; 44};
44 45
45 46
46// Layout information for the audioButtons (and if it is a toggle button or not) 47// Layout information for the audioButtons (and if it is a toggle button or not)
47MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
48 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 49 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
49 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 50 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
50 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 51 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
51 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 52 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
52 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 53 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
53 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 54 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
54 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 55 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
55 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 56 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
56 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 57 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
57}; 58};
58 59
59 60
60static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 61static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
61 62
62 63
63AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 64AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
64 QWidget( parent, name, f ) 65 QWidget( parent, name, f )
65{ 66{
66// QPEApplication::grabKeyboard();
67 setCaption( tr("OpiePlayer") ); 67 setCaption( tr("OpiePlayer") );
68
69// QGridLayout *layout = new QGridLayout( this );
70// layout->setSpacing( 2);
71// layout->setMargin( 2);
72
68 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 73 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
69 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); 74 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) );
70 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); 75 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) );
71 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); 76 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) );
72 pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); 77 pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) );
73 78
74 songInfo = new Ticker( this ); 79 songInfo = new Ticker( this );
75 songInfo->setFocusPolicy( QWidget::NoFocus ); 80 songInfo->setFocusPolicy( QWidget::NoFocus );
76 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 81 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
77 82// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 );
83
78 slider = new QSlider( Qt::Horizontal, this ); 84 slider = new QSlider( Qt::Horizontal, this );
79 slider->setFixedWidth( 220 ); 85 slider->setFixedWidth( 220 );
80 slider->setFixedHeight( 20 ); 86 slider->setFixedHeight( 20 );
81 slider->setMinValue( 0 ); 87 slider->setMinValue( 0 );
82 slider->setMaxValue( 1 ); 88 slider->setMaxValue( 1 );
83 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 89 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
84 slider->setFocusPolicy( QWidget::NoFocus ); 90 slider->setFocusPolicy( QWidget::NoFocus );
85 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 91 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
92 // layout->addMultiCellWidget( slider, 4, 4, 0, 2 );
86 93
87 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 94 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
88 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 95 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
89 96
90 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 97 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
91 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 98 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
92 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 99 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
93 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 100 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
94 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 101 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
95 102
96 // Intialise state 103 // Intialise state
97 setLength( mediaPlayerState->length() ); 104 setLength( mediaPlayerState->length() );
98 setPosition( mediaPlayerState->position() ); 105 setPosition( mediaPlayerState->position() );
99 setLooping( mediaPlayerState->fullscreen() ); 106 setLooping( mediaPlayerState->fullscreen() );
100 setPaused( mediaPlayerState->paused() ); 107 setPaused( mediaPlayerState->paused() );
101 setPlaying( mediaPlayerState->playing() ); 108 setPlaying( mediaPlayerState->playing() );
102 109
103} 110}
104 111
105 112
106AudioWidget::~AudioWidget() { 113AudioWidget::~AudioWidget() {
114 mediaPlayerState->isStreaming = FALSE;
107 for ( int i = 0; i < 4; i++ ) 115 for ( int i = 0; i < 4; i++ )
108 delete pixmaps[i]; 116 delete pixmaps[i];
109} 117}
110 118
111 119
112static bool audioSliderBeingMoved = FALSE; 120static bool audioSliderBeingMoved = FALSE;
113 121
114 122
115void AudioWidget::sliderPressed() { 123void AudioWidget::sliderPressed() {
116 audioSliderBeingMoved = TRUE; 124 audioSliderBeingMoved = TRUE;
117} 125}
118 126
119 127
120void AudioWidget::sliderReleased() { 128void AudioWidget::sliderReleased() {
121 audioSliderBeingMoved = FALSE; 129 audioSliderBeingMoved = FALSE;
122 if ( slider->width() == 0 ) 130 if ( slider->width() == 0 )
123 return; 131 return;
124 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 132 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
125 mediaPlayerState->setPosition( val ); 133 mediaPlayerState->setPosition( val );
126} 134}
127 135
128 136
129void AudioWidget::setPosition( long i ) { 137void AudioWidget::setPosition( long i ) {
130 updateSlider( i, mediaPlayerState->length() ); 138 updateSlider( i, mediaPlayerState->length() );
131} 139}
132 140
133 141
134void AudioWidget::setLength( long max ) { 142void AudioWidget::setLength( long max ) {
135 updateSlider( mediaPlayerState->position(), max ); 143 updateSlider( mediaPlayerState->position(), max );
136} 144}
137 145
138 146
139void AudioWidget::setView( char view ) { 147void AudioWidget::setView( char view ) {
148
140 if (mediaPlayerState->isStreaming) { 149 if (mediaPlayerState->isStreaming) {
141 if( !slider->isHidden()) slider->hide(); 150 if( !slider->isHidden()) slider->hide();
142 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 151 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
143 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 152 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
144 } else { 153 } else {
145// this stops the slider from being moved, thus 154// this stops the slider from being moved, thus
146 // does not stop stream when it reaches the end 155 // does not stop stream when it reaches the end
147 if( slider->isHidden()) slider->show(); 156 slider->show();
148 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 157 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
149 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 158 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
150 } 159 }
151 160
152 if ( view == 'a' ) { 161 if ( view == 'a' ) {
153 startTimer( 150 ); 162 startTimer( 150 );
154 showMaximized(); 163// show();
164 showMaximized();
155 } else { 165 } else {
156 killTimers(); 166 killTimers();
157 hide(); 167 hide();
158 } 168 }
159} 169}
160 170
161 171
162void AudioWidget::updateSlider( long i, long max ) { 172void AudioWidget::updateSlider( long i, long max ) {
163 if ( max == 0 ) 173 if ( max == 0 )
164 return; 174 return;
165 // Will flicker too much if we don't do this 175 // Will flicker too much if we don't do this
166 // Scale to something reasonable 176 // Scale to something reasonable
167 int width = slider->width(); 177 int width = slider->width();
168 int val = int((double)i * width / max); 178 int val = int((double)i * width / max);
169 if ( !audioSliderBeingMoved ) { 179 if ( !audioSliderBeingMoved ) {
170 if ( slider->value() != val ) 180 if ( slider->value() != val )
171 slider->setValue( val ); 181 slider->setValue( val );
172 if ( slider->maxValue() != width ) 182 if ( slider->maxValue() != width )
173 slider->setMaxValue( width ); 183 slider->setMaxValue( width );
174 } 184 }
175} 185}
176 186
177 187
178void AudioWidget::setToggleButton( int i, bool down ) { 188void AudioWidget::setToggleButton( int i, bool down ) {
179 if ( down != audioButtons[i].isDown ) 189 if ( down != audioButtons[i].isDown )
180 toggleButton( i ); 190 toggleButton( i );
181} 191}
182 192
183 193
184void AudioWidget::toggleButton( int i ) { 194void AudioWidget::toggleButton( int i ) {
185 audioButtons[i].isDown = !audioButtons[i].isDown; 195 audioButtons[i].isDown = !audioButtons[i].isDown;
186 QPainter p(this); 196 QPainter p(this);
187 paintButton ( &p, i ); 197 paintButton ( &p, i );
188} 198}
189 199
190 200
191void AudioWidget::paintButton( QPainter *p, int i ) { 201void AudioWidget::paintButton( QPainter *p, int i ) {
192 int x = audioButtons[i].xPos; 202 int x = audioButtons[i].xPos;
193 int y = audioButtons[i].yPos; 203 int y = audioButtons[i].yPos;
194 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 204 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
195 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 205 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
196 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); 206 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
197 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); 207 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
198} 208}
199 209
200 210
201void AudioWidget::timerEvent( QTimerEvent * ) { 211void AudioWidget::timerEvent( QTimerEvent * ) {
202 static int frame = 0; 212 static int frame = 0;
203 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 213 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
204 frame = frame >= 7 ? 0 : frame + 1; 214 frame = frame >= 7 ? 0 : frame + 1;
205 int x = audioButtons[AudioPlay].xPos; 215 int x = audioButtons[AudioPlay].xPos;
206 int y = audioButtons[AudioPlay].yPos; 216 int y = audioButtons[AudioPlay].yPos;
207 QPainter p( this ); 217 QPainter p( this );
208 // Optimize to only draw the little bit of the changing images which is different 218 // Optimize to only draw the little bit of the changing images which is different
209 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 219 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
210 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 220 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
211 } 221 }
212} 222}
213 223
214 224
215void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 225void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
216 for ( int i = 0; i < numButtons; i++ ) { 226 for ( int i = 0; i < numButtons; i++ ) {
217 int size = audioButtons[i].isBig; 227 int size = audioButtons[i].isBig;
218 int x = audioButtons[i].xPos; 228 int x = audioButtons[i].xPos;
219 int y = audioButtons[i].yPos; 229 int y = audioButtons[i].yPos;
220 if ( event->state() == QMouseEvent::LeftButton ) { 230 if ( event->state() == QMouseEvent::LeftButton ) {
221 // The test to see if the mouse click is inside the circular button or not 231 // The test to see if the mouse click is inside the circular button or not
222 // (compared with the radius squared to avoid a square-root of our distance) 232 // (compared with the radius squared to avoid a square-root of our distance)
223 int radius = 32 + 13 * size; 233 int radius = 32 + 13 * size;
224 QPoint center = QPoint( x + radius, y + radius ); 234 QPoint center = QPoint( x + radius, y + radius );
225 QPoint dXY = center - event->pos(); 235 QPoint dXY = center - event->pos();
226 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 236 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
227 bool isOnButton = dist <= (radius * radius); 237 bool isOnButton = dist <= (radius * radius);
228// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 238// QRect r( x, y, 64 + 22*size, 64 + 22*size );
229// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 239// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
230 if ( isOnButton && !audioButtons[i].isHeld ) { 240 if ( isOnButton && !audioButtons[i].isHeld ) {
231 audioButtons[i].isHeld = TRUE; 241 audioButtons[i].isHeld = TRUE;
232 toggleButton(i); 242 toggleButton(i);
233 qDebug("button toggled1 %d",i); 243 qDebug("button toggled1 %d",i);
234 switch (i) { 244 switch (i) {
235 case AudioVolumeUp: emit moreClicked(); return; 245 case AudioVolumeUp: emit moreClicked(); return;
236 case AudioVolumeDown: emit lessClicked(); return; 246 case AudioVolumeDown: emit lessClicked(); return;
237 } 247 }
238 } else if ( !isOnButton && audioButtons[i].isHeld ) { 248 } else if ( !isOnButton && audioButtons[i].isHeld ) {
239 audioButtons[i].isHeld = FALSE; 249 audioButtons[i].isHeld = FALSE;
240 toggleButton(i); 250 toggleButton(i);
241 qDebug("button toggled2 %d",i); 251 qDebug("button toggled2 %d",i);
242 } 252 }
243 } else { 253 } else {
244 if ( audioButtons[i].isHeld ) { 254 if ( audioButtons[i].isHeld ) {
245 audioButtons[i].isHeld = FALSE; 255 audioButtons[i].isHeld = FALSE;
246 if ( !audioButtons[i].isToggle ) 256 if ( !audioButtons[i].isToggle )
247 setToggleButton( i, FALSE ); 257 setToggleButton( i, FALSE );
248 qDebug("button toggled3 %d",i); 258 qDebug("button toggled3 %d",i);
249 switch (i) { 259 switch (i) {
250 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 260 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
251 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 261 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
252 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 262 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
253 case AudioNext: mediaPlayerState->setNext(); return; 263 case AudioNext: mediaPlayerState->setNext(); return;
254 case AudioPrevious: mediaPlayerState->setPrev(); return; 264 case AudioPrevious: mediaPlayerState->setPrev(); return;
255 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 265 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
256 case AudioVolumeUp: emit moreReleased(); return; 266 case AudioVolumeUp: emit moreReleased(); return;
257 case AudioVolumeDown: emit lessReleased(); return; 267 case AudioVolumeDown: emit lessReleased(); return;
258 case AudioPlayList: mediaPlayerState->setList(); return; 268 case AudioPlayList: mediaPlayerState->setList(); return;
259 } 269 }
260 } 270 }
261 } 271 }
262 } 272 }
263} 273}
264 274
265 275
266void AudioWidget::mousePressEvent( QMouseEvent *event ) { 276void AudioWidget::mousePressEvent( QMouseEvent *event ) {
267 mouseMoveEvent( event ); 277 mouseMoveEvent( event );
268} 278}
269 279
270 280
271void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 281void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
272 mouseMoveEvent( event ); 282 mouseMoveEvent( event );
273} 283}
274 284
275 285
276void AudioWidget::showEvent( QShowEvent* ) { 286void AudioWidget::showEvent( QShowEvent* ) {
277 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 287 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
278 mouseMoveEvent( &event ); 288 mouseMoveEvent( &event );
279} 289}
280 290
281 291
282void AudioWidget::closeEvent( QCloseEvent* ) { 292void AudioWidget::closeEvent( QCloseEvent* ) {
283 mediaPlayerState->setList(); 293 mediaPlayerState->setList();
284} 294}
285 295
286 296
287void AudioWidget::paintEvent( QPaintEvent * ) { 297void AudioWidget::paintEvent( QPaintEvent * ) {
288 QPainter p( this ); 298 QPainter p( this );
289 for ( int i = 0; i < numButtons; i++ ) 299 for ( int i = 0; i < numButtons; i++ )
290 paintButton( &p, i ); 300 paintButton( &p, i );
291} 301}
292 302
293 303void AudioWidget::showMe() {
304 show();
305}
294void AudioWidget::keyReleaseEvent( QKeyEvent *e) 306void AudioWidget::keyReleaseEvent( QKeyEvent *e)
295{ 307{
296 switch ( e->key() ) { 308 switch ( e->key() ) {
297////////////////////////////// Zaurus keys 309////////////////////////////// Zaurus keys
298 case Key_Home: 310 case Key_Home:
299 break; 311 break;
300 case Key_F9: //activity 312 case Key_F9: //activity
313 hide();
314// qDebug("Audio F9");
301 break; 315 break;
302 case Key_F10: //contacts 316 case Key_F10: //contacts
303 break; 317 break;
304 case Key_F11: //menu 318 case Key_F11: //menu
305 break; 319 break;
306 case Key_F12: //home 320 case Key_F12: //home
307 break; 321 break;
308 case Key_F13: //mail 322 case Key_F13: //mail
309 break; 323 break;
310 case Key_Space: { 324 case Key_Space: {
311 if(mediaPlayerState->playing()) { 325 if(mediaPlayerState->playing()) {
312// toggleButton(1); 326// toggleButton(1);
313 mediaPlayerState->setPlaying(FALSE); 327 mediaPlayerState->setPlaying(FALSE);
314// toggleButton(1); 328// toggleButton(1);
315 } else { 329 } else {
316// toggleButton(0); 330// toggleButton(0);
317 mediaPlayerState->setPlaying(TRUE); 331 mediaPlayerState->setPlaying(TRUE);
318// toggleButton(0); 332// toggleButton(0);
319 } 333 }
320 } 334 }
321 break; 335 break;
322 case Key_Down: 336 case Key_Down:
323 toggleButton(6); 337 toggleButton(6);
324 emit lessClicked(); 338 emit lessClicked();
325 emit lessReleased(); 339 emit lessReleased();
326 toggleButton(6); 340 toggleButton(6);
327 break; 341 break;
328 case Key_Up: 342 case Key_Up:
329 toggleButton(5); 343 toggleButton(5);
330 emit moreClicked(); 344 emit moreClicked();
331 emit moreReleased(); 345 emit moreReleased();
332 toggleButton(5); 346 toggleButton(5);
333 break; 347 break;
334 case Key_Right: 348 case Key_Right:
335// toggleButton(3); 349// toggleButton(3);
336 mediaPlayerState->setNext(); 350 mediaPlayerState->setNext();
337// toggleButton(3); 351// toggleButton(3);
338 break; 352 break;
339 case Key_Left: 353 case Key_Left:
340// toggleButton(4); 354// toggleButton(4);
341 mediaPlayerState->setPrev(); 355 mediaPlayerState->setPrev();
342// toggleButton(4); 356// toggleButton(4);
343 break; 357 break;
344 case Key_Escape: 358 case Key_Escape:
345 break; 359 break;
346 360
347 }; 361 };
348} 362}
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index 4ffd167..41ae4b6 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -1,145 +1,145 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef AUDIO_WIDGET_H 21#ifndef AUDIO_WIDGET_H
22#define AUDIO_WIDGET_H 22#define AUDIO_WIDGET_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qslider.h> 29#include <qslider.h>
30#include <qframe.h> 30#include <qframe.h>
31 31
32 32
33class QPixmap; 33class QPixmap;
34 34
35 35
36enum AudioButtons { 36enum AudioButtons {
37 AudioPlay, 37 AudioPlay,
38 AudioStop, 38 AudioStop,
39 AudioPause, 39 AudioPause,
40 AudioNext, 40 AudioNext,
41 AudioPrevious, 41 AudioPrevious,
42 AudioVolumeUp, 42 AudioVolumeUp,
43 AudioVolumeDown, 43 AudioVolumeDown,
44 AudioLoop, 44 AudioLoop,
45 AudioPlayList 45 AudioPlayList
46}; 46};
47 47
48 48
49#define USE_DBLBUF 49#define USE_DBLBUF
50 50
51 51
52class Ticker : public QFrame { 52class Ticker : public QFrame {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 Ticker( QWidget* parent=0 ) : QFrame( parent ) { 55 Ticker( QWidget* parent=0 ) : QFrame( parent ) {
56 setFrameStyle( WinPanel | Sunken ); 56 setFrameStyle( WinPanel | Sunken );
57 setText( "No Song" ); 57 setText( "No Song" );
58 } 58 }
59 ~Ticker() { } 59 ~Ticker() { }
60 void setText( const QString& text ) { 60 void setText( const QString& text ) {
61 pos = 0; // reset it everytime the text is changed 61 pos = 0; // reset it everytime the text is changed
62 scrollText = text; 62 scrollText = text;
63 pixelLen = fontMetrics().width( scrollText ); 63 pixelLen = fontMetrics().width( scrollText );
64 killTimers(); 64 killTimers();
65 if ( pixelLen > width() ) 65 if ( pixelLen > width() )
66 startTimer( 50 ); 66 startTimer( 50 );
67 update(); 67 update();
68 } 68 }
69protected: 69protected:
70 void timerEvent( QTimerEvent * ) { 70 void timerEvent( QTimerEvent * ) {
71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
72#ifndef USE_DBLBUF 72#ifndef USE_DBLBUF
73 scroll( -1, 0, contentsRect() ); 73 scroll( -1, 0, contentsRect() );
74#else 74#else
75 repaint( FALSE ); 75 repaint( FALSE );
76#endif 76#endif
77 } 77 }
78 void drawContents( QPainter *p ) { 78 void drawContents( QPainter *p ) {
79#ifndef USE_DBLBUF 79#ifndef USE_DBLBUF
80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
82#else 82#else
83 // Double buffering code. 83 // Double buffering code.
84 // Looks like qvfb makes it look like it flickers but I don't think it really is 84 // Looks like qvfb makes it look like it flickers but I don't think it really is
85 QPixmap pm( width(), height() ); 85 QPixmap pm( width(), height() );
86 pm.fill( colorGroup().base() ); 86 pm.fill( colorGroup().base() );
87 QPainter pmp( &pm ); 87 QPainter pmp( &pm );
88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
90 p->drawPixmap( 0, 0, pm ); 90 p->drawPixmap( 0, 0, pm );
91#endif 91#endif
92 } 92 }
93private: 93private:
94 QString scrollText; 94 QString scrollText;
95 int pos, pixelLen; 95 int pos, pixelLen;
96}; 96};
97 97
98 98
99class AudioWidget : public QWidget { 99class AudioWidget : public QWidget {
100 Q_OBJECT 100 Q_OBJECT
101public: 101public:
102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
103 ~AudioWidget(); 103 ~AudioWidget();
104 void setTickerText( const QString &text ) { songInfo->setText( text ); } 104 void setTickerText( const QString &text ) { songInfo->setText( text ); }
105 bool isStreaming; 105 bool isStreaming;
106public slots: 106public slots:
107 void updateSlider( long, long ); 107 void updateSlider( long, long );
108 void sliderPressed( ); 108 void sliderPressed( );
109 void sliderReleased( ); 109 void sliderReleased( );
110 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 110 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
113 void setPosition( long ); 113 void setPosition( long );
114 void setLength( long ); 114 void setLength( long );
115 void setView( char ); 115 void setView( char );
116 116
117signals: 117signals:
118 void moreClicked(); 118 void moreClicked();
119 void lessClicked(); 119 void lessClicked();
120 void moreReleased(); 120 void moreReleased();
121 void lessReleased(); 121 void lessReleased();
122 void sliderMoved(long); 122 void sliderMoved(long);
123 123
124protected: 124protected:
125 void paintEvent( QPaintEvent *pe ); 125 void paintEvent( QPaintEvent *pe );
126 void showEvent( QShowEvent *se ); 126 void showEvent( QShowEvent *se );
127 void mouseMoveEvent( QMouseEvent *event ); 127 void mouseMoveEvent( QMouseEvent *event );
128 void mousePressEvent( QMouseEvent *event ); 128 void mousePressEvent( QMouseEvent *event );
129 void mouseReleaseEvent( QMouseEvent *event ); 129 void mouseReleaseEvent( QMouseEvent *event );
130 void timerEvent( QTimerEvent *event ); 130 void timerEvent( QTimerEvent *event );
131 void closeEvent( QCloseEvent *event ); 131 void closeEvent( QCloseEvent *event );
132 void keyReleaseEvent( QKeyEvent *e); 132 void keyReleaseEvent( QKeyEvent *e);
133 133 void showMe();
134private: 134private:
135 void toggleButton( int ); 135 void toggleButton( int );
136 void setToggleButton( int, bool ); 136 void setToggleButton( int, bool );
137 void paintButton( QPainter *p, int i ); 137 void paintButton( QPainter *p, int i );
138 QPixmap *pixmaps[4]; 138 QPixmap *pixmaps[4];
139 Ticker *songInfo; 139 Ticker *songInfo;
140 QSlider *slider; 140 QSlider *slider;
141}; 141};
142 142
143 143
144#endif // AUDIO_WIDGET_H 144#endif // AUDIO_WIDGET_H
145 145
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 7005886..faa8e56 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -1,480 +1,477 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added changes Fri 02-15-2002 20// L.J.Potter added changes Fri 02-15-2002
21 21
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23 23
24#ifdef Q_WS_QWS 24#ifdef Q_WS_QWS
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#endif 26#endif
27#include <stdio.h> 27#include <stdio.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <string.h> 29#include <string.h>
30#include <pthread.h> 30#include <pthread.h>
31#include <errno.h> 31#include <errno.h>
32#include <unistd.h> 32#include <unistd.h>
33#include "loopcontrol.h" 33#include "loopcontrol.h"
34#include "videowidget.h" 34#include "videowidget.h"
35#include "audiodevice.h" 35#include "audiodevice.h"
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38 38
39 39
40extern VideoWidget *videoUI; // now only needed to tell it to play a frame 40extern VideoWidget *videoUI; // now only needed to tell it to play a frame
41extern MediaPlayerState *mediaPlayerState; 41extern MediaPlayerState *mediaPlayerState;
42 42
43 43
44//#define DecodeLoopDebug(x) qDebug x 44//#define DecodeLoopDebug(x) qDebug x
45#define DecodeLoopDebug(x) 45#define DecodeLoopDebug(x)
46 46
47 47
48static char *audioBuffer = NULL; 48static char *audioBuffer = NULL;
49static AudioDevice *audioDevice = NULL; 49static AudioDevice *audioDevice = NULL;
50static bool disabledSuspendScreenSaver = FALSE; 50static bool disabledSuspendScreenSaver = FALSE;
51static bool previousSuspendMode = FALSE; 51static bool previousSuspendMode = FALSE;
52 52
53 53
54pthread_t audio_tid; 54pthread_t audio_tid;
55pthread_attr_t audio_attr; 55pthread_attr_t audio_attr;
56bool threadOkToGo = FALSE; 56bool threadOkToGo = FALSE;
57 57
58 58
59class Mutex { 59class Mutex {
60public: 60public:
61 Mutex() { 61 Mutex() {
62 pthread_mutexattr_t attr; 62 pthread_mutexattr_t attr;
63 pthread_mutexattr_init( &attr ); 63 pthread_mutexattr_init( &attr );
64 pthread_mutex_init( &mutex, &attr ); 64 pthread_mutex_init( &mutex, &attr );
65 pthread_mutexattr_destroy( &attr ); 65 pthread_mutexattr_destroy( &attr );
66 } 66 }
67 67
68 ~Mutex() { 68 ~Mutex() {
69 pthread_mutex_destroy( &mutex ); 69 pthread_mutex_destroy( &mutex );
70 } 70 }
71 71
72 void lock() { 72 void lock() {
73 pthread_mutex_lock( &mutex ); 73 pthread_mutex_lock( &mutex );
74 } 74 }
75 75
76 void unlock() { 76 void unlock() {
77 pthread_mutex_unlock( &mutex ); 77 pthread_mutex_unlock( &mutex );
78 } 78 }
79private: 79private:
80 pthread_mutex_t mutex; 80 pthread_mutex_t mutex;
81}; 81};
82 82
83 83
84void *startAudioThread( void *ptr ) { 84void *startAudioThread( void *ptr ) {
85 LoopControl *mpegView = (LoopControl *)ptr; 85 LoopControl *mpegView = (LoopControl *)ptr;
86 while ( TRUE ) { 86 while ( TRUE ) {
87 if ( threadOkToGo && mpegView->moreAudio ) 87 if ( threadOkToGo && mpegView->moreAudio )
88 mpegView->startAudio(); 88 mpegView->startAudio();
89 else 89 else
90 usleep( 10000 ); // Semi-buzy-wait till we are playing again 90 usleep( 10000 ); // Semi-buzy-wait till we are playing again
91 } 91 }
92 return 0; 92 return 0;
93} 93}
94 94
95 95
96Mutex *audioMutex; 96Mutex *audioMutex;
97 97
98 98
99LoopControl::LoopControl( QObject *parent, const char *name ) 99LoopControl::LoopControl( QObject *parent, const char *name )
100 : QObject( parent, name ) { 100 : QObject( parent, name ) {
101 isMuted = FALSE; 101 isMuted = FALSE;
102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
103//qDebug("starting loopcontrol"); 103//qDebug("starting loopcontrol");
104 audioMutex = new Mutex; 104 audioMutex = new Mutex;
105 105
106 pthread_attr_init(&audio_attr); 106 pthread_attr_init(&audio_attr);
107#define USE_REALTIME_AUDIO_THREAD 107#define USE_REALTIME_AUDIO_THREAD
108#ifdef USE_REALTIME_AUDIO_THREAD 108#ifdef USE_REALTIME_AUDIO_THREAD
109 // Attempt to set it to real-time round robin 109 // Attempt to set it to real-time round robin
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
111 sched_param params; 111 sched_param params;
112 params.sched_priority = 50; 112 params.sched_priority = 50;
113 pthread_attr_setschedparam(&audio_attr,&params); 113 pthread_attr_setschedparam(&audio_attr,&params);
114 } else { 114 } else {
115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
116 pthread_attr_destroy(&audio_attr); 116 pthread_attr_destroy(&audio_attr);
117 pthread_attr_init(&audio_attr); 117 pthread_attr_init(&audio_attr);
118 } 118 }
119#endif 119#endif
120//qDebug("create audio thread"); 120//qDebug("create audio thread");
121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
122} 122}
123 123
124 124
125LoopControl::~LoopControl() { 125LoopControl::~LoopControl() {
126 stop(); 126 stop();
127} 127}
128 128
129 129
130static long prev_frame = 0; 130static long prev_frame = 0;
131static int currentSample = 0; 131static int currentSample = 0;
132 132
133 133
134void LoopControl::timerEvent( QTimerEvent *te ) { 134void LoopControl::timerEvent( QTimerEvent *te ) {
135 135
136 if ( te->timerId() == videoId ) 136 if ( te->timerId() == videoId )
137 startVideo(); 137 startVideo();
138 138
139 if ( te->timerId() == sliderId ) { 139 if ( te->timerId() == sliderId ) {
140 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 140 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
141 mediaPlayerState->updatePosition( audioSampleCounter ); 141 mediaPlayerState->updatePosition( audioSampleCounter );
142 } else if ( hasVideoChannel && moreVideo ) { 142 } else if ( hasVideoChannel && moreVideo ) {
143 mediaPlayerState->updatePosition( current_frame ); 143 mediaPlayerState->updatePosition( current_frame );
144 } 144 }
145 } 145 }
146 146
147 if ( !moreVideo && !moreAudio ) { 147 if ( !moreVideo && !moreAudio ) {
148 mediaPlayerState->setPlaying( FALSE ); 148 mediaPlayerState->setPlaying( FALSE );
149 mediaPlayerState->setNext(); 149 mediaPlayerState->setNext();
150 } 150 }
151} 151}
152 152
153 153
154void LoopControl::setPosition( long pos ) { 154void LoopControl::setPosition( long pos ) {
155 audioMutex->lock(); 155 audioMutex->lock();
156 156
157 if ( hasVideoChannel && hasAudioChannel ) { 157 if ( hasVideoChannel && hasAudioChannel ) {
158 playtime.restart(); 158 playtime.restart();
159 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 159 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
160 current_frame = pos + 1; 160 current_frame = pos + 1;
161 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 161 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
162 prev_frame = current_frame - 1; 162 prev_frame = current_frame - 1;
163 currentSample = (int)( (double)current_frame * freq / framerate ); 163 currentSample = (int)( (double)current_frame * freq / framerate );
164 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 164 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
165 audioSampleCounter = currentSample - 1; 165 audioSampleCounter = currentSample - 1;
166 } else if ( hasVideoChannel ) { 166 } else if ( hasVideoChannel ) {
167 playtime.restart(); 167 playtime.restart();
168 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 168 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
169 current_frame = pos + 1; 169 current_frame = pos + 1;
170 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 170 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
171 prev_frame = current_frame - 1; 171 prev_frame = current_frame - 1;
172 } else if ( hasAudioChannel ) { 172 } else if ( hasAudioChannel ) {
173 playtime.restart(); 173 playtime.restart();
174 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 174 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
175 currentSample = pos + 1; 175 currentSample = pos + 1;
176 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 176 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
177 audioSampleCounter = currentSample - 1; 177 audioSampleCounter = currentSample - 1;
178 } 178 }
179 179
180 audioMutex->unlock(); 180 audioMutex->unlock();
181} 181}
182 182
183 183
184void LoopControl::startVideo() { 184void LoopControl::startVideo() {
185 185
186 if ( moreVideo ) { 186 if ( moreVideo ) {
187 187
188 if ( mediaPlayerState->curDecoder() ) { 188 if ( mediaPlayerState->curDecoder() ) {
189 189
190 if ( hasAudioChannel && !isMuted ) { 190 if ( hasAudioChannel && !isMuted ) {
191 191
192 current_frame = long( playtime.elapsed() * framerate / 1000 ); 192 current_frame = long( playtime.elapsed() * framerate / 1000 );
193 193
194 if ( prev_frame != -1 && current_frame <= prev_frame ) 194 if ( prev_frame != -1 && current_frame <= prev_frame )
195 return; 195 return;
196 196
197 } else { 197 } else {
198 // Don't skip 198 // Don't skip
199 current_frame++; 199 current_frame++;
200 } 200 }
201 201
202 if ( prev_frame == -1 || current_frame > prev_frame ) { 202 if ( prev_frame == -1 || current_frame > prev_frame ) {
203 if ( current_frame > prev_frame + 1 ) { 203 if ( current_frame > prev_frame + 1 ) {
204 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 204 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
205 } 205 }
206 moreVideo = videoUI->playVideo(); 206 moreVideo = videoUI->playVideo();
207 prev_frame = current_frame; 207 prev_frame = current_frame;
208 } 208 }
209 209
210 } else { 210 } else {
211 211
212 moreVideo = FALSE; 212 moreVideo = FALSE;
213 killTimer( videoId ); 213 killTimer( videoId );
214 214
215 } 215 }
216 216
217 } 217 }
218} 218}
219 219
220 220
221void LoopControl::startAudio() { 221void LoopControl::startAudio() {
222 222
223//qDebug("start audio"); 223//qDebug("start audio");
224 audioMutex->lock(); 224 audioMutex->lock();
225 if ( moreAudio ) { 225 if ( moreAudio ) {
226 226
227 if ( !isMuted && mediaPlayerState->curDecoder() ) { 227 if ( !isMuted && mediaPlayerState->curDecoder() ) {
228 228
229 currentSample = audioSampleCounter + 1; 229 currentSample = audioSampleCounter + 1;
230 230
231 if ( currentSample != audioSampleCounter + 1 ) 231 if ( currentSample != audioSampleCounter + 1 )
232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
233 233
234 long samplesRead = 0; 234 long samplesRead = 0;
235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
237 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 237 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
238 238
239// this causes drop outs not sure why its even here 239// this causes drop outs not sure why its even here
240// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 240// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
241// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 241// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
242// } 242// }
243// else if ( sampleWaitTime <= -5000 ) { 243// else if ( sampleWaitTime <= -5000 ) {
244// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 244// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
245// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 245// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
246// currentSample = sampleWeShouldBeAt; 246// currentSample = sampleWeShouldBeAt;
247// } 247// }
248 248
249 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 249 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
250 250
251 if( mediaPlayerState->isStreaming == FALSE) 251 if( mediaPlayerState->isStreaming == FALSE)
252 audioSampleCounter = currentSample + samplesRead - 1; 252 audioSampleCounter = currentSample + samplesRead - 1;
253 253
254 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 254 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
255 255
256 } else { 256 } else {
257 257
258 moreAudio = FALSE; 258 moreAudio = FALSE;
259 259
260 } 260 }
261 261
262 } 262 }
263 263
264 audioMutex->unlock(); 264 audioMutex->unlock();
265} 265}
266 266
267 267
268void LoopControl::killTimers() { 268void LoopControl::killTimers() {
269 269
270 audioMutex->lock(); 270 audioMutex->lock();
271 271
272 if ( hasVideoChannel ) 272 if ( hasVideoChannel )
273 killTimer( videoId ); 273 killTimer( videoId );
274 killTimer( sliderId ); 274 killTimer( sliderId );
275 threadOkToGo = FALSE; 275 threadOkToGo = FALSE;
276 276
277 audioMutex->unlock(); 277 audioMutex->unlock();
278} 278}
279 279
280 280
281void LoopControl::startTimers() { 281void LoopControl::startTimers() {
282 282
283 audioMutex->lock(); 283 audioMutex->lock();
284 284
285 moreVideo = FALSE; 285 moreVideo = FALSE;
286 moreAudio = FALSE; 286 moreAudio = FALSE;
287 287
288 if ( hasVideoChannel ) { 288 if ( hasVideoChannel ) {
289 moreVideo = TRUE; 289 moreVideo = TRUE;
290 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value 290 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
291 videoId = startTimer( mSecsBetweenFrames ); 291 videoId = startTimer( mSecsBetweenFrames );
292 } 292 }
293 293
294 if ( hasAudioChannel ) { 294 if ( hasAudioChannel ) {
295 moreAudio = TRUE; 295 moreAudio = TRUE;
296 threadOkToGo = TRUE; 296 threadOkToGo = TRUE;
297 } 297 }
298 298
299 sliderId = startTimer( 300 ); // update slider every 1/3 second 299 sliderId = startTimer( 300 ); // update slider every 1/3 second
300 300
301 audioMutex->unlock(); 301 audioMutex->unlock();
302} 302}
303 303
304 304
305void LoopControl::setPaused( bool pause ) { 305void LoopControl::setPaused( bool pause ) {
306 306
307 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 307 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
308 return; 308 return;
309 309
310 if ( pause ) { 310 if ( pause ) {
311 killTimers(); 311 killTimers();
312 } else { 312 } else {
313 // Force an update of the position 313 // Force an update of the position
314 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 314 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
315 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 315 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
316 // Just like we never stopped 316 // Just like we never stopped
317 startTimers(); 317 startTimers();
318 } 318 }
319} 319}
320 320
321 321
322void LoopControl::stop( bool willPlayAgainShortly ) { 322void LoopControl::stop( bool willPlayAgainShortly ) {
323 323
324#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 324#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
325 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 325 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
326 disabledSuspendScreenSaver = FALSE; 326 disabledSuspendScreenSaver = FALSE;
327 // Re-enable the suspend mode 327 // Re-enable the suspend mode
328 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 328 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
329 } 329 }
330#endif 330#endif
331 331
332 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 332 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
333 333
334 killTimers(); 334 killTimers();
335 335
336 audioMutex->lock(); 336 audioMutex->lock();
337 337
338 mediaPlayerState->curDecoder()->close(); 338 mediaPlayerState->curDecoder()->close();
339 339
340 if ( audioDevice ) { 340 if ( audioDevice ) {
341 delete audioDevice; 341 delete audioDevice;
342 delete audioBuffer; 342 delete audioBuffer;
343 audioDevice = 0; 343 audioDevice = 0;
344 audioBuffer = 0; 344 audioBuffer = 0;
345 } 345 }
346 346
347 audioMutex->unlock(); 347 audioMutex->unlock();
348 348
349 } 349 }
350} 350}
351 351
352 352
353bool LoopControl::init( const QString& filename ) { 353bool LoopControl::init( const QString& filename ) {
354 stop(); 354 stop();
355 355
356 audioMutex->lock(); 356 audioMutex->lock();
357 357
358 fileName = filename; 358 fileName = filename;
359 stream = 0; // only play stream 0 for now 359 stream = 0; // only play stream 0 for now
360 current_frame = total_video_frames = total_audio_samples = 0; 360 current_frame = total_video_frames = total_audio_samples = 0;
361 361
362 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 362 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
363 363
364 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 364 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
365 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 365 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
366 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 366 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
367 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 367 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
368 mediaPlayerState->libMpeg3Decoder()->close(); 368 mediaPlayerState->libMpeg3Decoder()->close();
369 } 369 }
370 } 370 }
371 371
372 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 372 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
373 audioMutex->unlock(); 373 audioMutex->unlock();
374 return FALSE; 374 return FALSE;
375 } 375 }
376 376
377 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 377 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
378 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 378 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
379 379
380 if ( hasAudioChannel ) { 380 if ( hasAudioChannel ) {
381 int astream = 0; 381 int astream = 0;
382 382
383 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 383 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
384 qDebug( "LC- channels = %d", channels ); 384 qDebug( "LC- channels = %d", channels );
385 385
386 if ( !total_audio_samples ) 386 if ( !total_audio_samples )
387 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 387 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
388 388
389// total_audio_samples += 1000; 389// total_audio_samples += 1000;
390 390
391 mediaPlayerState->setLength( total_audio_samples ); 391 mediaPlayerState->setLength( total_audio_samples );
392 392
393 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 393 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
394 qDebug( "LC- frequency = %d", freq ); 394 qDebug( "LC- frequency = %d", freq );
395 395
396 audioSampleCounter = 0; 396 audioSampleCounter = 0;
397 int bits_per_sample; 397 int bits_per_sample;
398 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { 398 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
399 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); 399 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
400 qDebug("using stupid hack"); 400 qDebug("using stupid hack");
401 } else { 401 } else {
402 bits_per_sample=0; 402 bits_per_sample=0;
403 } 403 }
404 404
405 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 405 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
406 audioBuffer = new char[ audioDevice->bufferSize() ]; 406 audioBuffer = new char[ audioDevice->bufferSize() ];
407 channels = audioDevice->channels(); 407 channels = audioDevice->channels();
408 408
409 //### must check which frequency is actually used. 409 //### must check which frequency is actually used.
410 static const int size = 1; 410 static const int size = 1;
411 short int buf[size]; 411 short int buf[size];
412 long samplesRead = 0; 412 long samplesRead = 0;
413 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 413 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
414 } 414 }
415 415
416 if ( hasVideoChannel ) { 416 if ( hasVideoChannel ) {
417 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 417 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
418 418
419 mediaPlayerState->setLength( total_video_frames ); 419 mediaPlayerState->setLength( total_video_frames );
420 420
421 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 421 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
422 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 422 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
423 423
424 if ( framerate <= 1.0 ) { 424 if ( framerate <= 1.0 ) {
425 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 425 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
426 framerate = 25; 426 framerate = 25;
427 } 427 }
428 428
429 if ( total_video_frames == 1 ) { 429 if ( total_video_frames == 1 ) {
430 DecodeLoopDebug(( "Cannot seek to frame" )); 430 DecodeLoopDebug(( "Cannot seek to frame" ));
431 } 431 }
432 432
433 } 433 }
434 434
435 current_frame = 0; 435 current_frame = 0;
436 prev_frame = -1; 436 prev_frame = -1;
437 437
438 if( fileName.left(7) == "http://")
439 mediaPlayerState->isStreaming = TRUE;
440
441 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 438 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
442 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 439 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
443 440
444 audioMutex->unlock(); 441 audioMutex->unlock();
445 442
446 return TRUE; 443 return TRUE;
447} 444}
448 445
449 446
450void LoopControl::play() { 447void LoopControl::play() {
451 qDebug("LC- play"); 448 qDebug("LC- play");
452#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 449#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
453 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { 450 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
454 disabledSuspendScreenSaver = TRUE; 451 disabledSuspendScreenSaver = TRUE;
455 previousSuspendMode = hasVideoChannel; 452 previousSuspendMode = hasVideoChannel;
456 // Stop the screen from blanking and power saving state 453 // Stop the screen from blanking and power saving state
457 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 454 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
458 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 455 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
459 } 456 }
460#endif 457#endif
461 458
462 playtime.start(); 459 playtime.start();
463 startTimers(); 460 startTimers();
464} 461}
465 462
466 463
467void LoopControl::setMute( bool on ) { 464void LoopControl::setMute( bool on ) {
468 if ( on != isMuted ) { 465 if ( on != isMuted ) {
469 isMuted = on; 466 isMuted = on;
470 if ( !on ) { 467 if ( !on ) {
471 // Force an update of the position 468 // Force an update of the position
472 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 469 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
473 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 470 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
474 // Resume playing audio 471 // Resume playing audio
475 moreAudio = TRUE; 472 moreAudio = TRUE;
476 } 473 }
477 } 474 }
478} 475}
479 476
480 477
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index e0c4dba..ab46a7d 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -1,184 +1,187 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/qlibrary.h> 22#include <qpe/qlibrary.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25 25
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include "mediaplayer.h" 31#include "mediaplayer.h"
32#include "playlistwidget.h" 32#include "playlistwidget.h"
33#include "audiowidget.h" 33#include "audiowidget.h"
34#include "loopcontrol.h" 34#include "loopcontrol.h"
35#include "audiodevice.h" 35#include "audiodevice.h"
36 36
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38 38
39 39
40extern AudioWidget *audioUI; 40extern AudioWidget *audioUI;
41extern PlayListWidget *playList; 41extern PlayListWidget *playList;
42extern LoopControl *loopControl; 42extern LoopControl *loopControl;
43extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
44 44
45 45
46MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 46MediaPlayer::MediaPlayer( QObject *parent, const char *name )
47 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 47 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
48 QPEApplication::grabKeyboard();
48 49
49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
51 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 52 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
52 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 53 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
53 54
54 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 55 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
55 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 56 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
56 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 57 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
57 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 58 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
58} 59}
59 60
60 61
61MediaPlayer::~MediaPlayer() { 62MediaPlayer::~MediaPlayer() {
63 QPEApplication::grabKeyboard();
64 QPEApplication::ungrabKeyboard();
62} 65}
63 66
64 67
65void MediaPlayer::pauseCheck( bool b ) { 68void MediaPlayer::pauseCheck( bool b ) {
66 // Only pause if playing 69 // Only pause if playing
67 if ( b && !mediaPlayerState->playing() ) 70 if ( b && !mediaPlayerState->playing() )
68 mediaPlayerState->setPaused( FALSE ); 71 mediaPlayerState->setPaused( FALSE );
69} 72}
70 73
71 74
72void MediaPlayer::play() { 75void MediaPlayer::play() {
73 mediaPlayerState->setPlaying( FALSE ); 76 mediaPlayerState->setPlaying( FALSE );
74 mediaPlayerState->setPlaying( TRUE ); 77 mediaPlayerState->setPlaying( TRUE );
75} 78}
76 79
77 80
78void MediaPlayer::setPlaying( bool play ) { 81void MediaPlayer::setPlaying( bool play ) {
79 if ( !play ) { 82 if ( !play ) {
80 mediaPlayerState->setPaused( FALSE ); 83 mediaPlayerState->setPaused( FALSE );
81 loopControl->stop( FALSE ); 84 loopControl->stop( FALSE );
82 return; 85 return;
83 } 86 }
84 87
85 if ( mediaPlayerState->paused() ) { 88 if ( mediaPlayerState->paused() ) {
86 mediaPlayerState->setPaused( FALSE ); 89 mediaPlayerState->setPaused( FALSE );
87 return; 90 return;
88 } 91 }
89 92
90 const DocLnk *playListCurrent = playList->current(); 93 const DocLnk *playListCurrent = playList->current();
91 if ( playListCurrent != NULL ) { 94 if ( playListCurrent != NULL ) {
92 loopControl->stop( TRUE ); 95 loopControl->stop( TRUE );
93 currentFile = playListCurrent; 96 currentFile = playListCurrent;
94 } 97 }
95 if ( currentFile == NULL ) { 98 if ( currentFile == NULL ) {
96 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); 99 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
97 mediaPlayerState->setPlaying( FALSE ); 100 mediaPlayerState->setPlaying( FALSE );
98 return; 101 return;
99 } 102 }
100 103
101 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 104 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
102 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 105 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
103 mediaPlayerState->setPlaying( FALSE ); 106 mediaPlayerState->setPlaying( FALSE );
104 return; 107 return;
105 } 108 }
106 109
107 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 110 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
108 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 111 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
109 mediaPlayerState->setPlaying( FALSE ); 112 mediaPlayerState->setPlaying( FALSE );
110 return; 113 return;
111 } 114 }
112 115
113 if ( !loopControl->init( currentFile->file() ) ) { 116 if ( !loopControl->init( currentFile->file() ) ) {
114 QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); 117 QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
115 mediaPlayerState->setPlaying( FALSE ); 118 mediaPlayerState->setPlaying( FALSE );
116 return; 119 return;
117 } 120 }
118 long seconds = loopControl->totalPlaytime(); 121 long seconds = loopControl->totalPlaytime();
119 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 122 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
120 QString tickerText; 123 QString tickerText;
121 if( currentFile->file().left(4) == "http" ) 124 if( currentFile->file().left(4) == "http" )
122 tickerText= tr( " File: " ) + currentFile->name(); 125 tickerText= tr( " File: " ) + currentFile->name();
123 else 126 else
124 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 127 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
125 128
126 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); 129 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
127 if ( !fileInfo.isEmpty() ) 130 if ( !fileInfo.isEmpty() )
128 tickerText += ", " + fileInfo; 131 tickerText += ", " + fileInfo;
129 audioUI->setTickerText( tickerText + "." ); 132 audioUI->setTickerText( tickerText + "." );
130 133
131 loopControl->play(); 134 loopControl->play();
132 135
133 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); 136 mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
134} 137}
135 138
136 139
137void MediaPlayer::prev() { 140void MediaPlayer::prev() {
138 if ( playList->prev() ) 141 if ( playList->prev() )
139 play(); 142 play();
140 else if ( mediaPlayerState->looping() ) { 143 else if ( mediaPlayerState->looping() ) {
141 if ( playList->last() ) 144 if ( playList->last() )
142 play(); 145 play();
143 } else 146 } else
144 mediaPlayerState->setList(); 147 mediaPlayerState->setList();
145} 148}
146 149
147 150
148void MediaPlayer::next() { 151void MediaPlayer::next() {
149 if ( playList->next() ) 152 if ( playList->next() )
150 play(); 153 play();
151 else if ( mediaPlayerState->looping() ) { 154 else if ( mediaPlayerState->looping() ) {
152 if ( playList->first() ) 155 if ( playList->first() )
153 play(); 156 play();
154 } else 157 } else
155 mediaPlayerState->setList(); 158 mediaPlayerState->setList();
156} 159}
157 160
158 161
159void MediaPlayer::startDecreasingVolume() { 162void MediaPlayer::startDecreasingVolume() {
160 volumeDirection = -1; 163 volumeDirection = -1;
161 startTimer( 100 ); 164 startTimer( 100 );
162 AudioDevice::decreaseVolume(); 165 AudioDevice::decreaseVolume();
163} 166}
164 167
165 168
166void MediaPlayer::startIncreasingVolume() { 169void MediaPlayer::startIncreasingVolume() {
167 volumeDirection = +1; 170 volumeDirection = +1;
168 startTimer( 100 ); 171 startTimer( 100 );
169 AudioDevice::increaseVolume(); 172 AudioDevice::increaseVolume();
170} 173}
171 174
172 175
173void MediaPlayer::stopChangingVolume() { 176void MediaPlayer::stopChangingVolume() {
174 killTimers(); 177 killTimers();
175} 178}
176 179
177 180
178void MediaPlayer::timerEvent( QTimerEvent * ) { 181void MediaPlayer::timerEvent( QTimerEvent * ) {
179 if ( volumeDirection == +1 ) 182 if ( volumeDirection == +1 )
180 AudioDevice::increaseVolume(); 183 AudioDevice::increaseVolume();
181 else if ( volumeDirection == -1 ) 184 else if ( volumeDirection == -1 )
182 AudioDevice::decreaseVolume(); 185 AudioDevice::decreaseVolume();
183} 186}
184 187
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h
index d6e90cb..0354d21 100644
--- a/core/multimedia/opieplayer/mediaplayer.h
+++ b/core/multimedia/opieplayer/mediaplayer.h
@@ -1,58 +1,59 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MEDIA_PLAYER_H 20#ifndef MEDIA_PLAYER_H
21#define MEDIA_PLAYER_H 21#define MEDIA_PLAYER_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qpe/qlibrary.h> 25#include <qpe/qlibrary.h>
26#include <qpe/mediaplayerplugininterface.h> 26#include <qpe/mediaplayerplugininterface.h>
27 27
28 28
29class DocLnk; 29class DocLnk;
30 30
31 31
32class MediaPlayer : public QObject { 32class MediaPlayer : public QObject {
33 Q_OBJECT 33 Q_OBJECT
34public: 34public:
35 MediaPlayer( QObject *parent, const char *name ); 35 MediaPlayer( QObject *parent, const char *name );
36 ~MediaPlayer(); 36 ~MediaPlayer();
37 37
38private slots: 38private slots:
39 void setPlaying( bool ); 39 void setPlaying( bool );
40 void pauseCheck( bool ); 40 void pauseCheck( bool );
41 void play(); 41 void play();
42 void next(); 42 void next();
43 void prev(); 43 void prev();
44 void startIncreasingVolume(); 44 void startIncreasingVolume();
45 void startDecreasingVolume(); 45 void startDecreasingVolume();
46 void stopChangingVolume(); 46 void stopChangingVolume();
47 47
48protected: 48protected:
49 void timerEvent( QTimerEvent *e ); 49 void timerEvent( QTimerEvent *e );
50// void keyReleaseEvent( QKeyEvent *e);
50 51
51private: 52private:
52 int volumeDirection; 53 int volumeDirection;
53 const DocLnk *currentFile; 54 const DocLnk *currentFile;
54}; 55};
55 56
56 57
57#endif // MEDIA_PLAYER_H 58#endif // MEDIA_PLAYER_H
58 59
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index 4e14436..3ac9ac4 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,191 +1,195 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qdir.h> 25#include <qdir.h>
26#include <qpe/mediaplayerplugininterface.h> 26#include <qpe/mediaplayerplugininterface.h>
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29 29
30 30
31#ifdef QT_NO_COMPONENT 31#ifdef QT_NO_COMPONENT
32// Plugins which are compiled in when no plugin architecture available 32// Plugins which are compiled in when no plugin architecture available
33#include "libmad/libmadpluginimpl.h" 33#include "libmad/libmadpluginimpl.h"
34#include "libmpeg3/libmpeg3pluginimpl.h" 34#include "libmpeg3/libmpeg3pluginimpl.h"
35#include "wavplugin/wavpluginimpl.h" 35#include "wavplugin/wavpluginimpl.h"
36#endif 36#endif
37 37
38 38
39//#define MediaPlayerDebug(x) qDebug x 39//#define MediaPlayerDebug(x) qDebug x
40#define MediaPlayerDebug(x) 40#define MediaPlayerDebug(x)
41 41
42 42
43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
45 Config cfg( "OpiePlayer" ); 45 Config cfg( "OpiePlayer" );
46 readConfig( cfg ); 46 readConfig( cfg );
47 loadPlugins(); 47 loadPlugins();
48} 48}
49 49
50 50
51MediaPlayerState::~MediaPlayerState() { 51MediaPlayerState::~MediaPlayerState() {
52 Config cfg( "OpiePlayer" ); 52 Config cfg( "OpiePlayer" );
53 writeConfig( cfg ); 53 writeConfig( cfg );
54} 54}
55 55
56 56
57void MediaPlayerState::readConfig( Config& cfg ) { 57void MediaPlayerState::readConfig( Config& cfg ) {
58 cfg.setGroup("Options"); 58 cfg.setGroup("Options");
59 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 59 isFullscreen = cfg.readBoolEntry( "FullScreen" );
60 isScaled = cfg.readBoolEntry( "Scaling" ); 60 isScaled = cfg.readBoolEntry( "Scaling" );
61 isLooping = cfg.readBoolEntry( "Looping" ); 61 isLooping = cfg.readBoolEntry( "Looping" );
62 isShuffled = cfg.readBoolEntry( "Shuffle" ); 62 isShuffled = cfg.readBoolEntry( "Shuffle" );
63 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 63 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
64 usePlaylist = TRUE; 64 usePlaylist = TRUE;
65 isPlaying = FALSE; 65 isPlaying = FALSE;
66 isPaused = FALSE; 66 isPaused = FALSE;
67 curPosition = 0; 67 curPosition = 0;
68 curLength = 0; 68 curLength = 0;
69 curView = 'l'; 69 curView = 'l';
70} 70}
71 71
72 72
73void MediaPlayerState::writeConfig( Config& cfg ) const { 73void MediaPlayerState::writeConfig( Config& cfg ) const {
74 cfg.setGroup("Options"); 74 cfg.setGroup("Options");
75 cfg.writeEntry("FullScreen", isFullscreen ); 75 cfg.writeEntry("FullScreen", isFullscreen );
76 cfg.writeEntry("Scaling", isScaled ); 76 cfg.writeEntry("Scaling", isScaled );
77 cfg.writeEntry("Looping", isLooping ); 77 cfg.writeEntry("Looping", isLooping );
78 cfg.writeEntry("Shuffle", isShuffled ); 78 cfg.writeEntry("Shuffle", isShuffled );
79 cfg.writeEntry("UsePlayList", usePlaylist ); 79 cfg.writeEntry("UsePlayList", usePlaylist );
80} 80}
81 81
82 82
83struct MediaPlayerPlugin { 83struct MediaPlayerPlugin {
84#ifndef QT_NO_COMPONENT 84#ifndef QT_NO_COMPONENT
85 QLibrary *library; 85 QLibrary *library;
86#endif 86#endif
87 MediaPlayerPluginInterface *iface; 87 MediaPlayerPluginInterface *iface;
88 MediaPlayerDecoder *decoder; 88 MediaPlayerDecoder *decoder;
89 MediaPlayerEncoder *encoder; 89 MediaPlayerEncoder *encoder;
90}; 90};
91 91
92 92
93static QValueList<MediaPlayerPlugin> pluginList; 93static QValueList<MediaPlayerPlugin> pluginList;
94 94
95 95
96// Find the first decoder which supports this type of file 96// Find the first decoder which supports this type of file
97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
98 MediaPlayerDecoder *tmpDecoder = NULL; 98 MediaPlayerDecoder *tmpDecoder = NULL;
99 QValueList<MediaPlayerPlugin>::Iterator it; 99 QValueList<MediaPlayerPlugin>::Iterator it;
100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
101 if ( (*it).decoder->isFileSupported( file ) ) { 101 if ( (*it).decoder->isFileSupported( file ) ) {
102 tmpDecoder = (*it).decoder; 102 tmpDecoder = (*it).decoder;
103 break; 103 break;
104 } 104 }
105 } 105 }
106 if(file.left(4)=="http")
107 isStreaming = TRUE;
108 else
109 isStreaming = FALSE;
106 return decoder = tmpDecoder; 110 return decoder = tmpDecoder;
107} 111}
108 112
109 113
110MediaPlayerDecoder *MediaPlayerState::curDecoder() { 114MediaPlayerDecoder *MediaPlayerState::curDecoder() {
111 return decoder; 115 return decoder;
112} 116}
113 117
114 118
115// ### hack to get true sample count 119// ### hack to get true sample count
116MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 120MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
117 return libmpeg3decoder; 121 return libmpeg3decoder;
118} 122}
119 123
120// ### hack to get true sample count 124// ### hack to get true sample count
121// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { 125// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
122// return libwavdecoder; 126// return libwavdecoder;
123// } 127// }
124 128
125void MediaPlayerState::loadPlugins() { 129void MediaPlayerState::loadPlugins() {
126 qDebug("load plugins"); 130 qDebug("load plugins");
127#ifndef QT_NO_COMPONENT 131#ifndef QT_NO_COMPONENT
128 QValueList<MediaPlayerPlugin>::Iterator mit; 132 QValueList<MediaPlayerPlugin>::Iterator mit;
129 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 133 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
130 (*mit).iface->release(); 134 (*mit).iface->release();
131 (*mit).library->unload(); 135 (*mit).library->unload();
132 delete (*mit).library; 136 delete (*mit).library;
133 } 137 }
134 pluginList.clear(); 138 pluginList.clear();
135 139
136 QString path = QPEApplication::qpeDir() + "/plugins/codecs"; 140 QString path = QPEApplication::qpeDir() + "/plugins/codecs";
137 QDir dir( path, "lib*.so" ); 141 QDir dir( path, "lib*.so" );
138 QStringList list = dir.entryList(); 142 QStringList list = dir.entryList();
139 QStringList::Iterator it; 143 QStringList::Iterator it;
140 for ( it = list.begin(); it != list.end(); ++it ) { 144 for ( it = list.begin(); it != list.end(); ++it ) {
141 MediaPlayerPluginInterface *iface = 0; 145 MediaPlayerPluginInterface *iface = 0;
142 QLibrary *lib = new QLibrary( path + "/" + *it ); 146 QLibrary *lib = new QLibrary( path + "/" + *it );
143// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); 147// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
144 148
145 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { 149 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
146 150
147// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); 151// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() );
148 152
149 MediaPlayerPlugin plugin; 153 MediaPlayerPlugin plugin;
150 plugin.library = lib; 154 plugin.library = lib;
151 plugin.iface = iface; 155 plugin.iface = iface;
152 plugin.decoder = plugin.iface->decoder(); 156 plugin.decoder = plugin.iface->decoder();
153 plugin.encoder = plugin.iface->encoder(); 157 plugin.encoder = plugin.iface->encoder();
154 pluginList.append( plugin ); 158 pluginList.append( plugin );
155 159
156 // ### hack to get true sample count 160 // ### hack to get true sample count
157 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) 161 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
158 libmpeg3decoder = plugin.decoder; 162 libmpeg3decoder = plugin.decoder;
159 163
160 } else { 164 } else {
161 delete lib; 165 delete lib;
162 } 166 }
163 } 167 }
164#else 168#else
165 pluginList.clear(); 169 pluginList.clear();
166 170
167 MediaPlayerPlugin plugin0; 171 MediaPlayerPlugin plugin0;
168 plugin0.iface = new LibMpeg3PluginImpl; 172 plugin0.iface = new LibMpeg3PluginImpl;
169 plugin0.decoder = plugin0.iface->decoder(); 173 plugin0.decoder = plugin0.iface->decoder();
170 plugin0.encoder = plugin0.iface->encoder(); 174 plugin0.encoder = plugin0.iface->encoder();
171 pluginList.append( plugin0 ); 175 pluginList.append( plugin0 );
172 176
173 MediaPlayerPlugin plugin1; 177 MediaPlayerPlugin plugin1;
174 plugin1.iface = new LibMadPluginImpl; 178 plugin1.iface = new LibMadPluginImpl;
175 plugin1.decoder = plugin1.iface->decoder(); 179 plugin1.decoder = plugin1.iface->decoder();
176 plugin1.encoder = plugin1.iface->encoder(); 180 plugin1.encoder = plugin1.iface->encoder();
177 pluginList.append( plugin1 ); 181 pluginList.append( plugin1 );
178 182
179 MediaPlayerPlugin plugin2; 183 MediaPlayerPlugin plugin2;
180 plugin2.iface = new WavPluginImpl; 184 plugin2.iface = new WavPluginImpl;
181 plugin2.decoder = plugin2.iface->decoder(); 185 plugin2.decoder = plugin2.iface->decoder();
182 plugin2.encoder = plugin2.iface->encoder(); 186 plugin2.encoder = plugin2.iface->encoder();
183 pluginList.append( plugin2 ); 187 pluginList.append( plugin2 );
184#endif 188#endif
185 189
186 if ( pluginList.count() ) 190 if ( pluginList.count() )
187 MediaPlayerDebug(( "%i decoders found", pluginList.count() )); 191 MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
188 else 192 else
189 MediaPlayerDebug(( "No decoders found" )); 193 MediaPlayerDebug(( "No decoders found" ));
190} 194}
191 195
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 7c76400..faa6e3f 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1040 +1,1066 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22 22
23#include <qpe/qpemenubar.h> 23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/fileselector.h> 25#include <qpe/fileselector.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/lnkproperties.h> 27#include <qpe/lnkproperties.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29 29
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/global.h> 32#include <qpe/global.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34 34
35#include <qaction.h> 35#include <qaction.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qlayout.h> 39#include <qlayout.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qlist.h> 41#include <qlist.h>
42#include <qlistbox.h> 42#include <qlistbox.h>
43#include <qmainwindow.h> 43#include <qmainwindow.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qtoolbutton.h> 45#include <qtoolbutton.h>
46#include <qtabwidget.h> 46#include <qtabwidget.h>
47#include <qlistview.h> 47#include <qlistview.h>
48#include <qpoint.h> 48#include <qpoint.h>
49#include <qlineedit.h> 49#include <qlineedit.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qregexp.h> 51#include <qregexp.h>
52 52
53//#include <qtimer.h> 53//#include <qtimer.h>
54 54
55#include "playlistselection.h" 55#include "playlistselection.h"
56#include "playlistwidget.h" 56#include "playlistwidget.h"
57#include "mediaplayerstate.h" 57#include "mediaplayerstate.h"
58 58
59#include "inputDialog.h" 59#include "inputDialog.h"
60 60
61#include <stdlib.h> 61#include <stdlib.h>
62#include "audiowidget.h"
63#include "videowidget.h"
62 64
63#define BUTTONS_ON_TOOLBAR 65#define BUTTONS_ON_TOOLBAR
64#define SIDE_BUTTONS 66#define SIDE_BUTTONS
65#define CAN_SAVE_LOAD_PLAYLISTS 67#define CAN_SAVE_LOAD_PLAYLISTS
66 68
69extern AudioWidget *audioUI;
70extern VideoWidget *videoUI;
67extern MediaPlayerState *mediaPlayerState; 71extern MediaPlayerState *mediaPlayerState;
68 72
69// class myFileSelector { 73// class myFileSelector {
70 74
71// }; 75// };
72class PlayListWidgetPrivate { 76class PlayListWidgetPrivate {
73public: 77public:
74 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 78 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
75 QFrame *playListFrame; 79 QFrame *playListFrame;
76 FileSelector *files; 80 FileSelector *files;
77 PlayListSelection *selectedFiles; 81 PlayListSelection *selectedFiles;
78 bool setDocumentUsed; 82 bool setDocumentUsed;
79 DocLnk *current; 83 DocLnk *current;
80}; 84};
81 85
82 86
83class ToolButton : public QToolButton { 87class ToolButton : public QToolButton {
84public: 88public:
85 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 89 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
86 : QToolButton( parent, name ) { 90 : QToolButton( parent, name ) {
87 setTextLabel( name ); 91 setTextLabel( name );
88 setPixmap( Resource::loadPixmap( icon ) ); 92 setPixmap( Resource::loadPixmap( icon ) );
89 setAutoRaise( TRUE ); 93 setAutoRaise( TRUE );
90 setFocusPolicy( QWidget::NoFocus ); 94 setFocusPolicy( QWidget::NoFocus );
91 setToggleButton( t ); 95 setToggleButton( t );
92 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 96 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
93 QPEMenuToolFocusManager::manager()->addWidget( this ); 97 QPEMenuToolFocusManager::manager()->addWidget( this );
94 } 98 }
95}; 99};
96 100
97 101
98class MenuItem : public QAction { 102class MenuItem : public QAction {
99public: 103public:
100 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 104 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
101 : QAction( text, QString::null, 0, 0 ) { 105 : QAction( text, QString::null, 0, 0 ) {
102 connect( this, SIGNAL( activated() ), handler, slot ); 106 connect( this, SIGNAL( activated() ), handler, slot );
103 addTo( parent ); 107 addTo( parent );
104 } 108 }
105}; 109};
106 110
107 111
108PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 112PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
109 : QMainWindow( parent, name, fl ) { 113 : QMainWindow( parent, name, fl ) {
110 114
111 d = new PlayListWidgetPrivate; 115 d = new PlayListWidgetPrivate;
112 d->setDocumentUsed = FALSE; 116 d->setDocumentUsed = FALSE;
113 d->current = NULL; 117 d->current = NULL;
114 fromSetDocument = FALSE; 118 fromSetDocument = FALSE;
115 insanityBool=FALSE; 119 insanityBool=FALSE;
116// menuTimer = new QTimer( this ,"menu timer"), 120// menuTimer = new QTimer( this ,"menu timer"),
117// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 121// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
118 122
119 setBackgroundMode( PaletteButton ); 123 setBackgroundMode( PaletteButton );
120 124
121 setCaption( tr("OpiePlayer") ); 125 setCaption( tr("OpiePlayer") );
122 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 126 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
123 127
124 setToolBarsMovable( FALSE ); 128 setToolBarsMovable( FALSE );
125 129
126 // Create Toolbar 130 // Create Toolbar
127 QPEToolBar *toolbar = new QPEToolBar( this ); 131 QPEToolBar *toolbar = new QPEToolBar( this );
128 toolbar->setHorizontalStretchable( TRUE ); 132 toolbar->setHorizontalStretchable( TRUE );
129 133
130 // Create Menubar 134 // Create Menubar
131 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 135 QPEMenuBar *menu = new QPEMenuBar( toolbar );
132 menu->setMargin( 0 ); 136 menu->setMargin( 0 );
133 137
134 QPEToolBar *bar = new QPEToolBar( this ); 138 QPEToolBar *bar = new QPEToolBar( this );
135 bar->setLabel( tr( "Play Operations" ) ); 139 bar->setLabel( tr( "Play Operations" ) );
136// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 140// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
137// this , SLOT( addSelected()) ); 141// this , SLOT( addSelected()) );
138 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 142 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
139 tbDeletePlaylist->setFlat(TRUE); 143 tbDeletePlaylist->setFlat(TRUE);
140 tbDeletePlaylist->setFixedSize(20,20); 144 tbDeletePlaylist->setFixedSize(20,20);
141 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 145 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
142 146
143 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 147 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
144 this , SLOT(addSelected()) ); 148 this , SLOT(addSelected()) );
145 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 149 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
146 this , SLOT(removeSelected()) ); 150 this , SLOT(removeSelected()) );
147// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 151// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
148 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 152 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
149 this , SLOT( btnPlay(bool) ), TRUE ); 153 this , SLOT( btnPlay(bool) ), TRUE );
150 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 154 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
151 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 155 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
152 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 156 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
153 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 157 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
154 tbDeletePlaylist->hide(); 158 tbDeletePlaylist->hide();
155 159
156 QPopupMenu *pmPlayList = new QPopupMenu( this ); 160 QPopupMenu *pmPlayList = new QPopupMenu( this );
157 menu->insertItem( tr( "File" ), pmPlayList ); 161 menu->insertItem( tr( "File" ), pmPlayList );
158 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 162 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
159 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 163 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
160 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 164 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
161 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 165 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
162// pmPlayList->insertSeparator(-1); 166// pmPlayList->insertSeparator(-1);
163 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 167 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
164 pmPlayList->insertSeparator(-1); 168 pmPlayList->insertSeparator(-1);
165 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 169 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
166 170
167 QPopupMenu *pmView = new QPopupMenu( this ); 171 QPopupMenu *pmView = new QPopupMenu( this );
168 menu->insertItem( tr( "View" ), pmView ); 172 menu->insertItem( tr( "View" ), pmView );
169 173
170 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 174 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
171 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 175 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
172 fullScreenButton->addTo(pmView); 176 fullScreenButton->addTo(pmView);
173 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 177 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
174 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 178 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
175 scaleButton->addTo(pmView); 179 scaleButton->addTo(pmView);
176 180
177 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 181 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
178 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 182 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
179 183
180 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 184 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
181 185
182 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 186 tabWidget = new QTabWidget( hbox6, "tabWidget" );
183 tabWidget->setTabShape(QTabWidget::Triangular); 187 tabWidget->setTabShape(QTabWidget::Triangular);
184 188
185 QWidget *pTab; 189 QWidget *pTab;
186 pTab = new QWidget( tabWidget, "pTab" ); 190 pTab = new QWidget( tabWidget, "pTab" );
187// playlistView = new QListView( pTab, "playlistview" ); 191// playlistView = new QListView( pTab, "playlistview" );
188// playlistView->setMinimumSize(236,260); 192// playlistView->setMinimumSize(236,260);
189 tabWidget->insertTab( pTab,"Playlist"); 193 tabWidget->insertTab( pTab,"Playlist");
190 194
191 195
192 // Add the playlist area 196 // Add the playlist area
193 197
194 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 198 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
195 d->playListFrame = vbox3; 199 d->playListFrame = vbox3;
196 d->playListFrame ->setMinimumSize(235,260); 200 d->playListFrame ->setMinimumSize(235,260);
197 201
198 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 202 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
199 203
200 d->selectedFiles = new PlayListSelection( hbox2); 204 d->selectedFiles = new PlayListSelection( hbox2);
201 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 205 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
202 206
203 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 207 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
204 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 208
209 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
205 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 210 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
206 211
207 212
208 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 213 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
209 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 214 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
210 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 215 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
211 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 216 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
212 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 217 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
213 218
214 QWidget *aTab; 219 QWidget *aTab;
215 aTab = new QWidget( tabWidget, "aTab" ); 220 aTab = new QWidget( tabWidget, "aTab" );
216 audioView = new QListView( aTab, "Audioview" ); 221 audioView = new QListView( aTab, "Audioview" );
217 audioView->setMinimumSize(233,260); 222 audioView->setMinimumSize(233,260);
218 audioView->addColumn( tr("Title"),140); 223 audioView->addColumn( tr("Title"),140);
219 audioView->addColumn(tr("Size"), -1); 224 audioView->addColumn(tr("Size"), -1);
220 audioView->addColumn(tr("Media"),-1); 225 audioView->addColumn(tr("Media"),-1);
221 audioView->setColumnAlignment(1, Qt::AlignRight); 226 audioView->setColumnAlignment(1, Qt::AlignRight);
222 audioView->setColumnAlignment(2, Qt::AlignRight); 227 audioView->setColumnAlignment(2, Qt::AlignRight);
223 audioView->setAllColumnsShowFocus(TRUE); 228 audioView->setAllColumnsShowFocus(TRUE);
224 229
225 audioView->setMultiSelection( TRUE ); 230 audioView->setMultiSelection( TRUE );
226 audioView->setSelectionMode( QListView::Extended); 231 audioView->setSelectionMode( QListView::Extended);
227 232
228 tabWidget->insertTab(aTab,tr("Audio")); 233 tabWidget->insertTab(aTab,tr("Audio"));
229 234
230 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 235 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
231 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 236 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
232 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 237 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
233 238
234 239
235// audioView 240// audioView
236 populateAudioView(); 241 populateAudioView();
237// videowidget 242// videowidget
238 243
239 QWidget *vTab; 244 QWidget *vTab;
240 vTab = new QWidget( tabWidget, "vTab" ); 245 vTab = new QWidget( tabWidget, "vTab" );
241 videoView = new QListView( vTab, "Videoview" ); 246 videoView = new QListView( vTab, "Videoview" );
242 videoView->setMinimumSize(233,260); 247 videoView->setMinimumSize(233,260);
243 248
244 videoView->addColumn(tr("Title"),140); 249 videoView->addColumn(tr("Title"),140);
245 videoView->addColumn(tr("Size"),-1); 250 videoView->addColumn(tr("Size"),-1);
246 videoView->addColumn(tr("Media"),-1); 251 videoView->addColumn(tr("Media"),-1);
247 videoView->setColumnAlignment(1, Qt::AlignRight); 252 videoView->setColumnAlignment(1, Qt::AlignRight);
248 videoView->setColumnAlignment(2, Qt::AlignRight); 253 videoView->setColumnAlignment(2, Qt::AlignRight);
249 videoView->setAllColumnsShowFocus(TRUE); 254 videoView->setAllColumnsShowFocus(TRUE);
250 videoView->setMultiSelection( TRUE ); 255 videoView->setMultiSelection( TRUE );
251 videoView->setSelectionMode( QListView::Extended); 256 videoView->setSelectionMode( QListView::Extended);
252 257
253 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 258 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
254 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 259 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
255 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 260 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
256 261
257 tabWidget->insertTab( vTab,tr("Video")); 262 tabWidget->insertTab( vTab,tr("Video"));
258populateVideoView(); 263populateVideoView();
259 264
260//playlists list 265//playlists list
261 QWidget *LTab; 266 QWidget *LTab;
262 LTab = new QWidget( tabWidget, "LTab" ); 267 LTab = new QWidget( tabWidget, "LTab" );
263 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 268 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
264 playLists->setMinimumSize(233,260);; 269 playLists->setMinimumSize(233,260);;
265 tabWidget->insertTab(LTab,tr("Lists")); 270 tabWidget->insertTab(LTab,tr("Lists"));
266 271
267 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 272 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
268// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 273// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
269 274
270 275
271// add the library area 276// add the library area
272 277
273// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 278// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
274// this, SLOT( fauxPlay( QListViewItem *) ) ); 279// this, SLOT( fauxPlay( QListViewItem *) ) );
275// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 280// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
276// this, SLOT( fauxPlay( QListViewItem *)) ); 281// this, SLOT( fauxPlay( QListViewItem *)) );
277 282
278// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 283// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
279// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 284// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
280 285
281 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 286 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
282 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 287 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
283 288
284 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 289 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
285 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 290 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
286 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 291 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
287 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 292 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
288 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
289 294
290 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 295 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
291// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 296// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
292 297
293 setCentralWidget( vbox5 ); 298 setCentralWidget( vbox5 );
294 299
295 Config cfg( "OpiePlayer" ); 300 Config cfg( "OpiePlayer" );
296 readConfig( cfg ); 301 readConfig( cfg );
297 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
298// qDebug("currentList is "+currentPlaylist); 303// qDebug("currentList is "+currentPlaylist);
299 loadList(DocLnk( currentPlaylist)); 304 loadList(DocLnk( currentPlaylist));
300 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 305 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
301 306
302 initializeStates(); 307 initializeStates();
303} 308}
304 309
305 310
306PlayListWidget::~PlayListWidget() { 311PlayListWidget::~PlayListWidget() {
307 Config cfg( "OpiePlayer" ); 312 Config cfg( "OpiePlayer" );
308 writeConfig( cfg ); 313 writeConfig( cfg );
309 314
310 315
311 if ( d->current ) 316 if ( d->current )
312 delete d->current; 317 delete d->current;
313 delete d; 318 delete d;
314} 319}
315 320
316 321
317void PlayListWidget::initializeStates() { 322void PlayListWidget::initializeStates() {
318 323
319 d->tbPlay->setOn( mediaPlayerState->playing() ); 324 d->tbPlay->setOn( mediaPlayerState->playing() );
320 d->tbLoop->setOn( mediaPlayerState->looping() ); 325 d->tbLoop->setOn( mediaPlayerState->looping() );
321 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 326 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
322// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 327// d->tbFull->setOn( mediaPlayerState->fullscreen() );
323// d->tbScale->setOn( mediaPlayerState->scaled() ); 328// d->tbScale->setOn( mediaPlayerState->scaled() );
324// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 329// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
325// setPlaylist( mediaPlayerState->playlist() ); 330// setPlaylist( mediaPlayerState->playlist() );
326 setPlaylist( true); 331 setPlaylist( true);
327// d->selectedFiles->first(); 332// d->selectedFiles->first();
328 333
329} 334}
330 335
331 336
332void PlayListWidget::readConfig( Config& cfg ) { 337void PlayListWidget::readConfig( Config& cfg ) {
333 cfg.setGroup("PlayList"); 338 cfg.setGroup("PlayList");
334 QString currentString = cfg.readEntry("current", "" ); 339 QString currentString = cfg.readEntry("current", "" );
335 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 340 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
336 for ( int i = 0; i < noOfFiles; i++ ) { 341 for ( int i = 0; i < noOfFiles; i++ ) {
337 QString entryName; 342 QString entryName;
338 entryName.sprintf( "File%i", i + 1 ); 343 entryName.sprintf( "File%i", i + 1 );
339 QString linkFile = cfg.readEntry( entryName ); 344 QString linkFile = cfg.readEntry( entryName );
340 DocLnk lnk( linkFile ); 345 DocLnk lnk( linkFile );
341 if ( lnk.isValid() ) { 346 if ( lnk.isValid() ) {
342 d->selectedFiles->addToSelection( lnk ); 347 d->selectedFiles->addToSelection( lnk );
343 } 348 }
344 } 349 }
345 d->selectedFiles->setSelectedItem( currentString); 350 d->selectedFiles->setSelectedItem( currentString);
346// d->selectedFiles->setSelectedItem( (const QString &)currentString); 351// d->selectedFiles->setSelectedItem( (const QString &)currentString);
347} 352}
348 353
349 354
350void PlayListWidget::writeConfig( Config& cfg ) const { 355void PlayListWidget::writeConfig( Config& cfg ) const {
351 356
352 d->selectedFiles->writeCurrent( cfg); 357 d->selectedFiles->writeCurrent( cfg);
353 cfg.setGroup("PlayList"); 358 cfg.setGroup("PlayList");
354 int noOfFiles = 0; 359 int noOfFiles = 0;
355 d->selectedFiles->first(); 360 d->selectedFiles->first();
356 do { 361 do {
357 const DocLnk *lnk = d->selectedFiles->current(); 362 const DocLnk *lnk = d->selectedFiles->current();
358 if ( lnk ) { 363 if ( lnk ) {
359 QString entryName; 364 QString entryName;
360 entryName.sprintf( "File%i", noOfFiles + 1 ); 365 entryName.sprintf( "File%i", noOfFiles + 1 );
361// qDebug(entryName); 366// qDebug(entryName);
362 cfg.writeEntry( entryName, lnk->linkFile() ); 367 cfg.writeEntry( entryName, lnk->linkFile() );
363 // if this link does exist, add it so we have the file 368 // if this link does exist, add it so we have the file
364 // next time... 369 // next time...
365 if ( !QFile::exists( lnk->linkFile() ) ) { 370 if ( !QFile::exists( lnk->linkFile() ) ) {
366 // the way writing lnks doesn't really check for out 371 // the way writing lnks doesn't really check for out
367 // of disk space, but check it anyway. 372 // of disk space, but check it anyway.
368 if ( !lnk->writeLink() ) { 373 if ( !lnk->writeLink() ) {
369 QMessageBox::critical( 0, tr("Out of space"), 374 QMessageBox::critical( 0, tr("Out of space"),
370 tr( "There was a problem saving " 375 tr( "There was a problem saving "
371 "the playlist.\n" 376 "the playlist.\n"
372 "Your playlist " 377 "Your playlist "
373 "may be missing some entries\n" 378 "may be missing some entries\n"
374 "the next time you start it." ) 379 "the next time you start it." )
375 ); 380 );
376 } 381 }
377 } 382 }
378 noOfFiles++; 383 noOfFiles++;
379 } 384 }
380 } 385 }
381 while ( d->selectedFiles->next() ); 386 while ( d->selectedFiles->next() );
382 cfg.writeEntry("NumberOfFiles", noOfFiles ); 387 cfg.writeEntry("NumberOfFiles", noOfFiles );
383} 388}
384 389
385 390
386void PlayListWidget::addToSelection( const DocLnk& lnk ) { 391void PlayListWidget::addToSelection( const DocLnk& lnk ) {
387// qDebug("add"); 392// qDebug("add");
388 d->setDocumentUsed = FALSE; 393 d->setDocumentUsed = FALSE;
389 if ( mediaPlayerState->playlist() ) 394 if ( mediaPlayerState->playlist() )
390 d->selectedFiles->addToSelection( lnk ); 395 d->selectedFiles->addToSelection( lnk );
391 else 396 else
392 mediaPlayerState->setPlaying( TRUE ); 397 mediaPlayerState->setPlaying( TRUE );
393} 398}
394 399
395 400
396void PlayListWidget::clearList() { 401void PlayListWidget::clearList() {
397 while ( first() ) 402 while ( first() )
398 d->selectedFiles->removeSelected(); 403 d->selectedFiles->removeSelected();
399} 404}
400 405
401 406
402void PlayListWidget::addAllToList() { 407void PlayListWidget::addAllToList() {
403 DocLnkSet filesAll; 408 DocLnkSet filesAll;
404 Global::findDocuments(&filesAll, "video/*;audio/*"); 409 Global::findDocuments(&filesAll, "video/*;audio/*");
405 QListIterator<DocLnk> Adit( filesAll.children() ); 410 QListIterator<DocLnk> Adit( filesAll.children() );
406 for ( ; Adit.current(); ++Adit ) 411 for ( ; Adit.current(); ++Adit )
407 d->selectedFiles->addToSelection( **Adit ); 412 d->selectedFiles->addToSelection( **Adit );
408} 413}
409 414
410 415
411void PlayListWidget::addAllMusicToList() { 416void PlayListWidget::addAllMusicToList() {
412// DocLnkSet files; 417// DocLnkSet files;
413// Global::findDocuments(&files, "audio/*"); 418// Global::findDocuments(&files, "audio/*");
414 QListIterator<DocLnk> dit( files.children() ); 419 QListIterator<DocLnk> dit( files.children() );
415 for ( ; dit.current(); ++dit ) 420 for ( ; dit.current(); ++dit )
416 d->selectedFiles->addToSelection( **dit ); 421 d->selectedFiles->addToSelection( **dit );
417} 422}
418 423
419 424
420void PlayListWidget::addAllVideoToList() { 425void PlayListWidget::addAllVideoToList() {
421 QListIterator<DocLnk> dit( vFiles.children() ); 426 QListIterator<DocLnk> dit( vFiles.children() );
422 for ( ; dit.current(); ++dit ) 427 for ( ; dit.current(); ++dit )
423 d->selectedFiles->addToSelection( **dit ); 428 d->selectedFiles->addToSelection( **dit );
424} 429}
425 430
426 431
427void PlayListWidget::setDocument(const QString& fileref) { 432void PlayListWidget::setDocument(const QString& fileref) {
428 qDebug(fileref); 433 qDebug(fileref);
429 fromSetDocument = TRUE; 434 fromSetDocument = TRUE;
430 if ( fileref.isNull() ) { 435 if ( fileref.isNull() ) {
431 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 436 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
432 return; 437 return;
433 } 438 }
434// qDebug("setDocument "+fileref); 439// qDebug("setDocument "+fileref);
435// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 440// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
436// clearList(); 441// clearList();
437// addToSelection( DocLnk( fileref ) ); 442// addToSelection( DocLnk( fileref ) );
438// d->setDocumentUsed = TRUE; 443// d->setDocumentUsed = TRUE;
439// d->selectedFiles->first(); 444// d->selectedFiles->first();
440// qApp->processEvents(); 445// qApp->processEvents();
441// } 446// }
442// else 447// else
443 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 448 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
444 clearList(); 449 clearList();
445 loadList(DocLnk(fileref)); 450 loadList(DocLnk(fileref));
446 d->selectedFiles->first(); 451 d->selectedFiles->first();
447 } else { 452 } else {
448 clearList(); 453 clearList();
449 addToSelection( DocLnk( fileref ) ); 454 addToSelection( DocLnk( fileref ) );
450 d->setDocumentUsed = TRUE; 455 d->setDocumentUsed = TRUE;
451 mediaPlayerState->setPlaying( FALSE ); 456 mediaPlayerState->setPlaying( FALSE );
452 qApp->processEvents(); 457 qApp->processEvents();
453 mediaPlayerState->setPlaying( TRUE ); 458 mediaPlayerState->setPlaying( TRUE );
454 qApp->processEvents(); 459 qApp->processEvents();
455 setCaption(tr("OpiePlayer")); 460 setCaption(tr("OpiePlayer"));
456 } 461 }
457} 462}
458 463
459 464
460void PlayListWidget::setActiveWindow() { 465void PlayListWidget::setActiveWindow() {
461 // When we get raised we need to ensure that it switches views 466 // When we get raised we need to ensure that it switches views
462 char origView = mediaPlayerState->view(); 467 char origView = mediaPlayerState->view();
463 mediaPlayerState->setView( 'l' ); // invalidate 468 mediaPlayerState->setView( 'l' ); // invalidate
464 mediaPlayerState->setView( origView ); // now switch back 469 mediaPlayerState->setView( origView ); // now switch back
465} 470}
466 471
467 472
468void PlayListWidget::useSelectedDocument() { 473void PlayListWidget::useSelectedDocument() {
469 d->setDocumentUsed = FALSE; 474 d->setDocumentUsed = FALSE;
470} 475}
471 476
472 477
473const DocLnk *PlayListWidget::current() { // this is fugly 478const DocLnk *PlayListWidget::current() { // this is fugly
474 479
475// if( fromSetDocument) { 480// if( fromSetDocument) {
476// qDebug("from setDoc"); 481// qDebug("from setDoc");
477// DocLnkSet files; 482// DocLnkSet files;
478// Global::findDocuments(&files, "video/*;audio/*"); 483// Global::findDocuments(&files, "video/*;audio/*");
479// QListIterator<DocLnk> dit( files.children() ); 484// QListIterator<DocLnk> dit( files.children() );
480// for ( ; dit.current(); ++dit ) { 485// for ( ; dit.current(); ++dit ) {
481// if(dit.current()->linkFile() == setDocFileRef) { 486// if(dit.current()->linkFile() == setDocFileRef) {
482// qDebug(setDocFileRef); 487// qDebug(setDocFileRef);
483// return dit; 488// return dit;
484// } 489// }
485// } 490// }
486// } else 491// } else
487 492
488 493
489 switch (tabWidget->currentPageIndex()) { 494 switch (tabWidget->currentPageIndex()) {
490 case 0: //playlist 495 case 0: //playlist
491 { 496 {
492 qDebug("playlist"); 497 qDebug("playlist");
493 if ( mediaPlayerState->playlist() ) { 498 if ( mediaPlayerState->playlist() ) {
494 return d->selectedFiles->current(); 499 return d->selectedFiles->current();
495 } 500 }
496 else if ( d->setDocumentUsed && d->current ) { 501 else if ( d->setDocumentUsed && d->current ) {
497 return d->current; 502 return d->current;
498 } else { 503 } else {
499 return d->files->selected(); 504 return d->files->selected();
500 } 505 }
501 } 506 }
502 break; 507 break;
503 case 1://audio 508 case 1://audio
504 { 509 {
505 qDebug("audioView"); 510 qDebug("audioView");
506// Global::findDocuments(&files, "audio/*"); 511// Global::findDocuments(&files, "audio/*");
507 QListIterator<DocLnk> dit( files.children() ); 512 QListIterator<DocLnk> dit( files.children() );
508 for ( ; dit.current(); ++dit ) { 513 for ( ; dit.current(); ++dit ) {
509 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 514 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
510 qDebug("here"); 515 qDebug("here");
511 insanityBool=TRUE; 516 insanityBool=TRUE;
512 return dit; 517 return dit;
513 } 518 }
514 } 519 }
515 } 520 }
516 break; 521 break;
517 case 2: // video 522 case 2: // video
518 { 523 {
519 qDebug("videoView"); 524 qDebug("videoView");
520// Global::findDocuments(&vFiles, "video/*"); 525// Global::findDocuments(&vFiles, "video/*");
521 QListIterator<DocLnk> Vdit( vFiles.children() ); 526 QListIterator<DocLnk> Vdit( vFiles.children() );
522 for ( ; Vdit.current(); ++Vdit ) { 527 for ( ; Vdit.current(); ++Vdit ) {
523 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 528 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
524 insanityBool=TRUE; 529 insanityBool=TRUE;
525 return Vdit; 530 return Vdit;
526 } 531 }
527 } 532 }
528 } 533 }
529 break; 534 break;
530 }; 535 };
531 return 0; 536 return 0;
532} 537}
533 538
534bool PlayListWidget::prev() { 539bool PlayListWidget::prev() {
535 if ( mediaPlayerState->playlist() ) { 540 if ( mediaPlayerState->playlist() ) {
536 if ( mediaPlayerState->shuffled() ) { 541 if ( mediaPlayerState->shuffled() ) {
537 const DocLnk *cur = current(); 542 const DocLnk *cur = current();
538 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 543 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
539 for ( int i = 0; i < j; i++ ) { 544 for ( int i = 0; i < j; i++ ) {
540 if ( !d->selectedFiles->next() ) 545 if ( !d->selectedFiles->next() )
541 d->selectedFiles->first(); 546 d->selectedFiles->first();
542 } 547 }
543 if ( cur == current() ) 548 if ( cur == current() )
544 if ( !d->selectedFiles->next() ) 549 if ( !d->selectedFiles->next() )
545 d->selectedFiles->first(); 550 d->selectedFiles->first();
546 return TRUE; 551 return TRUE;
547 } else { 552 } else {
548 if ( !d->selectedFiles->prev() ) { 553 if ( !d->selectedFiles->prev() ) {
549 if ( mediaPlayerState->looping() ) { 554 if ( mediaPlayerState->looping() ) {
550 return d->selectedFiles->last(); 555 return d->selectedFiles->last();
551 } else { 556 } else {
552 return FALSE; 557 return FALSE;
553 } 558 }
554 } 559 }
555 return TRUE; 560 return TRUE;
556 } 561 }
557 } else { 562 } else {
558 return mediaPlayerState->looping(); 563 return mediaPlayerState->looping();
559 } 564 }
560} 565}
561 566
562 567
563bool PlayListWidget::next() { 568bool PlayListWidget::next() {
564 if ( mediaPlayerState->playlist() ) { 569 if ( mediaPlayerState->playlist() ) {
565 if ( mediaPlayerState->shuffled() ) { 570 if ( mediaPlayerState->shuffled() ) {
566 return prev(); 571 return prev();
567 } else { 572 } else {
568 if ( !d->selectedFiles->next() ) { 573 if ( !d->selectedFiles->next() ) {
569 if ( mediaPlayerState->looping() ) { 574 if ( mediaPlayerState->looping() ) {
570 return d->selectedFiles->first(); 575 return d->selectedFiles->first();
571 } else { 576 } else {
572 return FALSE; 577 return FALSE;
573 } 578 }
574 } 579 }
575 return TRUE; 580 return TRUE;
576 } 581 }
577 } else { 582 } else {
578 return mediaPlayerState->looping(); 583 return mediaPlayerState->looping();
579 } 584 }
580} 585}
581 586
582 587
583bool PlayListWidget::first() { 588bool PlayListWidget::first() {
584 if ( mediaPlayerState->playlist() ) 589 if ( mediaPlayerState->playlist() )
585 return d->selectedFiles->first(); 590 return d->selectedFiles->first();
586 else 591 else
587 return mediaPlayerState->looping(); 592 return mediaPlayerState->looping();
588} 593}
589 594
590 595
591bool PlayListWidget::last() { 596bool PlayListWidget::last() {
592 if ( mediaPlayerState->playlist() ) 597 if ( mediaPlayerState->playlist() )
593 return d->selectedFiles->last(); 598 return d->selectedFiles->last();
594 else 599 else
595 return mediaPlayerState->looping(); 600 return mediaPlayerState->looping();
596} 601}
597 602
598 603
599void PlayListWidget::saveList() { 604void PlayListWidget::saveList() {
600 605
601 QString filename; 606 QString filename;
602 InputDialog *fileDlg; 607 InputDialog *fileDlg;
603 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 608 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
604 fileDlg->exec(); 609 fileDlg->exec();
605 if( fileDlg->result() == 1 ) { 610 if( fileDlg->result() == 1 ) {
606 if ( d->current ) 611 if ( d->current )
607 delete d->current; 612 delete d->current;
608 filename = fileDlg->LineEdit1->text();//+".playlist"; 613 filename = fileDlg->LineEdit1->text();//+".playlist";
609// qDebug("saving playlist "+filename+".playlist"); 614// qDebug("saving playlist "+filename+".playlist");
610 Config cfg( filename +".playlist"); 615 Config cfg( filename +".playlist");
611 writeConfig( cfg ); 616 writeConfig( cfg );
612 617
613// qDebug("same name so delete lnk??"); 618// qDebug("same name so delete lnk??");
614// if( playLists->selected()->name() == filename) { 619// if( playLists->selected()->name() == filename) {
615 620
616// qDebug("same name so delete lnk"); 621// qDebug("same name so delete lnk");
617// QFile().remove(playLists->selected()->file()); 622// QFile().remove(playLists->selected()->file());
618// QFile().remove(playLists->selected()->linkFile()); 623// QFile().remove(playLists->selected()->linkFile());
619// playLists->reread(); 624// playLists->reread();
620// } 625// }
621// qDebug("new doclnk"); 626// qDebug("new doclnk");
622 DocLnk lnk; 627 DocLnk lnk;
623// lnk.setComment( ""); 628// lnk.setComment( "");
624 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 629 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
625 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 630 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
626 lnk.setIcon("opieplayer/playlist2"); 631 lnk.setIcon("opieplayer/playlist2");
627 lnk.setName( filename); //sets file name 632 lnk.setName( filename); //sets file name
628// qDebug(filename); 633// qDebug(filename);
629 if(!lnk.writeLink()) 634 if(!lnk.writeLink())
630 qDebug("Writing doclink did not work"); 635 qDebug("Writing doclink did not work");
631 } 636 }
632 Config config( "OpiePlayer" ); 637 Config config( "OpiePlayer" );
633 config.writeEntry("CurrentPlaylist",filename); 638 config.writeEntry("CurrentPlaylist",filename);
634 setCaption(tr("OpiePlayer: ")+filename); 639 setCaption(tr("OpiePlayer: ")+filename);
635 d->selectedFiles->first(); 640 d->selectedFiles->first();
636 if(fileDlg) 641 if(fileDlg)
637 delete fileDlg; 642 delete fileDlg;
638} 643}
639 644
640void PlayListWidget::loadList( const DocLnk & lnk) { 645void PlayListWidget::loadList( const DocLnk & lnk) {
641 QString name= lnk.name(); 646 QString name= lnk.name();
642// qDebug("currentList is "+name); 647// qDebug("currentList is "+name);
643 if( name.length()>1) { 648 if( name.length()>1) {
644 setCaption("OpiePlayer: "+name); 649 setCaption("OpiePlayer: "+name);
645// qDebug("load list "+ name+".playlist"); 650// qDebug("load list "+ name+".playlist");
646 clearList(); 651 clearList();
647 Config cfg( name+".playlist"); 652 Config cfg( name+".playlist");
648 readConfig(cfg); 653 readConfig(cfg);
649 654
650 tabWidget->setCurrentPage(0); 655 tabWidget->setCurrentPage(0);
651 656
652 Config config( "OpiePlayer" ); 657 Config config( "OpiePlayer" );
653 config.writeEntry("CurrentPlaylist", name); 658 config.writeEntry("CurrentPlaylist", name);
654// d->selectedFiles->first(); 659// d->selectedFiles->first();
655 } 660 }
656 661
657} 662}
658 663
659void PlayListWidget::setPlaylist( bool shown ) { 664void PlayListWidget::setPlaylist( bool shown ) {
660 if ( shown ) 665 if ( shown )
661 d->playListFrame->show(); 666 d->playListFrame->show();
662 else 667 else
663 d->playListFrame->hide(); 668 d->playListFrame->hide();
664} 669}
665 670
666void PlayListWidget::setView( char view ) { 671void PlayListWidget::setView( char view ) {
667 if ( view == 'l' ) 672 if ( view == 'l' )
668 showMaximized(); 673 showMaximized();
669 else 674 else
670 hide(); 675 hide();
671} 676}
672 677
673void PlayListWidget::addSelected() { 678void PlayListWidget::addSelected() {
674 679
675 Config cfg( "OpiePlayer" ); 680 Config cfg( "OpiePlayer" );
676 cfg.setGroup("PlayList"); 681 cfg.setGroup("PlayList");
677 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 682 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
678 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 683 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
679 684
680 switch (tabWidget->currentPageIndex()) { 685 switch (tabWidget->currentPageIndex()) {
681 case 0: //playlist 686 case 0: //playlist
682 break; 687 break;
683 case 1: { //audio 688 case 1: { //audio
684// QString entryName; 689// QString entryName;
685// entryName.sprintf( "File%i", i + 1 ); 690// entryName.sprintf( "File%i", i + 1 );
686// QString linkFile = cfg.readEntry( entryName ); 691// QString linkFile = cfg.readEntry( entryName );
687 QListViewItemIterator it( audioView ); 692 QListViewItemIterator it( audioView );
688 // iterate through all items of the listview 693 // iterate through all items of the listview
689 for ( ; it.current(); ++it ) { 694 for ( ; it.current(); ++it ) {
690 if ( it.current()->isSelected() ) { 695 if ( it.current()->isSelected() ) {
691 QListIterator<DocLnk> dit( files.children() ); 696 QListIterator<DocLnk> dit( files.children() );
692 for ( ; dit.current(); ++dit ) { 697 for ( ; dit.current(); ++dit ) {
693 if( dit.current()->name() == it.current()->text(0) ) { 698 if( dit.current()->name() == it.current()->text(0) ) {
694 d->selectedFiles->addToSelection( **dit ); 699 d->selectedFiles->addToSelection( **dit );
695 } 700 }
696 } 701 }
697 audioView->setSelected( it.current(),FALSE); 702 audioView->setSelected( it.current(),FALSE);
698 } 703 }
699 } 704 }
700 tabWidget->setCurrentPage(0); 705 tabWidget->setCurrentPage(0);
701 } 706 }
702 break; 707 break;
703 case 2: { // video 708 case 2: { // video
704 QListViewItemIterator it( videoView ); 709 QListViewItemIterator it( videoView );
705 // iterate through all items of the listview 710 // iterate through all items of the listview
706 for ( ; it.current(); ++it ) { 711 for ( ; it.current(); ++it ) {
707 if ( it.current()->isSelected() ) { 712 if ( it.current()->isSelected() ) {
708 QListIterator<DocLnk> dit( vFiles.children() ); 713 QListIterator<DocLnk> dit( vFiles.children() );
709 for ( ; dit.current(); ++dit ) { 714 for ( ; dit.current(); ++dit ) {
710 if( dit.current()->name() == it.current()->text(0) ) { 715 if( dit.current()->name() == it.current()->text(0) ) {
711 d->selectedFiles->addToSelection( **dit ); 716 d->selectedFiles->addToSelection( **dit );
712 } 717 }
713 } 718 }
714 719
715 videoView->setSelected( it.current(),FALSE); 720 videoView->setSelected( it.current(),FALSE);
716 } 721 }
717 } 722 }
718// for ( int i = 0; i < noOfFiles; i++ ) { 723// for ( int i = 0; i < noOfFiles; i++ ) {
719// QString entryName; 724// QString entryName;
720// entryName.sprintf( "File%i", i + 1 ); 725// entryName.sprintf( "File%i", i + 1 );
721// QString linkFile = cfg.readEntry( entryName ); 726// QString linkFile = cfg.readEntry( entryName );
722// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 727// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
723// int result= QMessageBox::warning(this,tr("OpiePlayer"), 728// int result= QMessageBox::warning(this,tr("OpiePlayer"),
724// tr("This is all ready in your playlist.\nContinue?"), 729// tr("This is all ready in your playlist.\nContinue?"),
725// tr("Yes"),tr("No"),0,0,1); 730// tr("Yes"),tr("No"),0,0,1);
726// if (result !=0) 731// if (result !=0)
727// return; 732// return;
728// } 733// }
729// } 734// }
730// addToSelection( videoView->selectedItem() ); 735// addToSelection( videoView->selectedItem() );
731 tabWidget->setCurrentPage(0); 736 tabWidget->setCurrentPage(0);
732 } 737 }
733 break; 738 break;
734 }; 739 };
735} 740}
736 741
737void PlayListWidget::removeSelected() { 742void PlayListWidget::removeSelected() {
738 d->selectedFiles->removeSelected( ); 743 d->selectedFiles->removeSelected( );
739} 744}
740 745
741void PlayListWidget::playIt( QListViewItem *it) { 746void PlayListWidget::playIt( QListViewItem *it) {
742// d->setDocumentUsed = FALSE; 747// d->setDocumentUsed = FALSE;
748 mediaPlayerState->setPlaying(FALSE);
743 mediaPlayerState->setPlaying(TRUE); 749 mediaPlayerState->setPlaying(TRUE);
750 d->selectedFiles->unSelect();
744} 751}
745 752
746void PlayListWidget::addToSelection( QListViewItem *it) { 753void PlayListWidget::addToSelection( QListViewItem *it) {
747 d->setDocumentUsed = FALSE; 754 d->setDocumentUsed = FALSE;
748 755
749 if(it) { 756 if(it) {
750 switch (tabWidget->currentPageIndex()) { 757 switch (tabWidget->currentPageIndex()) {
751 case 1: { 758 case 1: {
752 QListIterator<DocLnk> dit( files.children() ); 759 QListIterator<DocLnk> dit( files.children() );
753 for ( ; dit.current(); ++dit ) { 760 for ( ; dit.current(); ++dit ) {
754 if( dit.current()->name() == it->text(0)) { 761 if( dit.current()->name() == it->text(0)) {
755 d->selectedFiles->addToSelection( **dit ); 762 d->selectedFiles->addToSelection( **dit );
756 } 763 }
757 } 764 }
758 } 765 }
759 break; 766 break;
760 case 2: { 767 case 2: {
761 QListIterator<DocLnk> dit( vFiles.children() ); 768 QListIterator<DocLnk> dit( vFiles.children() );
762 for ( ; dit.current(); ++dit ) { 769 for ( ; dit.current(); ++dit ) {
763 if( dit.current()->name() == it->text(0)) { 770 if( dit.current()->name() == it->text(0)) {
764 d->selectedFiles->addToSelection( **dit ); 771 d->selectedFiles->addToSelection( **dit );
765 } 772 }
766 } 773 }
767 } 774 }
768 break; 775 break;
769 case 0: 776 case 0:
770 break; 777 break;
771 }; 778 };
772 tabWidget->setCurrentPage(0); 779 tabWidget->setCurrentPage(0);
773 } 780 }
774} 781}
775 782
776void PlayListWidget::tabChanged(QWidget *widg) { 783void PlayListWidget::tabChanged(QWidget *widg) {
777 784
778 switch ( tabWidget->currentPageIndex()) { 785 switch ( tabWidget->currentPageIndex()) {
779 case 0: 786 case 0:
780 { 787 {
781 if( !tbDeletePlaylist->isHidden()) 788 if( !tbDeletePlaylist->isHidden())
782 tbDeletePlaylist->hide(); 789 tbDeletePlaylist->hide();
783 d->tbRemoveFromList->setEnabled(TRUE); 790 d->tbRemoveFromList->setEnabled(TRUE);
784 d->tbAddToList->setEnabled(FALSE); 791 d->tbAddToList->setEnabled(FALSE);
785 } 792 }
786 break; 793 break;
787 case 1: 794 case 1:
788 { 795 {
789 if( !tbDeletePlaylist->isHidden()) 796 if( !tbDeletePlaylist->isHidden())
790 tbDeletePlaylist->hide(); 797 tbDeletePlaylist->hide();
791 d->tbRemoveFromList->setEnabled(FALSE); 798 d->tbRemoveFromList->setEnabled(FALSE);
792 d->tbAddToList->setEnabled(TRUE); 799 d->tbAddToList->setEnabled(TRUE);
793 } 800 }
794 break; 801 break;
795 case 2: 802 case 2:
796 { 803 {
797 if( !tbDeletePlaylist->isHidden()) 804 if( !tbDeletePlaylist->isHidden())
798 tbDeletePlaylist->hide(); 805 tbDeletePlaylist->hide();
799 d->tbRemoveFromList->setEnabled(FALSE); 806 d->tbRemoveFromList->setEnabled(FALSE);
800 d->tbAddToList->setEnabled(TRUE); 807 d->tbAddToList->setEnabled(TRUE);
801 } 808 }
802 break; 809 break;
803 case 3: 810 case 3:
804 { 811 {
805 if( tbDeletePlaylist->isHidden()) 812 if( tbDeletePlaylist->isHidden())
806 tbDeletePlaylist->show(); 813 tbDeletePlaylist->show();
807 playLists->reread(); 814 playLists->reread();
808 } 815 }
809 break; 816 break;
810 }; 817 };
811} 818}
812 819
813 820
814 821
815void PlayListWidget::btnPlay(bool b) { 822void PlayListWidget::btnPlay(bool b) {
816 823
817// mediaPlayerState->setPlaying(b); 824// mediaPlayerState->setPlaying(b);
818 switch ( tabWidget->currentPageIndex()) { 825 switch ( tabWidget->currentPageIndex()) {
819 case 0: 826 case 0:
820 { 827 {
821 mediaPlayerState->setPlaying(b); 828 mediaPlayerState->setPlaying(b);
822 } 829 }
823 break; 830 break;
824 case 1: 831 case 1:
825 { 832 {
826 addToSelection( audioView->selectedItem() ); 833 addToSelection( audioView->selectedItem() );
827 mediaPlayerState->setPlaying(b); 834 mediaPlayerState->setPlaying(b);
828 d->selectedFiles->removeSelected( ); 835 d->selectedFiles->removeSelected( );
829 tabWidget->setCurrentPage(1); 836 tabWidget->setCurrentPage(1);
830 d->selectedFiles->unSelect(); 837 d->selectedFiles->unSelect();
831// audioView->clearSelection(); 838// audioView->clearSelection();
832 } 839 }
833 break; 840 break;
834 case 2: 841 case 2:
835 { 842 {
836 addToSelection( videoView->selectedItem() ); 843 addToSelection( videoView->selectedItem() );
837 mediaPlayerState->setPlaying(b); 844 mediaPlayerState->setPlaying(b);
838 qApp->processEvents(); 845 qApp->processEvents();
839 d->selectedFiles->removeSelected( ); 846 d->selectedFiles->removeSelected( );
840 tabWidget->setCurrentPage(2); 847 tabWidget->setCurrentPage(2);
841 d->selectedFiles->unSelect(); 848 d->selectedFiles->unSelect();
842// videoView->clearSelection(); 849// videoView->clearSelection();
843 } 850 }
844 break; 851 break;
845 }; 852 };
846} 853}
847 854
848void PlayListWidget::deletePlaylist() { 855void PlayListWidget::deletePlaylist() {
849 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 856 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
850 (tr("You really want to delete\nthis playlist?")), 857 (tr("You really want to delete\nthis playlist?")),
851 (tr("Yes")), (tr("No")), 0 )){ 858 (tr("Yes")), (tr("No")), 0 )){
852 case 0: // Yes clicked, 859 case 0: // Yes clicked,
853 QFile().remove(playLists->selected()->file()); 860 QFile().remove(playLists->selected()->file());
854 QFile().remove(playLists->selected()->linkFile()); 861 QFile().remove(playLists->selected()->linkFile());
855 playLists->reread(); 862 playLists->reread();
856 break; 863 break;
857 case 1: // Cancel 864 case 1: // Cancel
858 break; 865 break;
859 }; 866 };
860 867
861} 868}
862 869
863void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 870void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
864{ 871{
865 switch (mouse) { 872 switch (mouse) {
866 case 1: 873 case 1:
867 break; 874 break;
868 case 2:{ 875 case 2:{
869 QPopupMenu m; 876 QPopupMenu m;
870 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 877 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
871 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 878 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
872 m.insertSeparator(); 879 m.insertSeparator();
873 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 880 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
874 m.exec( QCursor::pos() ); 881 m.exec( QCursor::pos() );
875 } 882 }
876 break; 883 break;
877 }; 884 };
878} 885}
879 886
880void PlayListWidget::playSelected() 887void PlayListWidget::playSelected()
881{ 888{
882 btnPlay( TRUE); 889 btnPlay( TRUE);
890 d->selectedFiles->unSelect();
883} 891}
884 892
885void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 893void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
886{ 894{
887 switch (mouse) { 895 switch (mouse) {
888 case 1: 896 case 1:
897
889 break; 898 break;
890 case 2:{ 899 case 2:{
891 QPopupMenu m; 900 QPopupMenu m;
892 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 901 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
893 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 902 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
894// m.insertSeparator(); 903// m.insertSeparator();
895 m.exec( QCursor::pos() ); 904 m.exec( QCursor::pos() );
896 } 905 }
897 break; 906 break;
898 }; 907 };
899 908
900} 909}
901 910
902void PlayListWidget::listDelete() { 911void PlayListWidget::listDelete() {
903 Config cfg( "OpiePlayer" ); 912 Config cfg( "OpiePlayer" );
904 cfg.setGroup("PlayList"); 913 cfg.setGroup("PlayList");
905 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 914 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
906 QString file; 915 QString file;
907 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 916 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
908 switch ( tabWidget->currentPageIndex()) { 917 switch ( tabWidget->currentPageIndex()) {
909 case 0: 918 case 0:
910 break; 919 break;
911 case 1: 920 case 1:
912 { 921 {
913 file = audioView->selectedItem()->text(0); 922 file = audioView->selectedItem()->text(0);
914// Global::findDocuments(&files, "audio/*"); 923// Global::findDocuments(&files, "audio/*");
915// AppLnkSet appFiles; 924// AppLnkSet appFiles;
916 QListIterator<DocLnk> dit( files.children() ); 925 QListIterator<DocLnk> dit( files.children() );
917 for ( ; dit.current(); ++dit ) { 926 for ( ; dit.current(); ++dit ) {
918 if( dit.current()->name() == file) { 927 if( dit.current()->name() == file) {
919// qDebug(file); 928// qDebug(file);
920 LnkProperties prop( dit.current() ); 929 LnkProperties prop( dit.current() );
921// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 930// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
922 prop.showMaximized(); 931 prop.showMaximized();
923 prop.exec(); 932 prop.exec();
924 } 933 }
925 } 934 }
926 populateAudioView(); 935 populateAudioView();
927 } 936 }
928 break; 937 break;
929 case 2: 938 case 2:
930 { 939 {
931// file = videoView->selectedItem()->text(0); 940// file = videoView->selectedItem()->text(0);
932// for ( int i = 0; i < noOfFiles; i++ ) { 941// for ( int i = 0; i < noOfFiles; i++ ) {
933// QString entryName; 942// QString entryName;
934// entryName.sprintf( "File%i", i + 1 ); 943// entryName.sprintf( "File%i", i + 1 );
935// QString linkFile = cfg.readEntry( entryName ); 944// QString linkFile = cfg.readEntry( entryName );
936// AppLnk lnk( AppLnk(linkFile)); 945// AppLnk lnk( AppLnk(linkFile));
937// if( lnk.name() == file ) { 946// if( lnk.name() == file ) {
938// LnkProperties prop( &lnk); 947// LnkProperties prop( &lnk);
939// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 948// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
940// prop.showMaximized(); 949// prop.showMaximized();
941// prop.exec(); 950// prop.exec();
942// } 951// }
943// } 952// }
944 } 953 }
945 break; 954 break;
946 }; 955 };
947} 956}
948 957
949void PlayListWidget::populateAudioView() { 958void PlayListWidget::populateAudioView() {
950// if(files) 959// if(files)
951// files.~DocLnkSet(); 960// files.~DocLnkSet();
952 StorageInfo storageInfo; 961 StorageInfo storageInfo;
953 const QList<FileSystem> &fs = storageInfo.fileSystems(); 962 const QList<FileSystem> &fs = storageInfo.fileSystems();
954 963
955 Global::findDocuments(&files, "audio/*"); 964 Global::findDocuments(&files, "audio/*");
956 QListIterator<DocLnk> dit( files.children() ); 965 QListIterator<DocLnk> dit( files.children() );
957 QListIterator<FileSystem> it ( fs ); 966 QListIterator<FileSystem> it ( fs );
958 audioView->clear(); 967 audioView->clear();
959 QString storage; 968 QString storage;
960 for ( ; dit.current(); ++dit ) { 969 for ( ; dit.current(); ++dit ) {
961 for( ; it.current(); ++it ){ 970 for( ; it.current(); ++it ){
962 const QString name = (*it)->name(); 971 const QString name = (*it)->name();
963 const QString path = (*it)->path(); 972 const QString path = (*it)->path();
964 if(dit.current()->file().find(path) != -1 ) storage=name; 973 if(dit.current()->file().find(path) != -1 ) storage=name;
965 } 974 }
966 975
967 QListViewItem * newItem; 976 QListViewItem * newItem;
968 if ( QFile( dit.current()->file()).exists() ) { 977 if ( QFile( dit.current()->file()).exists() ) {
969 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 978 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
970 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 979 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
971 } 980 }
972 } 981 }
973} 982}
974 983
975void PlayListWidget::populateVideoView() { 984void PlayListWidget::populateVideoView() {
976 StorageInfo storageInfo; 985 StorageInfo storageInfo;
977 const QList<FileSystem> &fs = storageInfo.fileSystems(); 986 const QList<FileSystem> &fs = storageInfo.fileSystems();
978 987
979 Global::findDocuments(&vFiles, "video/*"); 988 Global::findDocuments(&vFiles, "video/*");
980 QListIterator<DocLnk> Vdit( vFiles.children() ); 989 QListIterator<DocLnk> Vdit( vFiles.children() );
981 QListIterator<FileSystem> it ( fs ); 990 QListIterator<FileSystem> it ( fs );
982 videoView->clear(); 991 videoView->clear();
983 QString storage; 992 QString storage;
984 for ( ; Vdit.current(); ++Vdit ) { 993 for ( ; Vdit.current(); ++Vdit ) {
985 for( ; it.current(); ++it ){ 994 for( ; it.current(); ++it ){
986 const QString name = (*it)->name(); 995 const QString name = (*it)->name();
987 const QString path = (*it)->path(); 996 const QString path = (*it)->path();
988 if( Vdit.current()->file().find(path) != -1 ) storage=name; 997 if( Vdit.current()->file().find(path) != -1 ) storage=name;
989 } 998 }
990 999
991 QListViewItem * newItem; 1000 QListViewItem * newItem;
992 if ( QFile( Vdit.current()->file()).exists() ) { 1001 if ( QFile( Vdit.current()->file()).exists() ) {
993 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 1002 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
994 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1003 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
995 } 1004 }
996 } 1005 }
997} 1006}
998 1007
999void PlayListWidget::openFile() { 1008void PlayListWidget::openFile() {
1000 QString filename, name; 1009 QString filename, name;
1001 InputDialog *fileDlg; 1010 InputDialog *fileDlg;
1002 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1011 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1003 fileDlg->exec(); 1012 fileDlg->exec();
1004 if( fileDlg->result() == 1 ) { 1013 if( fileDlg->result() == 1 ) {
1005 filename = fileDlg->LineEdit1->text(); 1014 filename = fileDlg->LineEdit1->text();
1006 1015
1007// InputDialog *fileDlg2; 1016// InputDialog *fileDlg2;
1008// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); 1017// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0);
1009// fileDlg2->exec(); 1018// fileDlg2->exec();
1010// if( fileDlg2->result() == 1 ) { 1019// if( fileDlg2->result() == 1 ) {
1011// name = fileDlg2->LineEdit1->text(); 1020// name = fileDlg2->LineEdit1->text();
1012// } 1021// }
1013//http://205.188.234.129:8030 1022//http://205.188.234.129:8030
1014// http://66.28.68.70:8000 1023// http://66.28.68.70:8000
1015 qDebug(filename); 1024 qDebug(filename);
1016 DocLnk lnk; 1025 DocLnk lnk;
1017// if(filename.left(7) == "http://") 1026// if(filename.left(7) == "http://")
1018// name= filename.right(filename.length()-filename.find("http://")-7); 1027// name= filename.right(filename.length()-filename.find("http://")-7);
1019// else name = filename; 1028// else name = filename;
1020// qDebug("name is "+name); 1029// qDebug("name is "+name);
1021// lnk.setComment(filename); 1030// lnk.setComment(filename);
1022 lnk.setName(filename); //sets file name 1031 lnk.setName(filename); //sets file name
1023 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1032 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1024 filename += "/"; 1033 filename += "/";
1025 lnk.setFile(filename); //sets File property 1034 lnk.setFile(filename); //sets File property
1026 1035
1027 lnk.setType("audio/x-mpegurl"); 1036 lnk.setType("audio/x-mpegurl");
1028 lnk.setExec("opieplayer"); 1037 lnk.setExec("opieplayer");
1029 lnk.setIcon("opieplayer/MPEGPlayer"); 1038 lnk.setIcon("opieplayer/MPEGPlayer");
1030 1039
1031 if(!lnk.writeLink()) 1040 if(!lnk.writeLink())
1032 qDebug("Writing doclink did not work"); 1041 qDebug("Writing doclink did not work");
1033 d->selectedFiles->addToSelection( lnk); 1042 d->selectedFiles->addToSelection( lnk);
1034// if(fileDlg2) 1043// if(fileDlg2)
1035// delete fileDlg2; 1044// delete fileDlg2;
1036 } 1045 }
1037 1046
1038 if(fileDlg) 1047 if(fileDlg)
1039 delete fileDlg; 1048 delete fileDlg;
1040} 1049}
1050
1051void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1052{
1053 switch ( e->key() ) {
1054////////////////////////////// Zaurus keys
1055 case Key_F9: //activity
1056 if(audioUI->isHidden())
1057 audioUI->showMaximized();
1058 break;
1059 case Key_F10: //contacts
1060 if( videoUI->isHidden())
1061 videoUI->showMaximized();
1062
1063 break;
1064
1065 }
1066}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 02cdba6..16b9905 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,113 +1,113 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29/* #include <qtimer.h> */ 29/* #include <qtimer.h> */
30 30
31 31
32class PlayListWidgetPrivate; 32class PlayListWidgetPrivate;
33class Config; 33class Config;
34class QListViewItem; 34class QListViewItem;
35class QListView; 35class QListView;
36class QPoint; 36class QPoint;
37class QAction; 37class QAction;
38class QLabel; 38class QLabel;
39 39
40class PlayListWidget : public QMainWindow { 40class PlayListWidget : public QMainWindow {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 44 ~PlayListWidget();
45 QTabWidget * tabWidget; 45 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 46 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 47 DocLnkSet files;
48 DocLnkSet vFiles; 48 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 49 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 50 QLabel *libString;
51 bool fromSetDocument; 51 bool fromSetDocument;
52 bool insanityBool; 52 bool insanityBool;
53 QString setDocFileRef; 53 QString setDocFileRef;
54 // retrieve the current playlist entry (media file link) 54 // retrieve the current playlist entry (media file link)
55 const DocLnk *current(); 55 const DocLnk *current();
56 void useSelectedDocument(); 56 void useSelectedDocument();
57/* QTimer * menuTimer; */ 57/* QTimer * menuTimer; */
58 FileSelector* playLists; 58 FileSelector* playLists;
59 QPushButton *tbDeletePlaylist; 59 QPushButton *tbDeletePlaylist;
60public slots: 60public slots:
61 bool first(); 61 bool first();
62 bool last(); 62 bool last();
63 bool next(); 63 bool next();
64 bool prev(); 64 bool prev();
65/* void setFullScreen(); */ 65/* void setFullScreen(); */
66/* void setScaled(); */ 66/* void setScaled(); */
67protected: 67protected:
68/* void contentsMousePressEvent( QMouseEvent * e ); */ 68/* void contentsMousePressEvent( QMouseEvent * e ); */
69/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 69/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
70 70void keyReleaseEvent( QKeyEvent *e);
71private: 71private:
72 void initializeStates(); 72 void initializeStates();
73 void readConfig( Config& cfg ); 73 void readConfig( Config& cfg );
74 void writeConfig( Config& cfg ) const; 74 void writeConfig( Config& cfg ) const;
75 PlayListWidgetPrivate *d; // Private implementation data 75 PlayListWidgetPrivate *d; // Private implementation data
76 void populateAudioView(); 76 void populateAudioView();
77 void populateVideoView(); 77 void populateVideoView();
78private slots: 78private slots:
79 void openFile(); 79 void openFile();
80 void setDocument( const QString& fileref ); 80 void setDocument( const QString& fileref );
81 void addToSelection( const DocLnk& ); // Add a media file to the playlist 81 void addToSelection( const DocLnk& ); // Add a media file to the playlist
82 void addToSelection( QListViewItem* ); // Add a media file to the playlist 82 void addToSelection( QListViewItem* ); // Add a media file to the playlist
83 void setActiveWindow(); // need to handle this to show the right view 83 void setActiveWindow(); // need to handle this to show the right view
84 void setPlaylist( bool ); // Show/Hide the playlist 84 void setPlaylist( bool ); // Show/Hide the playlist
85 void setView( char ); 85 void setView( char );
86 void clearList(); 86 void clearList();
87 void addAllToList(); 87 void addAllToList();
88 void addAllMusicToList(); 88 void addAllMusicToList();
89 void addAllVideoToList(); 89 void addAllVideoToList();
90 void saveList(); // Save the playlist 90 void saveList(); // Save the playlist
91 void loadList( const DocLnk &); // Load a playlist 91 void loadList( const DocLnk &); // Load a playlist
92 void playIt( QListViewItem *); 92 void playIt( QListViewItem *);
93 93
94 void btnPlay(bool); 94 void btnPlay(bool);
95 void deletePlaylist(); 95 void deletePlaylist();
96 void addSelected(); 96 void addSelected();
97 void removeSelected(); 97 void removeSelected();
98 void tabChanged(QWidget*); 98 void tabChanged(QWidget*);
99 void viewPressed( int, QListViewItem *, const QPoint&, int); 99 void viewPressed( int, QListViewItem *, const QPoint&, int);
100 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 100 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
101 void playSelected(); 101 void playSelected();
102 void listDelete(); 102 void listDelete();
103 103
104protected slots: 104protected slots:
105/* void cancelMenuTimer(); */ 105/* void cancelMenuTimer(); */
106/* void showFileMenu(); */ 106/* void showFileMenu(); */
107 107
108 108
109}; 109};
110 110
111 111
112#endif // PLAY_LIST_WIDGET_H 112#endif // PLAY_LIST_WIDGET_H
113 113
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 70b4a95..d0cb764 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,472 +1,473 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qwidget.h> 22#include <qwidget.h>
23#include <qpainter.h> 23#include <qpainter.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qslider.h> 25#include <qslider.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include "videowidget.h" 27#include "videowidget.h"
28#include "mediaplayerstate.h" 28#include "mediaplayerstate.h"
29 29
30 30
31#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
32# define USE_DIRECT_PAINTER 32# define USE_DIRECT_PAINTER
33# include <qdirectpainter_qws.h> 33# include <qdirectpainter_qws.h>
34# include <qgfxraster_qws.h> 34# include <qgfxraster_qws.h>
35#endif 35#endif
36 36
37 37
38extern MediaPlayerState *mediaPlayerState; 38extern MediaPlayerState *mediaPlayerState;
39 39
40 40
41static const int xo = 2; // movable x offset 41static const int xo = 2; // movable x offset
42static const int yo = 0; // movable y offset 42static const int yo = 0; // movable y offset
43 43
44 44
45struct MediaButton { 45struct MediaButton {
46 int xPos, yPos; 46 int xPos, yPos;
47 bool isToggle, isHeld, isDown; 47 bool isToggle, isHeld, isDown;
48 int controlType; 48 int controlType;
49}; 49};
50 50
51 51
52// Layout information for the videoButtons (and if it is a toggle button or not) 52// Layout information for the videoButtons (and if it is a toggle button or not)
53MediaButton videoButtons[] = { 53MediaButton videoButtons[] = {
54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
61}; 61};
62 62
63 63
64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 65
66 66
67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
69 setCaption( tr("OpiePlayer") ); 69 setCaption( tr("OpiePlayer") );
70 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 70 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); 71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) );
72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); 72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) );
73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); 73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) );
74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
75 75
76 slider = new QSlider( Qt::Horizontal, this ); 76 slider = new QSlider( Qt::Horizontal, this );
77 slider->setMinValue( 0 ); 77 slider->setMinValue( 0 );
78 slider->setMaxValue( 1 ); 78 slider->setMaxValue( 1 );
79 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 79 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
80 slider->setFocusPolicy( QWidget::NoFocus ); 80 slider->setFocusPolicy( QWidget::NoFocus );
81 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 81 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
82 82
83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
85 85
86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
92 92
93 // Intialise state 93 // Intialise state
94 setLength( mediaPlayerState->length() ); 94 setLength( mediaPlayerState->length() );
95 setPosition( mediaPlayerState->position() ); 95 setPosition( mediaPlayerState->position() );
96 setFullscreen( mediaPlayerState->fullscreen() ); 96 setFullscreen( mediaPlayerState->fullscreen() );
97 setPaused( mediaPlayerState->paused() ); 97 setPaused( mediaPlayerState->paused() );
98 setPlaying( mediaPlayerState->playing() ); 98 setPlaying( mediaPlayerState->playing() );
99} 99}
100 100
101 101
102VideoWidget::~VideoWidget() { 102VideoWidget::~VideoWidget() {
103 for ( int i = 0; i < 3; i++ ) 103 for ( int i = 0; i < 3; i++ )
104 delete pixmaps[i]; 104 delete pixmaps[i];
105 delete currentFrame; 105 delete currentFrame;
106} 106}
107 107
108 108
109static bool videoSliderBeingMoved = FALSE; 109static bool videoSliderBeingMoved = FALSE;
110 110
111 111
112void VideoWidget::sliderPressed() { 112void VideoWidget::sliderPressed() {
113 videoSliderBeingMoved = TRUE; 113 videoSliderBeingMoved = TRUE;
114} 114}
115 115
116 116
117void VideoWidget::sliderReleased() { 117void VideoWidget::sliderReleased() {
118 videoSliderBeingMoved = FALSE; 118 videoSliderBeingMoved = FALSE;
119 if ( slider->width() == 0 ) 119 if ( slider->width() == 0 )
120 return; 120 return;
121 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 121 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
122 mediaPlayerState->setPosition( val ); 122 mediaPlayerState->setPosition( val );
123} 123}
124 124
125 125
126void VideoWidget::setPosition( long i ) { 126void VideoWidget::setPosition( long i ) {
127 updateSlider( i, mediaPlayerState->length() ); 127 updateSlider( i, mediaPlayerState->length() );
128} 128}
129 129
130 130
131void VideoWidget::setLength( long max ) { 131void VideoWidget::setLength( long max ) {
132 updateSlider( mediaPlayerState->position(), max ); 132 updateSlider( mediaPlayerState->position(), max );
133} 133}
134 134
135 135
136void VideoWidget::setView( char view ) { 136void VideoWidget::setView( char view ) {
137 if ( view == 'v' ) { 137 if ( view == 'v' ) {
138 makeVisible(); 138 makeVisible();
139 } else { 139 } else {
140 // Effectively blank the view next time we show it so it looks nicer 140 // Effectively blank the view next time we show it so it looks nicer
141 scaledWidth = 0; 141 scaledWidth = 0;
142 scaledHeight = 0; 142 scaledHeight = 0;
143 hide(); 143 hide();
144 } 144 }
145} 145}
146 146
147 147
148void VideoWidget::updateSlider( long i, long max ) { 148void VideoWidget::updateSlider( long i, long max ) {
149 // Will flicker too much if we don't do this 149 // Will flicker too much if we don't do this
150 if ( max == 0 ) 150 if ( max == 0 )
151 return; 151 return;
152 int width = slider->width(); 152 int width = slider->width();
153 int val = int((double)i * width / max); 153 int val = int((double)i * width / max);
154 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 154 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
155 if ( slider->value() != val ) 155 if ( slider->value() != val )
156 slider->setValue( val ); 156 slider->setValue( val );
157 if ( slider->maxValue() != width ) 157 if ( slider->maxValue() != width )
158 slider->setMaxValue( width ); 158 slider->setMaxValue( width );
159 } 159 }
160} 160}
161 161
162 162
163void VideoWidget::setToggleButton( int i, bool down ) { 163void VideoWidget::setToggleButton( int i, bool down ) {
164 if ( down != videoButtons[i].isDown ) 164 if ( down != videoButtons[i].isDown )
165 toggleButton( i ); 165 toggleButton( i );
166} 166}
167 167
168 168
169void VideoWidget::toggleButton( int i ) { 169void VideoWidget::toggleButton( int i ) {
170 videoButtons[i].isDown = !videoButtons[i].isDown; 170 videoButtons[i].isDown = !videoButtons[i].isDown;
171 QPainter p(this); 171 QPainter p(this);
172 paintButton ( &p, i ); 172 paintButton ( &p, i );
173} 173}
174 174
175 175
176void VideoWidget::paintButton( QPainter *p, int i ) { 176void VideoWidget::paintButton( QPainter *p, int i ) {
177 int x = videoButtons[i].xPos; 177 int x = videoButtons[i].xPos;
178 int y = videoButtons[i].yPos; 178 int y = videoButtons[i].yPos;
179 int offset = 10 + videoButtons[i].isDown; 179 int offset = 10 + videoButtons[i].isDown;
180 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 180 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
181 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 181 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
182} 182}
183 183
184 184
185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
186 for ( int i = 0; i < numButtons; i++ ) { 186 for ( int i = 0; i < numButtons; i++ ) {
187 int x = videoButtons[i].xPos; 187 int x = videoButtons[i].xPos;
188 int y = videoButtons[i].yPos; 188 int y = videoButtons[i].yPos;
189 if ( event->state() == QMouseEvent::LeftButton ) { 189 if ( event->state() == QMouseEvent::LeftButton ) {
190 // The test to see if the mouse click is inside the circular button or not 190 // The test to see if the mouse click is inside the circular button or not
191 // (compared with the radius squared to avoid a square-root of our distance) 191 // (compared with the radius squared to avoid a square-root of our distance)
192 int radius = 16; 192 int radius = 16;
193 QPoint center = QPoint( x + radius, y + radius ); 193 QPoint center = QPoint( x + radius, y + radius );
194 QPoint dXY = center - event->pos(); 194 QPoint dXY = center - event->pos();
195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
196 bool isOnButton = dist <= (radius * radius); 196 bool isOnButton = dist <= (radius * radius);
197 if ( isOnButton != videoButtons[i].isHeld ) { 197 if ( isOnButton != videoButtons[i].isHeld ) {
198 videoButtons[i].isHeld = isOnButton; 198 videoButtons[i].isHeld = isOnButton;
199 toggleButton(i); 199 toggleButton(i);
200 } 200 }
201 } else { 201 } else {
202 if ( videoButtons[i].isHeld ) { 202 if ( videoButtons[i].isHeld ) {
203 videoButtons[i].isHeld = FALSE; 203 videoButtons[i].isHeld = FALSE;
204 if ( !videoButtons[i].isToggle ) 204 if ( !videoButtons[i].isToggle )
205 setToggleButton( i, FALSE ); 205 setToggleButton( i, FALSE );
206 } 206 }
207 } 207 }
208 switch (i) { 208 switch (i) {
209 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 209 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
210 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 210 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
211 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 211 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
212 case VideoNext: mediaPlayerState->setNext(); return; 212 case VideoNext: mediaPlayerState->setNext(); return;
213 case VideoPrevious: mediaPlayerState->setPrev(); return; 213 case VideoPrevious: mediaPlayerState->setPrev(); return;
214 case VideoPlayList: mediaPlayerState->setList(); return; 214 case VideoPlayList: mediaPlayerState->setList(); return;
215 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 215 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
216 } 216 }
217 217
218 } 218 }
219} 219}
220 220
221 221
222void VideoWidget::mousePressEvent( QMouseEvent *event ) { 222void VideoWidget::mousePressEvent( QMouseEvent *event ) {
223 mouseMoveEvent( event ); 223 mouseMoveEvent( event );
224} 224}
225 225
226 226
227void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 227void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
228 if ( mediaPlayerState->fullscreen() ) { 228 if ( mediaPlayerState->fullscreen() ) {
229 mediaPlayerState->setFullscreen( FALSE ); 229 mediaPlayerState->setFullscreen( FALSE );
230 makeVisible(); 230 makeVisible();
231 231
232 mouseMoveEvent( event ); 232 mouseMoveEvent( event );
233 } 233 }
234} 234}
235 235
236 236
237void VideoWidget::makeVisible() { 237void VideoWidget::makeVisible() {
238 if ( mediaPlayerState->fullscreen() ) { 238 if ( mediaPlayerState->fullscreen() ) {
239 setBackgroundMode( QWidget::NoBackground ); 239 setBackgroundMode( QWidget::NoBackground );
240 showFullScreen(); 240 showFullScreen();
241 resize( qApp->desktop()->size() ); 241 resize( qApp->desktop()->size() );
242 slider->hide(); 242 slider->hide();
243 } else { 243 } else {
244 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 244 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
245 showNormal(); 245 showNormal();
246 showMaximized(); 246 showMaximized();
247 slider->show(); 247 slider->show();
248 } 248 }
249} 249}
250 250
251 251
252void VideoWidget::paintEvent( QPaintEvent * ) { 252void VideoWidget::paintEvent( QPaintEvent * ) {
253 QPainter p( this ); 253 QPainter p( this );
254 254
255 if ( mediaPlayerState->fullscreen() ) { 255 if ( mediaPlayerState->fullscreen() ) {
256 // Clear the background 256 // Clear the background
257 p.setBrush( QBrush( Qt::black ) ); 257 p.setBrush( QBrush( Qt::black ) );
258 p.drawRect( rect() ); 258 p.drawRect( rect() );
259 259
260 // Draw the current frame 260 // Draw the current frame
261 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen 261 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen
262 } else { 262 } else {
263 // draw border 263 // draw border
264 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); 264 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL );
265 265
266 // Clear the movie screen first 266 // Clear the movie screen first
267 p.setBrush( QBrush( Qt::black ) ); 267 p.setBrush( QBrush( Qt::black ) );
268 p.drawRect( 9, 20, 220, 160 ); 268 p.drawRect( 9, 20, 220, 160 );
269 269
270 // draw current frame (centrally positioned from scaling to maintain aspect ratio) 270 // draw current frame (centrally positioned from scaling to maintain aspect ratio)
271 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 271 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
272 272
273 // draw the buttons 273 // draw the buttons
274 for ( int i = 0; i < numButtons; i++ ) 274 for ( int i = 0; i < numButtons; i++ )
275 paintButton( &p, i ); 275 paintButton( &p, i );
276 276
277 // draw the slider 277 // draw the slider
278 slider->repaint( TRUE ); 278 slider->repaint( TRUE );
279 } 279 }
280} 280}
281 281
282 282
283void VideoWidget::closeEvent( QCloseEvent* ) { 283void VideoWidget::closeEvent( QCloseEvent* ) {
284 mediaPlayerState->setList(); 284 mediaPlayerState->setList();
285} 285}
286 286
287 287
288bool VideoWidget::playVideo() { 288bool VideoWidget::playVideo() {
289 bool result = FALSE; 289 bool result = FALSE;
290 290
291 int stream = 0; 291 int stream = 0;
292 292
293 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 293 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
294 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 294 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
295 int dd = QPixmap::defaultDepth(); 295 int dd = QPixmap::defaultDepth();
296 int w = height(); 296 int w = height();
297 int h = width(); 297 int h = width();
298 298
299 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 299 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
300 300
301 if ( mediaPlayerState->fullscreen() ) { 301 if ( mediaPlayerState->fullscreen() ) {
302#ifdef USE_DIRECT_PAINTER 302#ifdef USE_DIRECT_PAINTER
303 QDirectPainter p(this); 303 QDirectPainter p(this);
304 304
305 if ( ( qt_screen->transformOrientation() == 3 ) && 305 if ( ( qt_screen->transformOrientation() == 3 ) &&
306 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { 306 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) {
307 307
308 w = 320; 308 w = 320;
309 h = 240; 309 h = 240;
310 310
311 if ( mediaPlayerState->scaled() ) { 311 if ( mediaPlayerState->scaled() ) {
312 // maintain aspect ratio 312 // maintain aspect ratio
313 if ( w * sh > sw * h ) 313 if ( w * sh > sw * h )
314 w = sw * h / sh; 314 w = sw * h / sh;
315 else 315 else
316 h = sh * w / sw; 316 h = sh * w / sw;
317 } else { 317 } else {
318 w = sw; 318 w = sw;
319 h = sh; 319 h = sh;
320 } 320 }
321 321
322 w--; // we can't allow libmpeg to overwrite. 322 w--; // we can't allow libmpeg to overwrite.
323 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 323 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
324 324
325 int ox = roff.x() - height() + 2 + (height() - w) / 2; 325 int ox = roff.x() - height() + 2 + (height() - w) / 2;
326 int oy = roff.y() + (width() - h) / 2; 326 int oy = roff.y() + (width() - h) / 2;
327 int sx = 0, sy = 0; 327 int sx = 0, sy = 0;
328 328
329 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 329 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
330 fp += dd * ox / 8; 330 fp += dd * ox / 8;
331 uchar **jt = new uchar*[h]; 331 uchar **jt = new uchar*[h];
332 for ( int i = h; i; i-- ) { 332 for ( int i = h; i; i-- ) {
333 jt[h - i] = fp; 333 jt[h - i] = fp;
334 fp += p.lineStep(); 334 fp += p.lineStep();
335 } 335 }
336 336
337 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 337 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
338 338
339 delete [] jt; 339 delete [] jt;
340 } else { 340 } else {
341#endif 341#endif
342 QPainter p(this); 342 QPainter p(this);
343 343
344 w = 320; 344 w = 320;
345 h = 240; 345 h = 240;
346 346
347 if ( mediaPlayerState->scaled() ) { 347 if ( mediaPlayerState->scaled() ) {
348 // maintain aspect ratio 348 // maintain aspect ratio
349 if ( w * sh > sw * h ) 349 if ( w * sh > sw * h )
350 w = sw * h / sh; 350 w = sw * h / sh;
351 else 351 else
352 h = sh * w / sw; 352 h = sh * w / sw;
353 } else { 353 } else {
354 w = sw; 354 w = sw;
355 h = sh; 355 h = sh;
356 } 356 }
357 357
358 int bytes = ( dd == 16 ) ? 2 : 4; 358 int bytes = ( dd == 16 ) ? 2 : 4;
359 QImage tempFrame( w, h, bytes << 3 ); 359 QImage tempFrame( w, h, bytes << 3 );
360 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 360 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
361 0, 0, sw, sh, w, h, format, 0) == 0; 361 0, 0, sw, sh, w, h, format, 0) == 0;
362 if ( result && mediaPlayerState->fullscreen() ) { 362 if ( result && mediaPlayerState->fullscreen() ) {
363 363
364 int rw = h, rh = w; 364 int rw = h, rh = w;
365 QImage rotatedFrame( rw, rh, bytes << 3 ); 365 QImage rotatedFrame( rw, rh, bytes << 3 );
366 366
367 ushort* in = (ushort*)tempFrame.bits(); 367 ushort* in = (ushort*)tempFrame.bits();
368 ushort* out = (ushort*)rotatedFrame.bits(); 368 ushort* out = (ushort*)rotatedFrame.bits();
369 int spl = rotatedFrame.bytesPerLine() / bytes; 369 int spl = rotatedFrame.bytesPerLine() / bytes;
370 for (int x=0; x<h; x++) { 370 for (int x=0; x<h; x++) {
371 if ( bytes == 2 ) { 371 if ( bytes == 2 ) {
372 ushort* lout = out++ + (w - 1)*spl; 372 ushort* lout = out++ + (w - 1)*spl;
373 for (int y=0; y<w; y++) { 373 for (int y=0; y<w; y++) {
374 *lout=*in++; 374 *lout=*in++;
375 lout-=spl; 375 lout-=spl;
376 } 376 }
377 } else { 377 } else {
378 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 378 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
379 for (int y=0; y<w; y++) { 379 for (int y=0; y<w; y++) {
380 *lout=*((ulong*)in)++; 380 *lout=*((ulong*)in)++;
381 lout-=spl; 381 lout-=spl;
382 } 382 }
383 } 383 }
384 } 384 }
385 385
386 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 386 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
387 } 387 }
388#ifdef USE_DIRECT_PAINTER 388#ifdef USE_DIRECT_PAINTER
389 } 389 }
390#endif 390#endif
391 } else { 391 } else {
392 392
393 w = 220; 393 w = 220;
394 h = 160; 394 h = 160;
395 395
396 // maintain aspect ratio 396 // maintain aspect ratio
397 if ( w * sh > sw * h ) 397 if ( w * sh > sw * h )
398 w = sw * h / sh; 398 w = sw * h / sh;
399 else 399 else
400 h = sh * w / sw; 400 h = sh * w / sw;
401 401
402 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 402 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
403 403
404 QPainter p( this ); 404 QPainter p( this );
405 405
406 // Image changed size, therefore need to blank the possibly unpainted regions first 406 // Image changed size, therefore need to blank the possibly unpainted regions first
407 if ( scaledWidth != w || scaledHeight != h ) { 407 if ( scaledWidth != w || scaledHeight != h ) {
408 p.setBrush( QBrush( Qt::black ) ); 408 p.setBrush( QBrush( Qt::black ) );
409 p.drawRect( 9, 20, 220, 160 ); 409 p.drawRect( 9, 20, 220, 160 );
410 } 410 }
411 411
412 scaledWidth = w; 412 scaledWidth = w;
413 scaledHeight = h; 413 scaledHeight = h;
414 414
415 if ( result ) { 415 if ( result ) {
416 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 416 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
417 } 417 }
418 418
419 } 419 }
420 420
421 return result; 421 return result;
422} 422}
423 423
424 424
425 425
426void VideoWidget::keyReleaseEvent( QKeyEvent *e) 426void VideoWidget::keyReleaseEvent( QKeyEvent *e)
427{ 427{
428 switch ( e->key() ) { 428 switch ( e->key() ) {
429////////////////////////////// Zaurus keys 429////////////////////////////// Zaurus keys
430 case Key_Home: 430 case Key_Home:
431 break; 431 break;
432 case Key_F9: //activity 432 case Key_F9: //activity
433 break; 433 break;
434 case Key_F10: //contacts 434 case Key_F10: //contacts
435 hide();
435 break; 436 break;
436 case Key_F11: //menu 437 case Key_F11: //menu
437 break; 438 break;
438 case Key_F12: //home 439 case Key_F12: //home
439 break; 440 break;
440 case Key_F13: //mail 441 case Key_F13: //mail
441 break; 442 break;
442 case Key_Space: { 443 case Key_Space: {
443 if(mediaPlayerState->playing()) { 444 if(mediaPlayerState->playing()) {
444 mediaPlayerState->setPlaying(FALSE); 445 mediaPlayerState->setPlaying(FALSE);
445 } else { 446 } else {
446 mediaPlayerState->setPlaying(TRUE); 447 mediaPlayerState->setPlaying(TRUE);
447 } 448 }
448 } 449 }
449 break; 450 break;
450 case Key_Down: 451 case Key_Down:
451// toggleButton(6); 452// toggleButton(6);
452// emit lessClicked(); 453// emit lessClicked();
453// emit lessReleased(); 454// emit lessReleased();
454// toggleButton(6); 455// toggleButton(6);
455 break; 456 break;
456 case Key_Up: 457 case Key_Up:
457// toggleButton(5); 458// toggleButton(5);
458// emit moreClicked(); 459// emit moreClicked();
459// emit moreReleased(); 460// emit moreReleased();
460// toggleButton(5); 461// toggleButton(5);
461 break; 462 break;
462 case Key_Right: 463 case Key_Right:
463 mediaPlayerState->setNext(); 464 mediaPlayerState->setNext();
464 break; 465 break;
465 case Key_Left: 466 case Key_Left:
466 mediaPlayerState->setPrev(); 467 mediaPlayerState->setPrev();
467 break; 468 break;
468 case Key_Escape: 469 case Key_Escape:
469 break; 470 break;
470 471
471 }; 472 };
472} 473}