summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp67
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediadetect.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro1
4 files changed, 39 insertions, 38 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 6d867e5..bf3590b 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,593 +1,590 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50 50
51extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
52 52
53static const int xo = -2; // movable x offset 53static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 54static const int yo = 22; // movable y offset
55 55
56 56
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 58 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 59 setText( "No Song" );
60} 60}
61 61
62Ticker::~Ticker() { 62Ticker::~Ticker() {
63} 63}
64 64
65void Ticker::setText( const QString& text ) { 65void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 66 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 67 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 68 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 69 killTimers();
70 if ( pixelLen > width() ) { 70 if ( pixelLen > width() ) {
71 startTimer( 50 ); 71 startTimer( 50 );
72 } 72 }
73 update(); 73 update();
74} 74}
75 75
76 76
77void Ticker::timerEvent( QTimerEvent * ) { 77void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 79 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 80 repaint( FALSE );
81} 81}
82 82
83void Ticker::drawContents( QPainter *p ) { 83void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 }
86 QPixmap pm( width(), height() ); 87 QPixmap pm( width(), height() );
87 pm.fill( colorGroup().base() ); 88 pm.fill( colorGroup().base() );
88 QPainter pmp( &pm ); 89 QPainter pmp( &pm );
89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 90 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 91 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
91 } 92 }
92 p->drawPixmap( 0, 0, pm ); 93 p->drawPixmap( 0, 0, pm );
93} 94}
94 95
95struct MediaButton { 96struct MediaButton {
96 bool isToggle, isHeld, isDown; 97 bool isToggle, isHeld, isDown;
97}; 98};
98 99
99//Layout information for the audioButtons (and if it is a toggle button or not) 100//Layout information for the audioButtons (and if it is a toggle button or not)
100MediaButton audioButtons[] = { 101MediaButton audioButtons[] = {
101 { TRUE, FALSE, FALSE }, // play 102 { TRUE, FALSE, FALSE }, // play
102 { FALSE, FALSE, FALSE }, // stop 103 { FALSE, FALSE, FALSE }, // stop
103 { FALSE, FALSE, FALSE }, // next 104 { FALSE, FALSE, FALSE }, // next
104 { FALSE, FALSE, FALSE }, // previous 105 { FALSE, FALSE, FALSE }, // previous
105 { FALSE, FALSE, FALSE }, // volume up 106 { FALSE, FALSE, FALSE }, // volume up
106 { FALSE, FALSE, FALSE }, // volume down 107 { FALSE, FALSE, FALSE }, // volume down
107 { TRUE, FALSE, FALSE }, // repeat/loop 108 { TRUE, FALSE, FALSE }, // repeat/loop
108 { FALSE, FALSE, FALSE }, // playlist 109 { FALSE, FALSE, FALSE }, // playlist
109 { FALSE, FALSE, FALSE }, // forward 110 { FALSE, FALSE, FALSE }, // forward
110 { FALSE, FALSE, FALSE } // back 111 { FALSE, FALSE, FALSE } // back
111}; 112};
112 113
113const char *skin_mask_file_names[10] = { 114const char *skin_mask_file_names[10] = {
114 "play", "stop", "next", "prev", "up", 115 "play", "stop", "next", "prev", "up",
115 "down", "loop", "playlist", "forward", "back" 116 "down", "loop", "playlist", "forward", "back"
116}; 117};
117 118
118 119
119static void changeTextColor( QWidget *w ) { 120static void changeTextColor( QWidget *w ) {
120 QPalette p = w->palette(); 121 QPalette p = w->palette();
121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 122 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 123 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
123 w->setPalette( p ); 124 w->setPalette( p );
124} 125}
125 126
126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 127static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
127 128
128 129
129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 130AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
131
132 131
132 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
133 133
134 setCaption( tr("OpiePlayer") ); 134 setCaption( tr("OpiePlayer") );
135 135
136 Config cfg("OpiePlayer"); 136 Config cfg("OpiePlayer");
137 cfg.setGroup("Options"); 137 cfg.setGroup("Options");
138 skin = cfg.readEntry("Skin","default"); 138 skin = cfg.readEntry("Skin","default");
139 //skin = "scaleTest"; 139 //skin = "scaleTest";
140// color of background, frame, degree of transparency 140 // color of background, frame, degree of transparency
141 141
142 QString skinPath = "opieplayer2/skins/" + skin; 142 QString skinPath = "opieplayer2/skins/" + skin;
143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
146 146
147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
148 imgButtonMask->fill( 0 ); 148 imgButtonMask->fill( 0 );
149 149
150 for ( int i = 0; i < 10; i++ ) { 150 for ( int i = 0; i < 10; i++ ) {
151 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 151 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
152 masks[i] = new QBitmap( filename ); 152 masks[i] = new QBitmap( filename );
153 153
154 if ( !masks[i]->isNull() ) { 154 if ( !masks[i]->isNull() ) {
155 QImage imgMask = masks[i]->convertToImage(); 155 QImage imgMask = masks[i]->convertToImage();
156 uchar **dest = imgButtonMask->jumpTable(); 156 uchar **dest = imgButtonMask->jumpTable();
157 for ( int y = 0; y < imgUp->height(); y++ ) { 157 for ( int y = 0; y < imgUp->height(); y++ ) {
158 uchar *line = dest[y]; 158 uchar *line = dest[y];
159 for ( int x = 0; x < imgUp->width(); x++ ) 159 for ( int x = 0; x < imgUp->width(); x++ )
160 if ( !qRed( imgMask.pixel( x, y ) ) ) 160 if ( !qRed( imgMask.pixel( x, y ) ) )
161 line[x] = i + 1; 161 line[x] = i + 1;
162 } 162 }
163 } 163 }
164 164
165 } 165 }
166 166
167 for ( int i = 0; i < 10; i++ ) { 167 for ( int i = 0; i < 10; i++ ) {
168 buttonPixUp[i] = NULL; 168 buttonPixUp[i] = NULL;
169 buttonPixDown[i] = NULL; 169 buttonPixDown[i] = NULL;
170 } 170 }
171 171
172 setBackgroundPixmap( *pixBg ); 172 setBackgroundPixmap( *pixBg );
173 173
174 songInfo.setFocusPolicy( QWidget::NoFocus ); 174 songInfo.setFocusPolicy( QWidget::NoFocus );
175 changeTextColor( &songInfo ); 175 changeTextColor( &songInfo );
176 176
177 slider.setFixedHeight( 20 ); 177 slider.setFixedHeight( 20 );
178 slider.setMinValue( 0 ); 178 slider.setMinValue( 0 );
179 slider.setMaxValue( 1 ); 179 slider.setMaxValue( 1 );
180 slider.setFocusPolicy( QWidget::NoFocus ); 180 slider.setFocusPolicy( QWidget::NoFocus );
181 slider.setBackgroundPixmap( *pixBg ); 181 slider.setBackgroundPixmap( *pixBg );
182 182
183 time.setFocusPolicy( QWidget::NoFocus ); 183 time.setFocusPolicy( QWidget::NoFocus );
184 time.setAlignment( Qt::AlignCenter ); 184 time.setAlignment( Qt::AlignCenter );
185 time.setFrame(FALSE); 185 time.setFrame(FALSE);
186 changeTextColor( &time ); 186 changeTextColor( &time );
187 187
188 resizeEvent( NULL ); 188 resizeEvent( NULL );
189 189
190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
192 192
193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
196// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 196 // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
198 198
199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
203 203
204 204
205 205
206 // Intialise state 206 // Intialise state
207 setLength( mediaPlayerState->length() ); 207 setLength( mediaPlayerState->length() );
208 setPosition( mediaPlayerState->position() ); 208 setPosition( mediaPlayerState->position() );
209 setLooping( mediaPlayerState->fullscreen() ); 209 setLooping( mediaPlayerState->fullscreen() );
210// setPaused( mediaPlayerState->paused() ); 210 // setPaused( mediaPlayerState->paused() );
211 setPlaying( mediaPlayerState->playing() ); 211 setPlaying( mediaPlayerState->playing() );
212 212
213} 213}
214 214
215AudioWidget::~AudioWidget() { 215AudioWidget::~AudioWidget() {
216 216
217 for ( int i = 0; i < 10; i++ ) { 217 for ( int i = 0; i < 10; i++ ) {
218 delete buttonPixUp[i]; 218 delete buttonPixUp[i];
219 delete buttonPixDown[i]; 219 delete buttonPixDown[i];
220 } 220 }
221 delete pixBg; 221 delete pixBg;
222 delete imgUp; 222 delete imgUp;
223 delete imgDn; 223 delete imgDn;
224 delete imgButtonMask; 224 delete imgButtonMask;
225 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
226 delete masks[i]; 226 delete masks[i];
227 } 227 }
228} 228}
229 229
230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
231 QPixmap pix( img.width(), img.height() ); 231 QPixmap pix( img.width(), img.height() );
232 QPainter p( &pix ); 232 QPainter p( &pix );
233 p.drawTiledPixmap( pix.rect(), bg, offset ); 233 p.drawTiledPixmap( pix.rect(), bg, offset );
234 p.drawImage( 0, 0, img ); 234 p.drawImage( 0, 0, img );
235 return new QPixmap( pix ); 235 return new QPixmap( pix );
236} 236}
237 237
238 238
239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
240{
241 QPixmap *pixmap = new QPixmap( pix ); 240 QPixmap *pixmap = new QPixmap( pix );
242 pixmap->setMask( mask ); 241 pixmap->setMask( mask );
243 return pixmap; 242 return pixmap;
244} 243}
245 244
246 245
247 246
248void AudioWidget::resizeEvent( QResizeEvent * ) { 247void AudioWidget::resizeEvent( QResizeEvent * ) {
249 int h = height(); 248 int h = height();
250 int w = width(); 249 int w = width();
251 250
252 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 251 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
253 slider.setFixedWidth( w - 110 ); 252 slider.setFixedWidth( w - 110 );
254 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 253 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
255 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 254 slider.setBackgroundOrigin( QWidget::ParentOrigin );
256 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 255 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
257 256
258 xoff = ( w - imgUp->width() ) / 2; 257 xoff = ( w - imgUp->width() ) / 2;
259 yoff = (( h - imgUp->height() ) / 2) - 10; 258 yoff = (( h - imgUp->height() ) / 2) - 10;
260 QPoint p( xoff, yoff ); 259 QPoint p( xoff, yoff );
261 260
262 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 261 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
263 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 262 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
264 263
265 for ( int i = 0; i < 10; i++ ) { 264 for ( int i = 0; i < 10; i++ ) {
266 if ( !masks[i]->isNull() ) { 265 if ( !masks[i]->isNull() ) {
267 delete buttonPixUp[i]; 266 delete buttonPixUp[i];
268 delete buttonPixDown[i]; 267 delete buttonPixDown[i];
269 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 268 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
270 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 269 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
271 } 270 }
272 } 271 }
273 272
274 delete pixUp; 273 delete pixUp;
275 delete pixDn; 274 delete pixDn;
276} 275}
277 276
278static bool audioSliderBeingMoved = FALSE; 277static bool audioSliderBeingMoved = FALSE;
279 278
280 279
281void AudioWidget::sliderPressed() { 280void AudioWidget::sliderPressed() {
282 audioSliderBeingMoved = TRUE; 281 audioSliderBeingMoved = TRUE;
283} 282}
284 283
285 284
286void AudioWidget::sliderReleased() { 285void AudioWidget::sliderReleased() {
287 audioSliderBeingMoved = FALSE; 286 audioSliderBeingMoved = FALSE;
288 if ( slider.width() == 0 ) 287 if ( slider.width() == 0 )
289 return; 288 return;
290 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 289 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
291 mediaPlayerState->setPosition( val ); 290 mediaPlayerState->setPosition( val );
292} 291}
293 292
294void AudioWidget::setPosition( long i ) { 293void AudioWidget::setPosition( long i ) {
295// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 294 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
296 updateSlider( i, mediaPlayerState->length() ); 295 updateSlider( i, mediaPlayerState->length() );
297} 296}
298 297
299 298
300void AudioWidget::setLength( long max ) { 299void AudioWidget::setLength( long max ) {
301 updateSlider( mediaPlayerState->position(), max ); 300 updateSlider( mediaPlayerState->position(), max );
302} 301}
303 302
304 303
305void AudioWidget::setView( char view ) { 304void AudioWidget::setView( char view ) {
306 305
307// this isnt working for some reason 306 // this isnt working for some reason
308 307
309 if ( mediaPlayerState->streaming() ) { 308 if ( mediaPlayerState->streaming() ) {
310 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 309 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
311 if( !slider.isHidden()) { 310 if( !slider.isHidden()) {
312 slider.hide(); 311 slider.hide();
313 } 312 }
314 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 313 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
315 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 314 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
316 } else { 315 } else {
317 // this stops the slider from being moved, thus 316 // this stops the slider from being moved, thus
318 // does not stop stream when it reaches the end 317 // does not stop stream when it reaches the end
319 slider.show(); 318 slider.show();
320 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 319 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
321 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 320 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
322 } 321 }
323 322
324 if ( view == 'a' ) { 323 if ( view == 'a' ) {
325 // startTimer( 150 ); 324 // startTimer( 150 );
326 showMaximized(); 325 showMaximized();
327 } else { 326 } else {
328 killTimers(); 327 killTimers();
329 hide(); 328 hide();
330 } 329 }
331 qApp->processEvents(); 330 qApp->processEvents();
332} 331}
333 332
334 333
335static QString timeAsString( long length ) { 334static QString timeAsString( long length ) {
336 int minutes = length / 60; 335 int minutes = length / 60;
337 int seconds = length % 60; 336 int seconds = length % 60;
338 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 337 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
339} 338}
340 339
341void AudioWidget::updateSlider( long i, long max ) { 340void AudioWidget::updateSlider( long i, long max ) {
342 341
343 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 342 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
344// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 343// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
345 344
346 if ( max == 0 ) { 345 if ( max == 0 ) {
347 return; 346 return;
348 } 347 }
349 // Will flicker too much if we don't do this 348 // Will flicker too much if we don't do this
350 // Scale to something reasonable 349 // Scale to something reasonable
351 int width = slider.width(); 350 int width = slider.width();
352 int val = int((double)i * width / max); 351 int val = int((double)i * width / max);
353 if ( !audioSliderBeingMoved ) { 352 if ( !audioSliderBeingMoved ) {
354 if ( slider.value() != val ) { 353 if ( slider.value() != val ) {
355 slider.setValue( val ); 354 slider.setValue( val );
356 } 355 }
357 356
358 if ( slider.maxValue() != width ) { 357 if ( slider.maxValue() != width ) {
359 slider.setMaxValue( width ); 358 slider.setMaxValue( width );
360 } 359 }
361 } 360 }
362} 361}
363 362
364 363
365void AudioWidget::setToggleButton( int i, bool down ) { 364void AudioWidget::setToggleButton( int i, bool down ) {
366 qDebug("setToggleButton %d", i); 365 qDebug("setToggleButton %d", i);
367 if ( down != audioButtons[i].isDown ) { 366 if ( down != audioButtons[i].isDown ) {
368 toggleButton( i ); 367 toggleButton( i );
369 } 368 }
370} 369}
371 370
372 371
373void AudioWidget::toggleButton( int i ) { 372void AudioWidget::toggleButton( int i ) {
374 audioButtons[i].isDown = !audioButtons[i].isDown; 373 audioButtons[i].isDown = !audioButtons[i].isDown;
375 QPainter p(this); 374 QPainter p(this);
376 paintButton ( &p, i ); 375 paintButton ( &p, i );
377} 376}
378 377
379 378
380void AudioWidget::paintButton( QPainter *p, int i ) { 379void AudioWidget::paintButton( QPainter *p, int i ) {
381 if ( audioButtons[i].isDown ) { 380 if ( audioButtons[i].isDown ) {
382 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 381 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
383 } else { 382 } else {
384 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 383 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
385 } 384 }
386} 385}
387 386
388 387
389void AudioWidget::skipFor() { 388void AudioWidget::skipFor() {
390 skipDirection = +1; 389 skipDirection = +1;
391 startTimer( 50 ); 390 startTimer( 50 );
392 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 391 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
393} 392}
394 393
395void AudioWidget::skipBack() { 394void AudioWidget::skipBack() {
396 skipDirection = -1; 395 skipDirection = -1;
397 startTimer( 50 ); 396 startTimer( 50 );
398 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 397 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
399} 398}
400 399
401 400
402 401
403void AudioWidget::stopSkip() { 402void AudioWidget::stopSkip() {
404 killTimers(); 403 killTimers();
405} 404}
406 405
407 406
408void AudioWidget::timerEvent( QTimerEvent * ) { 407void AudioWidget::timerEvent( QTimerEvent * ) {
409 if ( skipDirection == +1 ) { 408 if ( skipDirection == +1 ) {
410 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 409 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
411 } else if ( skipDirection == -1 ) { 410 } else if ( skipDirection == -1 ) {
412 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 411 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
413 } 412 }
414} 413}
415 414
416 415
417void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 416void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
418 for ( int i = 0; i < numButtons; i++ ) { 417 for ( int i = 0; i < numButtons; i++ ) {
419 if ( event->state() == QMouseEvent::LeftButton ) { 418 if ( event->state() == QMouseEvent::LeftButton ) {
420 // The test to see if the mouse click is inside the button or not 419 // The test to see if the mouse click is inside the button or not
421 int x = event->pos().x() - xoff; 420 int x = event->pos().x() - xoff;
422 int y = event->pos().y() - yoff; 421 int y = event->pos().y() - yoff;
423 422
424 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 423 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
425 && y < imgButtonMask->height() 424 && y < imgButtonMask->height()
426 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 425 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
427 426
428 if ( isOnButton && !audioButtons[i].isHeld ) { 427 if ( isOnButton && !audioButtons[i].isHeld ) {
429 audioButtons[i].isHeld = TRUE; 428 audioButtons[i].isHeld = TRUE;
430 toggleButton(i); 429 toggleButton(i);
431 switch (i) { 430 switch (i) {
432 case AudioVolumeUp: 431 case AudioVolumeUp:
433 emit moreClicked(); 432 emit moreClicked();
434 return; 433 return;
435 case AudioVolumeDown: 434 case AudioVolumeDown:
436 emit lessClicked(); 435 emit lessClicked();
437 return; 436 return;
438 case AudioForward: 437 case AudioForward:
439 emit forwardClicked(); 438 emit forwardClicked();
440 return; 439 return;
441 case AudioBack: 440 case AudioBack:
442 emit backClicked(); 441 emit backClicked();
443 return; 442 return;
444 } 443 }
444 } else if ( !isOnButton && audioButtons[i].isHeld ) {
445 audioButtons[i].isHeld = FALSE;
446 toggleButton(i);
445 } 447 }
446 else if ( !isOnButton && audioButtons[i].isHeld ) {
447 audioButtons[i].isHeld = FALSE;
448 toggleButton(i);
449 }
450 } else { 448 } else {
451 if ( audioButtons[i].isHeld ) { 449 if ( audioButtons[i].isHeld ) {
452 audioButtons[i].isHeld = FALSE; 450 audioButtons[i].isHeld = FALSE;
453 if ( !audioButtons[i].isToggle ) { 451 if ( !audioButtons[i].isToggle ) {
454 setToggleButton( i, FALSE ); 452 setToggleButton( i, FALSE );
455 } 453 }
456 switch (i) { 454 switch (i) {
457 case AudioPlay: 455 case AudioPlay:
458 if( mediaPlayerState->isPaused ) { 456 if( mediaPlayerState->isPaused ) {
459// setToggleButton( i, FALSE ); 457// setToggleButton( i, FALSE );
460 mediaPlayerState->setPaused( FALSE ); 458 mediaPlayerState->setPaused( FALSE );
461 return; 459 return;
462 } else if( !mediaPlayerState->isPaused ) { 460 } else if( !mediaPlayerState->isPaused ) {
463// setToggleButton( i, TRUE ); 461// setToggleButton( i, TRUE );
464 mediaPlayerState->setPaused( TRUE ); 462 mediaPlayerState->setPaused( TRUE );
465 return; 463 return;
466 } else { 464 } else {
467 // setToggleButton( i, TRUE ); 465 // setToggleButton( i, TRUE );
468 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 466 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
469 } 467 }
470 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 468 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
471 case AudioNext: mediaPlayerState->setNext(); return; 469 case AudioNext: mediaPlayerState->setNext(); return;
472 case AudioPrevious: mediaPlayerState->setPrev(); return; 470 case AudioPrevious: mediaPlayerState->setPrev(); return;
473 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 471 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
474 case AudioVolumeUp: emit moreReleased(); return; 472 case AudioVolumeUp: emit moreReleased(); return;
475 case AudioVolumeDown: emit lessReleased(); return; 473 case AudioVolumeDown: emit lessReleased(); return;
476 case AudioPlayList: mediaPlayerState->setList(); return; 474 case AudioPlayList: mediaPlayerState->setList(); return;
477 case AudioForward: emit forwardReleased(); return; 475 case AudioForward: emit forwardReleased(); return;
478 case AudioBack: emit backReleased(); return; 476 case AudioBack: emit backReleased(); return;
479 } 477 }
480 } 478 }
481 } 479 }
482 } 480 }
483} 481}
484 482
485 483
486void AudioWidget::mousePressEvent( QMouseEvent *event ) { 484void AudioWidget::mousePressEvent( QMouseEvent *event ) {
487 mouseMoveEvent( event ); 485 mouseMoveEvent( event );
488} 486}
489 487
490 488
491void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 489void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
492 mouseMoveEvent( event ); 490 mouseMoveEvent( event );
493} 491}
494 492
495 493
496void AudioWidget::showEvent( QShowEvent* ) { 494void AudioWidget::showEvent( QShowEvent* ) {
497 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 495 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
498 mouseMoveEvent( &event ); 496 mouseMoveEvent( &event );
499} 497}
500 498
501 499
502void AudioWidget::closeEvent( QCloseEvent* ) { 500void AudioWidget::closeEvent( QCloseEvent* ) {
503 mediaPlayerState->setList(); 501 mediaPlayerState->setList();
504} 502}
505 503
506 504
507void AudioWidget::paintEvent( QPaintEvent * pe) { 505void AudioWidget::paintEvent( QPaintEvent * pe) {
508 if ( !pe->erased() ) { 506 if ( !pe->erased() ) {
509 // Combine with background and double buffer 507 // Combine with background and double buffer
510 QPixmap pix( pe->rect().size() ); 508 QPixmap pix( pe->rect().size() );
511 QPainter p( &pix ); 509 QPainter p( &pix );
512 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 510 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
513 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 511 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
514 for ( int i = 0; i < numButtons; i++ ) 512 for ( int i = 0; i < numButtons; i++ )
515 paintButton( &p, i ); 513 paintButton( &p, i );
516 QPainter p2( this ); 514 QPainter p2( this );
517 p2.drawPixmap( pe->rect().topLeft(), pix ); 515 p2.drawPixmap( pe->rect().topLeft(), pix );
518 } else { 516 } else {
519 QPainter p( this ); 517 QPainter p( this );
520 for ( int i = 0; i < numButtons; i++ ) 518 for ( int i = 0; i < numButtons; i++ )
521 paintButton( &p, i ); 519 paintButton( &p, i );
522 } 520 }
523} 521}
524 522
525void AudioWidget::keyReleaseEvent( QKeyEvent *e) 523void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
526{
527 switch ( e->key() ) { 524 switch ( e->key() ) {
528////////////////////////////// Zaurus keys 525 ////////////////////////////// Zaurus keys
529 case Key_Home: 526 case Key_Home:
530 break; 527 break;
531 case Key_F9: //activity 528 case Key_F9: //activity
532 hide(); 529 hide();
533// qDebug("Audio F9"); 530 // qDebug("Audio F9");
534 break; 531 break;
535 case Key_F10: //contacts 532 case Key_F10: //contacts
536 break; 533 break;
537 case Key_F11: //menu 534 case Key_F11: //menu
538 mediaPlayerState->toggleBlank(); 535 mediaPlayerState->toggleBlank();
539 break; 536 break;
540 case Key_F12: //home 537 case Key_F12: //home
541 break; 538 break;
542 case Key_F13: //mail 539 case Key_F13: //mail
543 mediaPlayerState->toggleBlank(); 540 mediaPlayerState->toggleBlank();
544 break; 541 break;
545 case Key_Space: { 542 case Key_Space: {
546 if(mediaPlayerState->playing()) { 543 if(mediaPlayerState->playing()) {
547// toggleButton(1); 544 // toggleButton(1);
548 mediaPlayerState->setPlaying(FALSE); 545 mediaPlayerState->setPlaying(FALSE);
549// toggleButton(1); 546 // toggleButton(1);
550 } else { 547 } else {
551// toggleButton(0); 548 // toggleButton(0);
552 mediaPlayerState->setPlaying(TRUE); 549 mediaPlayerState->setPlaying(TRUE);
553// toggleButton(0); 550 // toggleButton(0);
554 } 551 }
555 } 552 }
556 break; 553 break;
557 case Key_Down: 554 case Key_Down:
558// toggleButton(6); 555 // toggleButton(6);
559 emit lessClicked(); 556 emit lessClicked();
560 emit lessReleased(); 557 emit lessReleased();
561// toggleButton(6); 558 // toggleButton(6);
562 break; 559 break;
563 case Key_Up: 560 case Key_Up:
564// toggleButton(5); 561 // toggleButton(5);
565 emit moreClicked(); 562 emit moreClicked();
566 emit moreReleased(); 563 emit moreReleased();
567// toggleButton(5); 564 // toggleButton(5);
568 break; 565 break;
569 case Key_Right: 566 case Key_Right:
570// toggleButton(3); 567 // toggleButton(3);
571 mediaPlayerState->setNext(); 568 mediaPlayerState->setNext();
572// toggleButton(3); 569 // toggleButton(3);
573 break; 570 break;
574 case Key_Left: 571 case Key_Left:
575// toggleButton(4); 572 // toggleButton(4);
576 mediaPlayerState->setPrev(); 573 mediaPlayerState->setPrev();
577// toggleButton(4); 574 // toggleButton(4);
578 break; 575 break;
579 case Key_Escape: { 576 case Key_Escape: {
580#if defined(QT_QWS_IPAQ) 577#if defined(QT_QWS_IPAQ)
581 if( mediaPlayerState->isPaused ) { 578 if( mediaPlayerState->isPaused ) {
582 setToggleButton( i, FALSE ); 579 setToggleButton( i, FALSE );
583 mediaPlayerState->setPaused( FALSE ); 580 mediaPlayerState->setPaused( FALSE );
584 } else if( !mediaPlayerState->isPaused ) { 581 } else if( !mediaPlayerState->isPaused ) {
585 setToggleButton( i, TRUE ); 582 setToggleButton( i, TRUE );
586 mediaPlayerState->setPaused( TRUE ); 583 mediaPlayerState->setPaused( TRUE );
587 } 584 }
588#endif 585#endif
589 } 586 }
590 break; 587 break;
591 588
592 }; 589 };
593} 590}
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 39364ab..3a82a50 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,249 +1,249 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41 41
42#include <qgfx_qws.h> 42#include <qgfx_qws.h>
43#include <qdirectpainter_qws.h> 43#include <qdirectpainter_qws.h>
44 44
45#include "xinevideowidget.h" 45#include "xinevideowidget.h"
46#include "frame.h" 46#include "frame.h"
47#include "lib.h" 47#include "lib.h"
48 48
49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
50 int width, int height,int bytes ); 50 int width, int height,int bytes );
51 51
52extern "C" { 52extern "C" {
53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); 53 vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
54 int null_is_showing_video( vo_driver_t* self ); 54 int null_is_showing_video( vo_driver_t* self );
55 void null_set_show_video( vo_driver_t* self, int show ); 55 void null_set_show_video( vo_driver_t* self, int show );
56 int null_is_fullscreen( vo_driver_t* self ); 56 int null_is_fullscreen( vo_driver_t* self );
57 void null_set_fullscreen( vo_driver_t* self, int screen ); 57 void null_set_fullscreen( vo_driver_t* self, int screen );
58 int null_is_scaling( vo_driver_t* self ); 58 int null_is_scaling( vo_driver_t* self );
59 void null_set_scaling( vo_driver_t* self, int scale ); 59 void null_set_scaling( vo_driver_t* self, int scale );
60 void null_set_gui_width( vo_driver_t* self, int width ); 60 void null_set_gui_width( vo_driver_t* self, int width );
61 void null_set_gui_height( vo_driver_t* self, int height ); 61 void null_set_gui_height( vo_driver_t* self, int height );
62 void null_set_mode( vo_driver_t* self, int depth, int rgb ); 62 void null_set_mode( vo_driver_t* self, int depth, int rgb );
63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); 63 void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
64} 64}
65 65
66using namespace XINE; 66using namespace XINE;
67 67
68Lib::Lib(XineVideoWidget* widget) { 68Lib::Lib(XineVideoWidget* widget) {
69 m_video = false; 69 m_video = false;
70 m_wid = widget; 70 m_wid = widget;
71 printf("Lib"); 71 printf("Lib");
72 QCString str( getenv("HOME") ); 72 QCString str( getenv("HOME") );
73 str += "/Settings/opiexine.cf"; 73 str += "/Settings/opiexine.cf";
74 // get the configuration 74 // get the configuration
75 75
76 // not really OO, should be an extra class, later 76 // not really OO, should be an extra class, later
77 if ( !QFile(str).exists() ) { 77 if ( !QFile(str).exists() ) {
78 QFile f(str); 78 QFile f(str);
79 f.open(IO_WriteOnly); 79 f.open(IO_WriteOnly);
80 QTextStream ts( &f ); 80 QTextStream ts( &f );
81 ts << "misc.memcpy_method:glibc\n"; 81 ts << "misc.memcpy_method:glibc\n";
82 f.close(); 82 f.close();
83 } 83 }
84 84
85 m_config = xine_config_file_init( str.data() ); 85 m_config = xine_config_file_init( str.data() );
86 86
87 // allocate oss for sound 87 // allocate oss for sound
88 // and fb for framebuffer 88 // and fb for framebuffer
89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; 89 m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
90 if (m_audioOutput == NULL ) 90 if (m_audioOutput == NULL )
91 printf("Failure\n"); 91 printf("Failure\n");
92 else 92 else
93 printf("Success\n"); 93 printf("Success\n");
94 94
95 95
96 // test code 96 // test code
97/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", 97/* m_videoOutput = xine_load_video_output_plugin(m_config, "fb",
98 VISUAL_TYPE_FB, 98 VISUAL_TYPE_FB,
99 0 ); 99 0 );
100*/ 100*/
101 101
102 char** files = xine_list_video_output_plugins(3); 102 char** files = xine_list_video_output_plugins(3);
103 char* out; 103 char* out;
104 int i = 0; 104 int i = 0;
105 while ( ( out = files[i] ) != 0 ) { 105 while ( ( out = files[i] ) != 0 ) {
106 printf("Video %s\n", out ); 106 printf("Video %s\n", out );
107 i++; 107 i++;
108 } 108 }
109// m_xine = xine_init( m_videoOutput, 109// m_xine = xine_init( m_videoOutput,
110// m_audioOutput, 110// m_audioOutput,
111// m_config ); 111// m_config );
112 // test loading 112 // test loading
113 m_videoOutput = ::init_video_out_plugin( m_config, NULL ); 113 m_videoOutput = ::init_video_out_plugin( m_config, NULL );
114 if (m_wid != 0 ) { 114 if (m_wid != 0 ) {
115 printf("!0\n" ); 115 printf("!0\n" );
116 resize ( m_wid-> size ( )); 116 resize ( m_wid-> size ( ));
117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 117 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
118 m_wid-> setImage ( new QImage ( Resource::loadImage(""))); 118 m_wid-> setImage ( new QImage ( Resource::loadImage("")));
119 m_wid->repaint(); 119 m_wid->repaint();
120 } 120 }
121 null_display_handler( m_videoOutput, 121 null_display_handler( m_videoOutput,
122 xine_display_frame, 122 xine_display_frame,
123 this ); 123 this );
124 124
125 m_xine = xine_init( m_videoOutput, 125 m_xine = xine_init( m_videoOutput,
126 m_audioOutput, m_config ); 126 m_audioOutput, m_config );
127 // install the event handler 127 // install the event handler
128 xine_register_event_listener( m_xine, xine_event_handler, this ); 128 xine_register_event_listener( m_xine, xine_event_handler, this );
129} 129}
130 130
131Lib::~Lib() { 131Lib::~Lib() {
132 delete m_config; 132 delete m_config;
133 xine_remove_event_listener( m_xine, xine_event_handler ); 133 xine_remove_event_listener( m_xine, xine_event_handler );
134 xine_exit( m_xine ); 134 xine_exit( m_xine );
135 delete m_videoOutput; 135 delete m_videoOutput;
136 //delete m_audioOutput; 136 //delete m_audioOutput;
137 137
138} 138}
139 139
140void Lib::resize ( const QSize &s ) 140void Lib::resize ( const QSize &s )
141{ 141{
142 if ( s. width ( ) && s. height ( )) { 142 if ( s. width ( ) && s. height ( )) {
143 ::null_set_gui_width( m_videoOutput, s. width() ); 143 ::null_set_gui_width( m_videoOutput, s. width() );
144 ::null_set_gui_height(m_videoOutput, s. height() ); 144 ::null_set_gui_height(m_videoOutput, s. height() );
145 } 145 }
146} 146}
147 147
148QCString Lib::version() { 148QCString Lib::version() {
149 QCString str( xine_get_str_version() ); 149 QCString str( xine_get_str_version() );
150 return str; 150 return str;
151}; 151};
152 152
153int Lib::majorVersion() { 153int Lib::majorVersion() {
154 return xine_get_major_version(); 154 return xine_get_major_version();
155} 155}
156int Lib::minorVersion() { 156int Lib::minorVersion() {
157 return xine_get_minor_version(); 157 return xine_get_minor_version();
158}; 158};
159 159
160int Lib::subVersion() { 160int Lib::subVersion() {
161 return xine_get_sub_version(); 161 return xine_get_sub_version();
162} 162}
163int Lib::play( const QString& fileName, 163int Lib::play( const QString& fileName,
164 int startPos, 164 int startPos,
165 int start_time ) { 165 int start_time ) {
166 QString str = fileName.stripWhiteSpace(); 166 QString str = fileName.stripWhiteSpace();
167 //workaround OpiePlayer bug 167 //workaround OpiePlayer bug
168 if (str.right(1) == QString::fromLatin1("/") ) 168 //f (str.right(1) == QString::fromLatin1("/") )
169 str = str.mid( str.length() -1 ); 169 // str = str.mid( str.length() -1 );
170 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), 170 return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
171 startPos, start_time); 171 startPos, start_time);
172} 172}
173void Lib::stop() { 173void Lib::stop() {
174 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 174 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
175 xine_stop(m_xine ); 175 xine_stop(m_xine );
176} 176}
177void Lib::pause(){ 177void Lib::pause(){
178 xine_set_speed( m_xine, SPEED_PAUSE ); 178 xine_set_speed( m_xine, SPEED_PAUSE );
179} 179}
180int Lib::speed() { 180int Lib::speed() {
181 return xine_get_speed( m_xine ); 181 return xine_get_speed( m_xine );
182} 182}
183void Lib::setSpeed( int speed ) { 183void Lib::setSpeed( int speed ) {
184 xine_set_speed( m_xine, speed ); 184 xine_set_speed( m_xine, speed );
185} 185}
186int Lib::status(){ 186int Lib::status(){
187 return xine_get_status( m_xine ); 187 return xine_get_status( m_xine );
188} 188}
189int Lib::currentPosition(){ 189int Lib::currentPosition(){
190 return xine_get_current_position( m_xine ); 190 return xine_get_current_position( m_xine );
191} 191}
192int Lib::currentTime() { 192int Lib::currentTime() {
193 return xine_get_current_time( m_xine ); 193 return xine_get_current_time( m_xine );
194}; 194};
195int Lib::length() { 195int Lib::length() {
196 return xine_get_stream_length( m_xine ); 196 return xine_get_stream_length( m_xine );
197} 197}
198bool Lib::isSeekable() { 198bool Lib::isSeekable() {
199 return xine_is_stream_seekable(m_xine); 199 return xine_is_stream_seekable(m_xine);
200} 200}
201Frame Lib::currentFrame() { 201Frame Lib::currentFrame() {
202 Frame frame; 202 Frame frame;
203 return frame; 203 return frame;
204}; 204};
205int Lib::error() { 205int Lib::error() {
206 return xine_get_error( m_xine ); 206 return xine_get_error( m_xine );
207}; 207};
208void Lib::handleXineEvent( xine_event_t* t ) { 208void Lib::handleXineEvent( xine_event_t* t ) {
209 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) 209 if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
210 emit stopped(); 210 emit stopped();
211} 211}
212void Lib::setShowVideo( bool video ) { 212void Lib::setShowVideo( bool video ) {
213 m_video = video; 213 m_video = video;
214 ::null_set_show_video( m_videoOutput, video ); 214 ::null_set_show_video( m_videoOutput, video );
215} 215}
216bool Lib::isShowingVideo() { 216bool Lib::isShowingVideo() {
217 return ::null_is_showing_video( m_videoOutput ); 217 return ::null_is_showing_video( m_videoOutput );
218} 218}
219void Lib::showVideoFullScreen( bool fullScreen ) { 219void Lib::showVideoFullScreen( bool fullScreen ) {
220 ::null_set_fullscreen( m_videoOutput, fullScreen ); 220 ::null_set_fullscreen( m_videoOutput, fullScreen );
221} 221}
222bool Lib::isVideoFullScreen() { 222bool Lib::isVideoFullScreen() {
223 return ::null_is_fullscreen( m_videoOutput ); 223 return ::null_is_fullscreen( m_videoOutput );
224} 224}
225void Lib::setScaling( bool scale ) { 225void Lib::setScaling( bool scale ) {
226 ::null_set_scaling( m_videoOutput, scale ); 226 ::null_set_scaling( m_videoOutput, scale );
227} 227}
228bool Lib::isScaling() { 228bool Lib::isScaling() {
229 return ::null_is_scaling( m_videoOutput ); 229 return ::null_is_scaling( m_videoOutput );
230} 230}
231void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { 231void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
232 ((Lib*)user_data)->handleXineEvent( t ); 232 ((Lib*)user_data)->handleXineEvent( t );
233} 233}
234void Lib::xine_display_frame( void* user_data, uint8_t *frame, 234void Lib::xine_display_frame( void* user_data, uint8_t *frame,
235 int width, int height, int bytes ) { 235 int width, int height, int bytes ) {
236 236
237 ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); 237 ((Lib*)user_data)->drawFrame( frame, width, height, bytes );
238} 238}
239void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 239void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
240 if (!m_video ) { 240 if (!m_video ) {
241 qWarning("not showing video now"); 241 qWarning("not showing video now");
242 return; 242 return;
243 } 243 }
244// qWarning("called draw frame %d %d", width, height); 244// qWarning("called draw frame %d %d", width, height);
245 245
246 m_wid->setImage( frame, width, height, bytes ); 246 m_wid->setImage( frame, width, height, bytes );
247// m_wid->repaint(false); 247// m_wid->repaint(false);
248 248
249} 249}
diff --git a/noncore/multimedia/opieplayer2/mediadetect.cpp b/noncore/multimedia/opieplayer2/mediadetect.cpp
index 5e0da88..91137db 100644
--- a/noncore/multimedia/opieplayer2/mediadetect.cpp
+++ b/noncore/multimedia/opieplayer2/mediadetect.cpp
@@ -1,40 +1,43 @@
1#include <qstring.h> 1#include <qstring.h>
2#include "mediadetect.h" 2#include "mediadetect.h"
3 3
4 4
5MediaDetect::MediaDetect() { 5MediaDetect::MediaDetect() {
6} 6}
7 7
8MediaDetect::~MediaDetect() { 8MediaDetect::~MediaDetect() {
9} 9}
10 10
11char MediaDetect::videoOrAudio( const QString& fileName ) { 11char MediaDetect::videoOrAudio( const QString& fileName ) {
12 if( (fileName.lower()).right(4) == ".avi" || 12 if( (fileName.lower()).right(4) == ".avi" ||
13 (fileName.lower()).right(4) == ".mpg" || 13 (fileName.lower()).right(4) == ".mpg" ||
14 (fileName.lower()).right(4) == ".asf" || 14 (fileName.lower()).right(4) == ".asf" ||
15 (fileName.lower()).right(4) == ".mov" || 15 (fileName.lower()).right(4) == ".mov" ||
16 (fileName.lower()).right(5) == ".mpeg" ) { 16 (fileName.lower()).right(5) == ".mpeg" ) {
17 qDebug("Video out taken"); 17 qDebug("Video out taken");
18 return 'v'; 18 return 'v';
19 } else if ( (fileName.lower()).right(4) == "·mp1" || 19 } else if ( (fileName.lower()).right(4) == "·mp1" ||
20 (fileName.lower()).right(4) == ".mp3" || 20 (fileName.lower()).right(4) == ".mp3" ||
21 (fileName.lower()).right(4) == ".ogg" || 21 (fileName.lower()).right(4) == ".ogg" ||
22 (fileName.lower()).right(4) == ".wav" ) { 22 (fileName.lower()).right(4) == ".wav" ) {
23 qDebug("AUDIO out taken"); 23 qDebug("AUDIO out taken");
24 return 'a'; 24 return 'a';
25 } else if ( (fileName.lower()).left(7) == "http://" &&
26 (fileName.lower()).right(1) == "/" ) {
27 return 'a';
25 } else { 28 } else {
26 return 'f'; 29 return 'f';
27 } 30 }
28} 31}
29 32
30bool MediaDetect::isStreaming( const QString& fileName ) { 33bool MediaDetect::isStreaming( const QString& fileName ) {
31 // ugly 34 // ugly
32 if( (fileName.lower()).left(4) == "http" ) { 35 if( (fileName.lower()).left(4) == "http" ) {
33 return true; 36 return true;
34 } else if ( (fileName.lower()).left(3) == "ftp" ) { 37 } else if ( (fileName.lower()).left(3) == "ftp" ) {
35 return true; 38 return true;
36 } else { 39 } else {
37 return false; 40 return false;
38 } 41 }
39} 42}
40 43
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index edc4624..03540a1 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,23 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3#CONFIG = qt warn_on debug
3#release 4#release
4DESTDIR = $(OPIEDIR)/bin 5DESTDIR = $(OPIEDIR)/bin
5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ 6HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ 7 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \
7 frame.h lib.h xinevideowidget.h volumecontrol.h\ 8 frame.h lib.h xinevideowidget.h volumecontrol.h\
8 alphablend.h yuv2rgb.h 9 alphablend.h yuv2rgb.h
9SOURCES = main.cpp \ 10SOURCES = main.cpp \
10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ 11 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\
11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ 12 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \
12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\ 13 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\
13 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S 14 alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S
14TARGET = opieplayer2 15TARGET = opieplayer2
15INCLUDEPATH += $(OPIEDIR)/include 16INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 17DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lqpe -lpthread -lopie -lxine -lxineutils 18LIBS += -lqpe -lpthread -lopie -lxine -lxineutils
18MOC_DIR=qpeobj 19MOC_DIR=qpeobj
19OBJECTS_DIR=qpeobj 20OBJECTS_DIR=qpeobj
20 21
21INCLUDEPATH += $(OPIEDIR)/include 22INCLUDEPATH += $(OPIEDIR)/include
22DEPENDPATH += $(OPIEDIR)/include 23DEPENDPATH += $(OPIEDIR)/include
23 24