summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h32
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp171
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h35
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp48
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h34
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp2
6 files changed, 188 insertions, 134 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 20e3552..79ba579 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,16 +1,48 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#ifndef MEDIA_PLAYER_STATE_H 34#ifndef MEDIA_PLAYER_STATE_H
3#define MEDIA_PLAYER_STATE_H 35#define MEDIA_PLAYER_STATE_H
4 36
5 37
6#include <qobject.h> 38#include <qobject.h>
7 39
8 40
9class MediaPlayerDecoder; 41class MediaPlayerDecoder;
10class Config; 42class Config;
11 43
12 44
13class MediaPlayerState : public QObject { 45class MediaPlayerState : public QObject {
14Q_OBJECT 46Q_OBJECT
15public: 47public:
16 MediaPlayerState( QObject *parent, const char *name ); 48 MediaPlayerState( QObject *parent, const char *name );
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 5625c0e..8fdb3d3 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,16 +1,48 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#include <qpe/resource.h> 34#include <qpe/resource.h>
3#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
4#include <qpe/config.h> 36#include <qpe/config.h>
5 37
6#include <qwidget.h> 38#include <qwidget.h>
7#include <qpainter.h> 39#include <qpainter.h>
8#include <qpixmap.h> 40#include <qpixmap.h>
9#include <qslider.h> 41#include <qslider.h>
10#include <qdrawutil.h> 42#include <qdrawutil.h>
11#include "videowidget.h" 43#include "videowidget.h"
12#include "mediaplayerstate.h" 44#include "mediaplayerstate.h"
13 45
14 46
15#ifdef Q_WS_QWS 47#ifdef Q_WS_QWS
16# define USE_DIRECT_PAINTER 48# define USE_DIRECT_PAINTER
@@ -60,48 +92,51 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
60 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
61 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
62 94
63 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 95 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
64 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 96 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
65 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 97 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
66 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 98 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
67 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 99 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
68 100
69 slider = new QSlider( Qt::Horizontal, this ); 101 slider = new QSlider( Qt::Horizontal, this );
70 slider->setMinValue( 0 ); 102 slider->setMinValue( 0 );
71 slider->setMaxValue( 1 ); 103 slider->setMaxValue( 1 );
72 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
73 slider->setFocusPolicy( QWidget::NoFocus ); 105 slider->setFocusPolicy( QWidget::NoFocus );
74 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 106 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
75 107
76 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 108 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
77 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 109 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
78 110
79 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 111 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
80 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 112 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
81 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 113 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
82 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
83 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 115 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
84 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
85 117
86 // Intialise state 118 // Intialise state
87 setLength( mediaPlayerState->length() ); 119 setLength( mediaPlayerState->length() );
88 setPosition( mediaPlayerState->position() ); 120 setPosition( mediaPlayerState->position() );
89 setFullscreen( mediaPlayerState->fullscreen() ); 121 setFullscreen( mediaPlayerState->fullscreen() );
90 setPaused( mediaPlayerState->paused() ); 122 setPaused( mediaPlayerState->paused() );
91 setPlaying( mediaPlayerState->playing() ); 123 setPlaying( mediaPlayerState->playing() );
124
125 videoFrame = new XineVideoWidget( 200, 150 ,this, "Video frame" );
126 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
92} 127}
93 128
94 129
95VideoWidget::~VideoWidget() { 130VideoWidget::~VideoWidget() {
96 for ( int i = 0; i < 3; i++ ) { 131 for ( int i = 0; i < 3; i++ ) {
97 delete pixmaps[i]; 132 delete pixmaps[i];
98 } 133 }
99 delete currentFrame; 134 delete currentFrame;
100} 135}
101 136
102 137
103static bool videoSliderBeingMoved = FALSE; 138static bool videoSliderBeingMoved = FALSE;
104 139
105 140
106void VideoWidget::sliderPressed() { 141void VideoWidget::sliderPressed() {
107 videoSliderBeingMoved = TRUE; 142 videoSliderBeingMoved = TRUE;
@@ -243,195 +278,71 @@ void VideoWidget::makeVisible() {
243 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 278 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
244 showNormal(); 279 showNormal();
245 showMaximized(); 280 showMaximized();
246 slider->show(); 281 slider->show();
247 } 282 }
248} 283}
249 284
250 285
251void VideoWidget::paintEvent( QPaintEvent * ) { 286void VideoWidget::paintEvent( QPaintEvent * ) {
252 QPainter p( this ); 287 QPainter p( this );
253 288
254 if ( mediaPlayerState->fullscreen() ) { 289 if ( mediaPlayerState->fullscreen() ) {
255 // Clear the background 290 // Clear the background
256 p.setBrush( QBrush( Qt::black ) ); 291 p.setBrush( QBrush( Qt::black ) );
257 p.drawRect( rect() ); 292 p.drawRect( rect() );
258 293
259 // Draw the current frame
260 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen
261 } else { 294 } else {
262 // draw border 295 // draw border
263 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); 296 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL );
264 297
265 // Clear the movie screen first 298 // Clear the movie screen first
266 p.setBrush( QBrush( Qt::black ) ); 299 p.setBrush( QBrush( Qt::black ) );
267 p.drawRect( 9, 20, 220, 160 ); 300 p.drawRect( 9, 20, 220, 160 );
268 301
269 // draw current frame (centrally positioned from scaling to maintain aspect ratio) 302 // draw current frame (centrally positioned from scaling to maintain aspect ratio)
270 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 303 //p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
271 304
272 // draw the buttons 305 // draw the buttons
273 for ( int i = 0; i < numButtons; i++ ) { 306 for ( int i = 0; i < numButtons; i++ ) {
274 paintButton( &p, i ); 307 paintButton( &p, i );
275 } 308 }
276 309
277 // draw the slider 310 // draw the slider
278 slider->repaint( TRUE ); 311 slider->repaint( TRUE );
279 } 312 }
280} 313}
281 314
282 315
283void VideoWidget::closeEvent( QCloseEvent* ) { 316void VideoWidget::closeEvent( QCloseEvent* ) {
284 mediaPlayerState->setList(); 317 mediaPlayerState->setList();
285} 318}
286 319
287 320
288bool VideoWidget::playVideo() { 321bool VideoWidget::playVideo() {
289 bool result = FALSE; 322 bool result = FALSE;
290 323
291 int stream = 0; 324 int stream = 0;
292 325
293 int sw = 240; //mediaPlayerState->curDecoder()->videoWidth( stream ); 326 int sw = 240;
294 int sh = 320; //mediaPlayerState->curDecoder()->videoHeight( stream ); 327 int sh = 320;
295 int dd = QPixmap::defaultDepth(); 328 int dd = QPixmap::defaultDepth();
296 int w = height(); 329 int w = height();
297 int h = width(); 330 int h = width();
298 331
299 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 332 return true;
300
301 if ( mediaPlayerState->fullscreen() ) {
302#ifdef USE_DIRECT_PAINTER
303 QDirectPainter p(this);
304
305 if ( ( qt_screen->transformOrientation() == 3 ) &&
306 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) {
307
308 w = 320;
309 h = 240;
310
311 if ( mediaPlayerState->scaled() ) {
312 // maintain aspect ratio
313 if ( w * sh > sw * h )
314 w = sw * h / sh;
315 else
316 h = sh * w / sw;
317 } else {
318 w = sw;
319 h = sh;
320 }
321
322 w--; // we can't allow libmpeg to overwrite.
323 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
324
325 int ox = roff.x() - height() + 2 + (height() - w) / 2;
326 int oy = roff.y() + (width() - h) / 2;
327 int sx = 0, sy = 0;
328
329 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
330 fp += dd * ox / 8;
331 uchar **jt = new uchar*[h];
332 for ( int i = h; i; i-- ) {
333 jt[h - i] = fp;
334 fp += p.lineStep();
335 }
336
337 result = 42; //mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
338
339 delete [] jt;
340 } else {
341#endif
342 QPainter p(this);
343
344 w = 320;
345 h = 240;
346
347 if ( mediaPlayerState->scaled() ) {
348 // maintain aspect ratio
349 if ( w * sh > sw * h ) {
350 w = sw * h / sh;
351 } else {
352 h = sh * w / sw;
353 }
354 } else {
355 w = sw;
356 h = sh;
357 }
358
359 int bytes = ( dd == 16 ) ? 2 : 4;
360 QImage tempFrame( w, h, bytes << 3 );
361 result = 42; // mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
362 // 0, 0, sw, sh, w, h, format, 0) == 0;
363 if ( result && mediaPlayerState->fullscreen() ) {
364
365 int rw = h, rh = w;
366 QImage rotatedFrame( rw, rh, bytes << 3 );
367
368 ushort* in = (ushort*)tempFrame.bits();
369 ushort* out = (ushort*)rotatedFrame.bits();
370 int spl = rotatedFrame.bytesPerLine() / bytes;
371 for (int x=0; x<h; x++) {
372 if ( bytes == 2 ) {
373 ushort* lout = out++ + (w - 1)*spl;
374 for (int y=0; y<w; y++) {
375 *lout=*in++;
376 lout-=spl;
377 }
378 } else {
379 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
380 for (int y=0; y<w; y++) {
381 *lout=*((ulong*)in)++;
382 lout-=spl;
383 }
384 }
385 }
386
387 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
388 }
389#ifdef USE_DIRECT_PAINTER
390 }
391#endif
392 } else {
393
394 w = 220;
395 h = 160;
396
397 // maintain aspect ratio
398 if ( w * sh > sw * h ) {
399 w = sw * h / sh;
400 } else {
401 h = sh * w / sw;
402 }
403
404 result = 42 ; //mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
405
406 QPainter p( this );
407
408 // Image changed size, therefore need to blank the possibly unpainted regions first
409 if ( scaledWidth != w || scaledHeight != h ) {
410 p.setBrush( QBrush( Qt::black ) );
411 p.drawRect( 9, 20, 220, 160 );
412 }
413
414 scaledWidth = w;
415 scaledHeight = h;
416
417 if ( result ) {
418 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
419 }
420 }
421 return result;
422} 333}
423 334
424 335
425 336
426void VideoWidget::keyReleaseEvent( QKeyEvent *e) 337void VideoWidget::keyReleaseEvent( QKeyEvent *e)
427{ 338{
428 switch ( e->key() ) { 339 switch ( e->key() ) {
429////////////////////////////// Zaurus keys 340////////////////////////////// Zaurus keys
430 case Key_Home: 341 case Key_Home:
431 break; 342 break;
432 case Key_F9: //activity 343 case Key_F9: //activity
433 break; 344 break;
434 case Key_F10: //contacts 345 case Key_F10: //contacts
435// hide(); 346// hide();
436 break; 347 break;
437 case Key_F11: //menu 348 case Key_F11: //menu
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index e18edd1..9ab91ac 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,22 +1,54 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
3#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
4 36
5
6#include <qwidget.h> 37#include <qwidget.h>
38#include "xinevideowidget.h"
7 39
8class QPixmap; 40class QPixmap;
9class QSlider; 41class QSlider;
10 42
11enum VideoButtons { 43enum VideoButtons {
12 VideoPrevious, 44 VideoPrevious,
13 VideoStop, 45 VideoStop,
14 VideoPlay, 46 VideoPlay,
15 VideoPause, 47 VideoPause,
16 VideoNext, 48 VideoNext,
17 VideoPlayList, 49 VideoPlayList,
18 VideoFullscreen 50 VideoFullscreen
19}; 51};
20 52
21class VideoWidget : public QWidget { 53class VideoWidget : public QWidget {
22 Q_OBJECT 54 Q_OBJECT
@@ -46,22 +78,23 @@ protected:
46 void mouseMoveEvent( QMouseEvent *event ); 78 void mouseMoveEvent( QMouseEvent *event );
47 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
48 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
49 void closeEvent( QCloseEvent *event ); 81 void closeEvent( QCloseEvent *event );
50 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
51 83
52private: 84private:
53 void paintButton( QPainter *p, int i ); 85 void paintButton( QPainter *p, int i );
54 void toggleButton( int ); 86 void toggleButton( int );
55 void setToggleButton( int, bool ); 87 void setToggleButton( int, bool );
56 88
57 QSlider *slider; 89 QSlider *slider;
58 QPixmap *pixmaps[3]; 90 QPixmap *pixmaps[3];
59 QImage *currentFrame; 91 QImage *currentFrame;
60 int scaledWidth; 92 int scaledWidth;
61 int scaledHeight; 93 int scaledHeight;
94 XineVideoWidget* videoFrame;
62}; 95};
63 96
64#endif // VIDEO_WIDGET_H 97#endif // VIDEO_WIDGET_H
65 98
66 99
67 100
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 7d3b1f7..893ac41 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,48 +1,90 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34
1#include <qtimer.h> 35#include <qtimer.h>
2#include "xinecontrol.h" 36#include "xinecontrol.h"
3#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
4 38
5 39
6extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
7 41
8XineControl::XineControl( QObject *parent, const char *name ) 42XineControl::XineControl( QObject *parent, const char *name )
9 : QObject( parent, name ) { 43 : QObject( parent, name ) {
10 libXine = new XINE::Lib(); 44 libXine = new XINE::Lib();
11 45
12 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
13 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); 47 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) );
14 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 48 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
15 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 49 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
51
16} 52}
17 53
18XineControl::~XineControl() { 54XineControl::~XineControl() {
19 delete libXine; 55 delete libXine;
20} 56}
21 57
22void XineControl::play( const QString& fileName ) { 58void XineControl::play( const QString& fileName ) {
23 libXine->play( fileName ); 59 libXine->play( fileName );
24 mediaPlayerState->setPlaying( true ); 60 mediaPlayerState->setPlaying( true );
25 // default to audio view until we know how to handle video 61 // default to audio view until we know how to handle video
26 // MediaDetect mdetect; 62 // MediaDetect mdetect;
27 char whichGui = mdetect.videoOrAudio( fileName ); 63 char whichGui = mdetect.videoOrAudio( fileName );
28 if (whichGui == 'f') { 64 if (whichGui == 'f') {
29 qDebug("Nicht erkannter Dateityp"); 65 qDebug("Nicht erkannter Dateityp");
30 return; 66 return;
31 } 67 }
32 68
69 if (whichGui == 'a') {
70 libXine->setShowVideo( false );
71 } else {
72 libXine->setShowVideo( true );
73 }
74
33 // determine if slider is shown 75 // determine if slider is shown
34 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); 76 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) );
35 mediaPlayerState->setIsStreaming( libXine->isSeekable() ); 77 mediaPlayerState->setIsStreaming( libXine->isSeekable() );
36 // which gui (video / audio) 78 // which gui (video / audio)
37 mediaPlayerState->setView( whichGui ); 79 mediaPlayerState->setView( whichGui );
38 80
39} 81}
40 82
41void XineControl::stop( bool isSet ) { 83void XineControl::stop( bool isSet ) {
42 if ( !isSet) { 84 if ( !isSet) {
43 libXine->stop(); 85 libXine->stop();
44 mediaPlayerState->setList(); 86 mediaPlayerState->setList();
45 //mediaPlayerState->setPlaying( false ); 87 //mediaPlayerState->setPlaying( false );
46 } else { 88 } else {
47 // play again 89 // play again
48 } 90 }
@@ -59,18 +101,22 @@ int XineControl::currentTime() {
59} 101}
60 102
61void XineControl::length() { 103void XineControl::length() {
62 m_length = libXine->length(); 104 m_length = libXine->length();
63 mediaPlayerState->setLength( m_length ); 105 mediaPlayerState->setLength( m_length );
64} 106}
65 107
66int XineControl::position() { 108int XineControl::position() {
67 m_position = (m_currentTime/m_length*100); 109 m_position = (m_currentTime/m_length*100);
68 mediaPlayerState->setPosition( m_position ); 110 mediaPlayerState->setPosition( m_position );
69 return m_position; 111 return m_position;
70 emit positionChanged( m_position ); 112 emit positionChanged( m_position );
71 QTimer::singleShot( 1000, this, SLOT( position ) ); 113 QTimer::singleShot( 1000, this, SLOT( position ) );
72} 114}
73 115
74void XineControl::setFullscreen( bool isSet ) { 116void XineControl::setFullscreen( bool isSet ) {
75 libXine-> showVideoFullScreen( isSet); 117 libXine->showVideoFullScreen( isSet);
118}
119
120void XineControl::seekTo( long second ) {
121 // libXine->
76} 122}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 145cd0c..47eee91 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -1,37 +1,69 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =.
8 .=l.
9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
1 33
2#ifndef XINECONTROL_H 34#ifndef XINECONTROL_H
3#define XINECONTROL_H 35#define XINECONTROL_H
4 36
5#include "lib.h" 37#include "lib.h"
6#include "mediadetect.h" 38#include "mediadetect.h"
7#include <qobject.h> 39#include <qobject.h>
8 40
9class XineControl : public QObject { 41class XineControl : public QObject {
10 Q_OBJECT 42 Q_OBJECT
11public: 43public:
12 XineControl( QObject *parent = 0, const char *name =0 ); 44 XineControl( QObject *parent = 0, const char *name =0 );
13 ~XineControl(); 45 ~XineControl();
14 46
15public slots: 47public slots:
16 void play( const QString& fileName ); 48 void play( const QString& fileName );
17 void stop( bool ); 49 void stop( bool );
18 void pause( bool ); 50 void pause( bool );
19 void setFullscreen( bool ); 51 void setFullscreen( bool );
20 int currentTime(); 52 int currentTime();
21 53 void seekTo( long );
22 // get length of media file and set it 54 // get length of media file and set it
23 void length(); 55 void length();
24 56
25 int position(); 57 int position();
26 58
27private: 59private:
28 XINE::Lib *libXine; 60 XINE::Lib *libXine;
29 MediaDetect mdetect; 61 MediaDetect mdetect;
30 int m_length; 62 int m_length;
31 int m_currentTime; 63 int m_currentTime;
32 int m_position; 64 int m_position;
33 65
34signals: 66signals:
35 void positionChanged( int position ); 67 void positionChanged( int position );
36 68
37}; 69};
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 47f4805..e02ee7c 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,22 +1,22 @@
1 1
2/* 2/*
3                This file is part of the Opie Project 3                This file is part of the Opie Project
4 4
5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 5              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
6 Copyright (c) 2002 LJP <> 6 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 7 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
8 =. 8 =.
9 .=l. 9 .=l.
10           .>+-= 10           .>+-=
11 _;:,     .>    :=|. This program is free software; you can 11 _;:,     .>    :=|. This program is free software; you can
12.> <`_,   >  .   <= redistribute it and/or modify it under 12.> <`_,   >  .   <= redistribute it and/or modify it under
13:`=1 )Y*s>-.--   : the terms of the GNU General Public 13:`=1 )Y*s>-.--   : the terms of the GNU General Public
14.="- .-=="i,     .._ License as published by the Free Software 14.="- .-=="i,     .._ License as published by the Free Software
15 - .   .-<_>     .<> Foundation; either version 2 of the License, 15 - .   .-<_>     .<> Foundation; either version 2 of the License,
16     ._= =}       : or (at your option) any later version. 16     ._= =}       : or (at your option) any later version.
17    .%`+i>       _;_. 17    .%`+i>       _;_.
18    .i_,=:_.      -<s. This program is distributed in the hope that 18    .i_,=:_.      -<s. This program is distributed in the hope that
19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 19     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
20    : ..    .:,     . . . without even the implied warranty of 20    : ..    .:,     . . . without even the implied warranty of
21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 21    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 22  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU