summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-03 21:45:32 (UTC)
committer llornkcor <llornkcor>2002-11-03 21:45:32 (UTC)
commitbf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (patch) (unidiff)
treef2a02844f411d874e9afd703c18b6ebd70d97172
parent5ba841a12e67b326833751ea502cf054e423114d (diff)
downloadopie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.zip
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.gz
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.bz2
m3u stuff and op2 skins
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp316
-rw-r--r--core/multimedia/opieplayer/audiowidget.h73
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp27
-rw-r--r--core/multimedia/opieplayer/inputDialog.h17
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp13
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h2
-rw-r--r--core/multimedia/opieplayer/opie-mediaplayer.control2
-rw-r--r--core/multimedia/opieplayer/opieplayer.pro9
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp474
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
10 files changed, 526 insertions, 412 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index b96b1ef..896da91 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -31,76 +31,117 @@
31#include "audiowidget.h" 31#include "audiowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34#include <stdlib.h>
35#include <stdio.h>
36
34extern MediaPlayerState *mediaPlayerState; 37extern MediaPlayerState *mediaPlayerState;
35 38
36 39
37static const int xo = -2; // movable x offset 40static const int xo = -2; // movable x offset
38static const int yo = 22; // movable y offset 41static const int yo = 22; // movable y offset
39 42
40
41struct MediaButton { 43struct MediaButton {
42 int xPos, yPos; 44 bool isToggle, isHeld, isDown;
43 int color;
44 bool isToggle, isBig, isHeld, isDown;
45}; 45};
46 46
47
48// 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)
49MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
50 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
51 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
52 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 51 { TRUE, FALSE, FALSE }, // pause
53 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 52 { FALSE, FALSE, FALSE }, // next
54 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 53 { FALSE, FALSE, FALSE }, // previous
55 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 54 { FALSE, FALSE, FALSE }, // volume up
56 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 55 { FALSE, FALSE, FALSE }, // volume down
57 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 56 { TRUE, FALSE, FALSE }, // repeat/loop
58 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 57 { FALSE, FALSE, FALSE }, // playlist
58 { FALSE, FALSE, FALSE }, // forward
59 { FALSE, FALSE, FALSE } // back
60};
61
62const char *skin_mask_file_names[11] = {
63 "play", "stop", "pause", "next", "prev", "up",
64 "down", "loop", "playlist", "forward", "back"
59}; 65};
60 66
61 67
62static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 68static void changeTextColor( QWidget *w ) {
69 QPalette p = w->palette();
70 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
71 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
72 w->setPalette( p );
73}
63 74
75static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
64 76
65AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 77AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
66 QWidget( parent, name, f ) 78 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
67{ 79{
68 setCaption( tr("OpiePlayer") ); 80 setCaption( tr("OpiePlayer") );
81 qDebug("<<<<<audioWidget");
82
69 Config cfg("OpiePlayer"); 83 Config cfg("OpiePlayer");
70 cfg.setGroup("AudioWidget"); 84 cfg.setGroup("AudioWidget");
71// QGridLayout *layout = new QGridLayout( this ); 85 skin = cfg.readEntry("Skin","default");
72// layout->setSpacing( 2); 86 //skin = "scaleTest";
73// layout->setMargin( 2); 87// color of background, frame, degree of transparency
74 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 88
75 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 89 QString skinPath = "opieplayer2/skins/" + skin;
76 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); 90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
77 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); 91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
78 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); 92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
79// animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton"); 93
80 94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 95 imgButtonMask->fill( 0 );
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); 96
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); 97 for ( int i = 0; i < 11; i++ ) {
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
85// pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) ); 99 masks[i] = new QBitmap( filename );
86 100
87 songInfo = new Ticker( this ); 101 if ( !masks[i]->isNull() ) {
88 songInfo->setFocusPolicy( QWidget::NoFocus ); 102 QImage imgMask = masks[i]->convertToImage();
89 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 103 uchar **dest = imgButtonMask->jumpTable();
90// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 ); 104 for ( int y = 0; y < imgUp->height(); y++ ) {
91 105 uchar *line = dest[y];
92 slider = new QSlider( Qt::Horizontal, this ); 106 for ( int x = 0; x < imgUp->width(); x++ )
93 slider->setFixedWidth( 220 ); 107 if ( !qRed( imgMask.pixel( x, y ) ) )
94 slider->setFixedHeight( 20 ); 108 line[x] = i + 1;
95 slider->setMinValue( 0 ); 109 }
96 slider->setMaxValue( 1 ); 110 }
97 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 111
98 slider->setFocusPolicy( QWidget::NoFocus ); 112 }
99 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 113
100 // layout->addMultiCellWidget( slider, 4, 4, 0, 2 ); 114 for ( int i = 0; i < 11; i++ ) {
101 115 buttonPixUp[i] = NULL;
102 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 116 buttonPixDown[i] = NULL;
103 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 117 }
118
119 setBackgroundPixmap( *pixBg );
120
121 songInfo.setFocusPolicy( QWidget::NoFocus );
122
123 changeTextColor( &songInfo );
124 songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
125 songInfo.setFrameStyle( QFrame::NoFrame);
126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
127 //NoFrame
128// songInfo.setForegroundColor(Qt::white);
129
130 slider.setFixedHeight( 20 );
131 slider.setMinValue( 0 );
132 slider.setMaxValue( 1 );
133 slider.setFocusPolicy( QWidget::NoFocus );
134 slider.setBackgroundPixmap( *pixBg );
135
136 time.setFocusPolicy( QWidget::NoFocus );
137 time.setAlignment( Qt::AlignCenter );
138 time.setFrame(FALSE);
139 changeTextColor( &time );
140
141 resizeEvent( NULL );
142
143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
104 145
105 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
106 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
@@ -119,15 +160,72 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
119 160
120 161
121AudioWidget::~AudioWidget() { 162AudioWidget::~AudioWidget() {
122 mediaPlayerState->isStreaming = FALSE; 163
123 for ( int i = 0; i < 3; i++ ) 164 for ( int i = 0; i < 11; i++ ) {
124 delete pixmaps[i]; 165 delete buttonPixUp[i];
166 delete buttonPixDown[i];
167 }
168 delete pixBg;
169 delete imgUp;
170 delete imgDn;
171 delete imgButtonMask;
172 for ( int i = 0; i < 11; i++ ) {
173 delete masks[i];
174 }
125} 175}
126 176
127 177
128static bool audioSliderBeingMoved = FALSE; 178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img );
183 return new QPixmap( pix );
184}
185
186
187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
188{
189 QPixmap *pixmap = new QPixmap( pix );
190 pixmap->setMask( mask );
191 return pixmap;
192}
129 193
130 194
195
196void AudioWidget::resizeEvent( QResizeEvent * ) {
197 int h = height();
198 int w = width();
199
200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
201 slider.setFixedWidth( w - 110 );
202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
203 slider.setBackgroundOrigin( QWidget::ParentOrigin );
204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
205
206 xoff = ( w - imgUp->width() ) / 2;
207 yoff = (( h - imgUp->height() ) / 2) - 10;
208 QPoint p( xoff, yoff );
209
210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
212
213 for ( int i = 0; i < 11; i++ ) {
214 if ( !masks[i]->isNull() ) {
215 delete buttonPixUp[i];
216 delete buttonPixDown[i];
217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
219 }
220 }
221
222 delete pixUp;
223 delete pixDn;
224}
225
226
227static bool audioSliderBeingMoved = FALSE;
228
131void AudioWidget::sliderPressed() { 229void AudioWidget::sliderPressed() {
132 audioSliderBeingMoved = TRUE; 230 audioSliderBeingMoved = TRUE;
133} 231}
@@ -135,16 +233,17 @@ void AudioWidget::sliderPressed() {
135 233
136void AudioWidget::sliderReleased() { 234void AudioWidget::sliderReleased() {
137 audioSliderBeingMoved = FALSE; 235 audioSliderBeingMoved = FALSE;
138 if ( slider->width() == 0 ) 236 if ( slider.width() == 0 )
139 return; 237 return;
140 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
141 mediaPlayerState->setPosition( val ); 239 mediaPlayerState->setPosition( val );
142} 240}
143 241
144 242
145void AudioWidget::setPosition( long i ) { 243void AudioWidget::setPosition( long i ) {
146// qDebug("set position %d",i); 244// qDebug("set position %d",i);
147 updateSlider( i, mediaPlayerState->length() ); 245 long length = mediaPlayerState->length();
246 updateSlider( i, length );
148} 247}
149 248
150 249
@@ -154,14 +253,15 @@ void AudioWidget::setLength( long max ) {
154 253
155 254
156void AudioWidget::setView( char view ) { 255void AudioWidget::setView( char view ) {
256
157 if (mediaPlayerState->isStreaming) { 257 if (mediaPlayerState->isStreaming) {
158 if( !slider->isHidden()) slider->hide(); 258 if( !slider.isHidden()) slider.hide();
159 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
160 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
161 } else { 261 } else {
162// this stops the slider from being moved, thus 262// this stops the slider from being moved, thus
163 // does not stop stream when it reaches the end 263 // does not stop stream when it reaches the end
164 slider->show(); 264 slider.show();
165 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 265 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
166 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 266 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
167 } 267 }
@@ -177,18 +277,27 @@ void AudioWidget::setView( char view ) {
177} 277}
178 278
179 279
280static QString timeAsString( long length ) {
281 length /= 44100;
282 int minutes = length / 60;
283 int seconds = length % 60;
284 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
285}
286
180void AudioWidget::updateSlider( long i, long max ) { 287void AudioWidget::updateSlider( long i, long max ) {
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289
181 if ( max == 0 ) 290 if ( max == 0 )
182 return; 291 return;
183 // Will flicker too much if we don't do this 292 // Will flicker too much if we don't do this
184 // Scale to something reasonable 293 // Scale to something reasonable
185 int width = slider->width(); 294 int width = slider.width();
186 int val = int((double)i * width / max); 295 int val = int((double)i * width / max);
187 if ( !audioSliderBeingMoved ) { 296 if ( !audioSliderBeingMoved ) {
188 if ( slider->value() != val ) 297 if ( slider.value() != val )
189 slider->setValue( val ); 298 slider.setValue( val );
190 if ( slider->maxValue() != width ) 299 if ( slider.maxValue() != width )
191 slider->setMaxValue( width ); 300 slider.setMaxValue( width );
192 } 301 }
193} 302}
194 303
@@ -207,63 +316,64 @@ void AudioWidget::toggleButton( int i ) {
207 316
208 317
209void AudioWidget::paintButton( QPainter *p, int i ) { 318void AudioWidget::paintButton( QPainter *p, int i ) {
210 int x = audioButtons[i].xPos; 319 if ( audioButtons[i].isDown )
211 int y = audioButtons[i].yPos; 320 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
212 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 321 else
213 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 322 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
214 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
215 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
216} 323}
217 324
218 325
219void AudioWidget::timerEvent( QTimerEvent * ) { 326void AudioWidget::timerEvent( QTimerEvent * ) {
327/*
328 int x = audioButtons[AudioPlay].xPos;
329 int y = audioButtons[AudioPlay].yPos;
330 QPainter p( this );
331 // Optimize to only draw the little bit of the changing images which is different
332 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
333 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
334*/
335/*
220 static int frame = 0; 336 static int frame = 0;
221 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 337 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
222 frame = frame >= 7 ? 0 : frame + 1; 338 frame = frame >= 7 ? 0 : frame + 1;
223// int x = audioButtons[AudioPlay].xPos;
224// int y = audioButtons[AudioPlay].yPos;
225// QPainter p( this );
226// // Optimize to only draw the little bit of the changing images which is different
227// p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
228// p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
229 } 339 }
340 */
230} 341}
231 342
232 343
233void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 344void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
234 for ( int i = 0; i < numButtons; i++ ) { 345 for ( int i = 0; i < numButtons; i++ ) {
235 int size = audioButtons[i].isBig;
236 int x = audioButtons[i].xPos;
237 int y = audioButtons[i].yPos;
238 if ( event->state() == QMouseEvent::LeftButton ) { 346 if ( event->state() == QMouseEvent::LeftButton ) {
239 // The test to see if the mouse click is inside the circular button or not 347
240 // (compared with the radius squared to avoid a square-root of our distance) 348 // The test to see if the mouse click is inside the button or not
241 int radius = 32 + 13 * size; 349 int x = event->pos().x() - xoff;
242 QPoint center = QPoint( x + radius, y + radius ); 350 int y = event->pos().y() - yoff;
243 QPoint dXY = center - event->pos(); 351
244 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 352 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
245 bool isOnButton = dist <= (radius * radius); 353 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
246// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 354
247// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 355 if ( isOnButton && i == AudioVolumeUp )
356 qDebug("on up");
357
248 if ( isOnButton && !audioButtons[i].isHeld ) { 358 if ( isOnButton && !audioButtons[i].isHeld ) {
249 audioButtons[i].isHeld = TRUE; 359 audioButtons[i].isHeld = TRUE;
250 toggleButton(i); 360 toggleButton(i);
251 qDebug("button toggled1 %d",i);
252 switch (i) { 361 switch (i) {
253 case AudioVolumeUp: emit moreClicked(); return; 362 case AudioVolumeUp:
363 qDebug("more clicked");
364 emit moreClicked();
365 return;
254 case AudioVolumeDown: emit lessClicked(); return; 366 case AudioVolumeDown: emit lessClicked(); return;
255 } 367 }
256 } else if ( !isOnButton && audioButtons[i].isHeld ) { 368 } else if ( !isOnButton && audioButtons[i].isHeld ) {
257 audioButtons[i].isHeld = FALSE; 369 audioButtons[i].isHeld = FALSE;
258 toggleButton(i); 370 toggleButton(i);
259 qDebug("button toggled2 %d",i);
260 } 371 }
261 } else { 372 } else {
262 if ( audioButtons[i].isHeld ) { 373 if ( audioButtons[i].isHeld ) {
263 audioButtons[i].isHeld = FALSE; 374 audioButtons[i].isHeld = FALSE;
264 if ( !audioButtons[i].isToggle ) 375 if ( !audioButtons[i].isToggle )
265 setToggleButton( i, FALSE ); 376 setToggleButton( i, FALSE );
266 qDebug("button toggled3 %d",i);
267 switch (i) { 377 switch (i) {
268 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
269 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
@@ -281,6 +391,7 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
281} 391}
282 392
283 393
394
284void AudioWidget::mousePressEvent( QMouseEvent *event ) { 395void AudioWidget::mousePressEvent( QMouseEvent *event ) {
285 mouseMoveEvent( event ); 396 mouseMoveEvent( event );
286} 397}
@@ -302,11 +413,23 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
302} 413}
303 414
304 415
305void AudioWidget::paintEvent( QPaintEvent * ) { 416void AudioWidget::paintEvent( QPaintEvent * pe) {
417 if ( !pe->erased() ) {
418 // Combine with background and double buffer
419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i );
425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else {
306 QPainter p( this ); 428 QPainter p( this );
307 for ( int i = 0; i < numButtons; i++ ) 429 for ( int i = 0; i < numButtons; i++ )
308 paintButton( &p, i ); 430 paintButton( &p, i );
309} 431}
432}
310 433
311void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
312{ 435{
@@ -327,6 +450,7 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
327 case Key_F13: //mail 450 case Key_F13: //mail
328 break; 451 break;
329 case Key_Space: { 452 case Key_Space: {
453
330 if(mediaPlayerState->playing()) { 454 if(mediaPlayerState->playing()) {
331// toggleButton(1); 455// toggleButton(1);
332 mediaPlayerState->setPlaying(FALSE); 456 mediaPlayerState->setPlaying(FALSE);
@@ -338,24 +462,24 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
338 } 462 }
339 } 463 }
340 break; 464 break;
341 case Key_Down: 465 case Key_Down: //volume
342 toggleButton(6); 466 toggleButton(6);
343 emit lessClicked(); 467 emit lessClicked();
344 emit lessReleased(); 468 emit lessReleased();
345 toggleButton(6); 469 toggleButton(6);
346 break; 470 break;
347 case Key_Up: 471 case Key_Up: //volume
348 toggleButton(5); 472 toggleButton(5);
349 emit moreClicked(); 473 emit moreClicked();
350 emit moreReleased(); 474 emit moreReleased();
351 toggleButton(5); 475 toggleButton(5);
352 break; 476 break;
353 case Key_Right: 477 case Key_Right: //next in playlist
354// toggleButton(3); 478// toggleButton(3);
355 mediaPlayerState->setNext(); 479 mediaPlayerState->setNext();
356// toggleButton(3); 480// toggleButton(3);
357 break; 481 break;
358 case Key_Left: 482 case Key_Left: // previous in playlist
359// toggleButton(4); 483// toggleButton(4);
360 mediaPlayerState->setPrev(); 484 mediaPlayerState->setPrev();
361// toggleButton(4); 485// toggleButton(4);
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index b3d39bf..c686741 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -25,14 +25,16 @@
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 <qbitmap.h>
28#include <qstring.h> 29#include <qstring.h>
29#include <qslider.h> 30#include <qslider.h>
31#include <qlineedit.h>
30#include <qframe.h> 32#include <qframe.h>
31 33
34#include <opie/oticker.h>
32 35
33class QPixmap; 36class QPixmap;
34 37
35
36enum AudioButtons { 38enum AudioButtons {
37 AudioPlay, 39 AudioPlay,
38 AudioStop, 40 AudioStop,
@@ -46,62 +48,14 @@ enum AudioButtons {
46}; 48};
47 49
48 50
49#define USE_DBLBUF 51//#define USE_DBLBUF
50
51
52class Ticker : public QFrame {
53 Q_OBJECT
54public:
55 Ticker( QWidget* parent=0 ) : QFrame( parent ) {
56 setFrameStyle( WinPanel | Sunken );
57 setText( "No Song" );
58 }
59 ~Ticker() { }
60 void setText( const QString& text ) {
61 pos = 0; // reset it everytime the text is changed
62 scrollText = text;
63 pixelLen = fontMetrics().width( scrollText );
64 killTimers();
65 if ( pixelLen > width() )
66 startTimer( 50 );
67 update();
68 }
69protected:
70 void timerEvent( QTimerEvent * ) {
71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
72#ifndef USE_DBLBUF
73 scroll( -1, 0, contentsRect() );
74#else
75 repaint( FALSE );
76#endif
77 }
78 void drawContents( QPainter *p ) {
79#ifndef USE_DBLBUF
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 );
82#else
83 // Double buffering code.
84 // Looks like qvfb makes it look like it flickers but I don't think it really is
85 QPixmap pm( width(), height() );
86 pm.fill( colorGroup().base() );
87 QPainter pmp( &pm );
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 );
90 p->drawPixmap( 0, 0, pm );
91#endif
92 }
93private:
94 QString scrollText;
95 int pos, pixelLen;
96};
97
98 52
99class AudioWidget : public QWidget { 53class AudioWidget : public QWidget {
100 Q_OBJECT 54 Q_OBJECT
101public: 55public:
102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 56 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
103 ~AudioWidget(); 57 ~AudioWidget();
104 void setTickerText( const QString &text ) { songInfo->setText( text ); } 58 void setTickerText( const QString &text ) { songInfo.setText( text ); }
105 bool isStreaming; 59 bool isStreaming;
106public slots: 60public slots:
107 void updateSlider( long, long ); 61 void updateSlider( long, long );
@@ -126,6 +80,7 @@ protected:
126 void doUnblank(); 80 void doUnblank();
127 void paintEvent( QPaintEvent *pe ); 81 void paintEvent( QPaintEvent *pe );
128 void showEvent( QShowEvent *se ); 82 void showEvent( QShowEvent *se );
83 void resizeEvent( QResizeEvent *re );
129 void mouseMoveEvent( QMouseEvent *event ); 84 void mouseMoveEvent( QMouseEvent *event );
130 void mousePressEvent( QMouseEvent *event ); 85 void mousePressEvent( QMouseEvent *event );
131 void mouseReleaseEvent( QMouseEvent *event ); 86 void mouseReleaseEvent( QMouseEvent *event );
@@ -136,9 +91,21 @@ private:
136 void toggleButton( int ); 91 void toggleButton( int );
137 void setToggleButton( int, bool ); 92 void setToggleButton( int, bool );
138 void paintButton( QPainter *p, int i ); 93 void paintButton( QPainter *p, int i );
94 QString skin;
95 QPixmap *pixBg;
96 QImage *imgUp;
97 QImage *imgDn;
98 QImage *imgButtonMask;
99 QBitmap *masks[11];
100 QPixmap *buttonPixUp[11];
101 QPixmap *buttonPixDown[11];
102
139 QPixmap *pixmaps[4]; 103 QPixmap *pixmaps[4];
140 Ticker *songInfo; 104 OTicker songInfo;
141 QSlider *slider; 105 QSlider slider;
106 QLineEdit time;
107 int xoff, yoff;
108
142}; 109};
143 110
144 111
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp
index da8e276..62240b2 100644
--- a/core/multimedia/opieplayer/inputDialog.cpp
+++ b/core/multimedia/opieplayer/inputDialog.cpp
@@ -1,11 +1,3 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "inputDialog.h" 1#include "inputDialog.h"
10 2
11#include <qpe/resource.h> 3#include <qpe/resource.h>
@@ -19,10 +11,10 @@
19#include <qwhatsthis.h> 11#include <qwhatsthis.h>
20 12
21InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
22 : QDialog( parent, name, modal, fl ) 14 : QDialog( parent, name, modal, fl ) {
23{ 15 if ( !name ) {
24 if ( !name )
25 setName( "InputDialog" ); 16 setName( "InputDialog" );
17 }
26 resize( 234, 115); 18 resize( 234, 115);
27 setMaximumSize( QSize( 240, 40)); 19 setMaximumSize( QSize( 240, 40));
28 setCaption( tr(name ) ); 20 setCaption( tr(name ) );
@@ -33,15 +25,18 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
33 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 25 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
34 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 26 LineEdit1 = new QLineEdit( this, "LineEdit1" );
35 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28 LineEdit1->setFocus();
29}
30/*
31 * return the current text(input)
32 */
33QString InputDialog::text() const {
34 return LineEdit1->text();
36} 35}
37
38/* 36/*
39 * Destroys the object and frees any allocated resources 37 * Destroys the object and frees any allocated resources
40 */ 38 */
41InputDialog::~InputDialog() 39InputDialog::~InputDialog() {
42{
43 inputText= LineEdit1->text();
44
45} 40}
46 41
47void InputDialog::browse() { 42void InputDialog::browse() {
diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h
index 3e3e36f..0f36ea4 100644
--- a/core/multimedia/opieplayer/inputDialog.h
+++ b/core/multimedia/opieplayer/inputDialog.h
@@ -1,11 +1,4 @@
1/**************************************************************************** 1
2** Form interface generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INPUTDIALOG_H 2#ifndef INPUTDIALOG_H
10#define INPUTDIALOG_H 3#define INPUTDIALOG_H
11 4
@@ -14,15 +7,17 @@
14 7
15class QLineEdit; 8class QLineEdit;
16 9
17class InputDialog : public QDialog 10class InputDialog : public QDialog {
18{
19 Q_OBJECT 11 Q_OBJECT
20 12
21public: 13public:
22 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 14 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
23 ~InputDialog(); 15 ~InputDialog();
24 QString inputText; 16 QString text()const;
17
18private:
25 QLineEdit* LineEdit1; 19 QLineEdit* LineEdit1;
20
26protected slots: 21protected slots:
27 void browse(); 22 void browse();
28}; 23};
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 64fdc01..b0963cf 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -80,6 +80,7 @@ void MediaPlayer::play() {
80 80
81 81
82void MediaPlayer::setPlaying( bool play ) { 82void MediaPlayer::setPlaying( bool play ) {
83 qDebug("MediaPlayer setPlaying");
83 if ( !play ) { 84 if ( !play ) {
84 mediaPlayerState->setPaused( FALSE ); 85 mediaPlayerState->setPaused( FALSE );
85 loopControl->stop( FALSE ); 86 loopControl->stop( FALSE );
@@ -90,8 +91,9 @@ void MediaPlayer::setPlaying( bool play ) {
90 mediaPlayerState->setPaused( FALSE ); 91 mediaPlayerState->setPaused( FALSE );
91 return; 92 return;
92 } 93 }
93 94 qDebug("about to ctrash");
94 const DocLnk *playListCurrent = playList->current(); 95 const DocLnk *playListCurrent = playList->current();
96
95 if ( playListCurrent != NULL ) { 97 if ( playListCurrent != NULL ) {
96 loopControl->stop( TRUE ); 98 loopControl->stop( TRUE );
97 currentFile = playListCurrent; 99 currentFile = playListCurrent;
@@ -103,19 +105,22 @@ void MediaPlayer::setPlaying( bool play ) {
103 } 105 }
104 106
105 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
106 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 108 QMessageBox::critical( 0, tr( "File not found"),
109 tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
107 mediaPlayerState->setPlaying( FALSE ); 110 mediaPlayerState->setPlaying( FALSE );
108 return; 111 return;
109 } 112 }
110 113
111 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 114 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
112 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 115 QMessageBox::critical( 0, tr( "No decoder found"),
116 tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
113 mediaPlayerState->setPlaying( FALSE ); 117 mediaPlayerState->setPlaying( FALSE );
114 return; 118 return;
115 } 119 }
116 120
117 if ( !loopControl->init( currentFile->file() ) ) { 121 if ( !loopControl->init( currentFile->file() ) ) {
118 QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); 122 QMessageBox::critical( 0, tr( "Error opening file"),
123 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
119 mediaPlayerState->setPlaying( FALSE ); 124 mediaPlayerState->setPlaying( FALSE );
120 return; 125 return;
121 } 126 }
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 06c5556..26185c5 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -57,7 +57,9 @@ public slots:
57 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } 57 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); }
58 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } 58 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); }
59 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } 59 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); }
60
60 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } 61 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); }
62
61 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } 63 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); }
62 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } 64 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); }
63 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } 65 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); }
diff --git a/core/multimedia/opieplayer/opie-mediaplayer.control b/core/multimedia/opieplayer/opie-mediaplayer.control
index 3bfb911..da193c0 100644
--- a/core/multimedia/opieplayer/opie-mediaplayer.control
+++ b/core/multimedia/opieplayer/opie-mediaplayer.control
@@ -1,4 +1,4 @@
1Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop 1Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop pics/opieplayer2/skins/default
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: L.J.Potter <ljp@llornkcor.com> 4Maintainer: L.J.Potter <ljp@llornkcor.com>
diff --git a/core/multimedia/opieplayer/opieplayer.pro b/core/multimedia/opieplayer/opieplayer.pro
index e111717..6f22280 100644
--- a/core/multimedia/opieplayer/opieplayer.pro
+++ b/core/multimedia/opieplayer/opieplayer.pro
@@ -2,11 +2,14 @@ TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3#release 3#release
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ 5HEADERS = loopcontrol.h mediaplayerplugininterface.h \
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h 6 playlistselection.h mediaplayerstate.h \
7 videowidget.h audiowidget.h playlistwidget.h \
8 mediaplayer.h audiodevice.h inputDialog.h om3u.h
7SOURCES = main.cpp \ 9SOURCES = main.cpp \
8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ 10 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \
9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp \
12 mediaplayer.cpp audiodevice.cpp inputDialog.cpp om3u.cpp
10TARGET = opieplayer 13TARGET = opieplayer
11INCLUDEPATH += $(OPIEDIR)/include 14INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 15DEPENDPATH += $(OPIEDIR)/include
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 5be0d6d..6580a88 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -83,6 +83,7 @@ extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
86// class myFileSelector { 87// class myFileSelector {
87 88
88// }; 89// };
@@ -179,8 +180,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
179 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
180 pmPlayList->insertSeparator(-1); 181 pmPlayList->insertSeparator(-1);
181 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
182 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
183 pmPlayList->insertSeparator(-1);
184 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
185 pmPlayList->insertSeparator(-1); 184 pmPlayList->insertSeparator(-1);
186 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
@@ -279,6 +278,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
279 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 278 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
280 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 279 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
281 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 280 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
281
282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
284 284
@@ -300,7 +300,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
300 300
301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
302 302
303 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 303// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
@@ -323,7 +323,6 @@ PlayListWidget::~PlayListWidget() {
323 Config cfg( "OpiePlayer" ); 323 Config cfg( "OpiePlayer" );
324 writeConfig( cfg ); 324 writeConfig( cfg );
325 325
326
327 if ( d->current ) 326 if ( d->current )
328 delete d->current; 327 delete d->current;
329 delete d; 328 delete d;
@@ -393,13 +392,13 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
393 392
394 393
395void PlayListWidget::addToSelection( const DocLnk& lnk ) { 394void PlayListWidget::addToSelection( const DocLnk& lnk ) {
396 d->setDocumentUsed = FALSE; 395 d->setDocumentUsed = false;
397 if ( mediaPlayerState->playlist() ) { 396 if ( mediaPlayerState->playlist() ) {
398 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 397 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
399 d->selectedFiles->addToSelection( lnk ); 398 d->selectedFiles->addToSelection( lnk );
400 } 399 }
401 else 400 else
402 mediaPlayerState->setPlaying( TRUE ); 401 mediaPlayerState->setPlaying( true);
403} 402}
404 403
405 404
@@ -496,6 +495,7 @@ const DocLnk *PlayListWidget::current() { // this is fugly
496// } 495// }
497// } else 496// } else
498 497
498 qDebug("current");
499 499
500 switch (tabWidget->currentPageIndex()) { 500 switch (tabWidget->currentPageIndex()) {
501 case 0: //playlist 501 case 0: //playlist
@@ -606,54 +606,20 @@ bool PlayListWidget::last() {
606 606
607 607
608void PlayListWidget::saveList() { 608void PlayListWidget::saveList() {
609 609 writem3u();
610 QString filename;
611 InputDialog *fileDlg;
612 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
613 fileDlg->exec();
614 if( fileDlg->result() == 1 ) {
615 if ( d->current )
616 delete d->current;
617 filename = fileDlg->LineEdit1->text();//+".playlist";
618// qDebug("saving playlist "+filename+".playlist");
619 Config cfg( filename +".playlist");
620 writeConfig( cfg );
621
622 DocLnk lnk;
623// lnk.setComment( "");
624 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
625 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
626 lnk.setIcon("opieplayer/playlist2");
627 lnk.setName( filename); //sets file name
628// qDebug(filename);
629 if(!lnk.writeLink())
630 qDebug("Writing doclink did not work");
631 }
632 Config config( "OpiePlayer" );
633 config.writeEntry("CurrentPlaylist",filename);
634 setCaption(tr("OpiePlayer: ")+filename);
635 d->selectedFiles->first();
636 if(fileDlg)
637 delete fileDlg;
638} 610}
639 611
640void PlayListWidget::loadList( const DocLnk & lnk) { 612void PlayListWidget::loadList( const DocLnk & lnk) {
641 QString name= lnk.name(); 613 QString name= lnk.name();
642// qDebug("currentList is "+name); 614// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
643 if( name.length()>1) { 615
616 if( name.length()>0) {
644 setCaption("OpiePlayer: "+name); 617 setCaption("OpiePlayer: "+name);
645// qDebug("load list "+ name+".playlist"); 618// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
646 clearList(); 619 clearList();
647 Config cfg( name+".playlist"); 620 readm3u(lnk.file());
648 readConfig(cfg);
649
650 tabWidget->setCurrentPage(0); 621 tabWidget->setCurrentPage(0);
651
652 Config config( "OpiePlayer" );
653 config.writeEntry("CurrentPlaylist", name);
654// d->selectedFiles->first();
655 } 622 }
656
657} 623}
658 624
659void PlayListWidget::setPlaylist( bool shown ) { 625void PlayListWidget::setPlaylist( bool shown ) {
@@ -675,7 +641,7 @@ void PlayListWidget::addSelected() {
675 Config cfg( "OpiePlayer" ); 641 Config cfg( "OpiePlayer" );
676 cfg.setGroup("PlayList"); 642 cfg.setGroup("PlayList");
677 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 643 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
678 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 644// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
679 645
680 switch (tabWidget->currentPageIndex()) { 646 switch (tabWidget->currentPageIndex()) {
681 case 0: //playlist 647 case 0: //playlist
@@ -738,7 +704,7 @@ void PlayListWidget::removeSelected() {
738 d->selectedFiles->removeSelected( ); 704 d->selectedFiles->removeSelected( );
739} 705}
740 706
741void PlayListWidget::playIt( QListViewItem *it) { 707void PlayListWidget::playIt( QListViewItem *) {
742// d->setDocumentUsed = FALSE; 708// d->setDocumentUsed = FALSE;
743// mediaPlayerState->curPosition =0; 709// mediaPlayerState->curPosition =0;
744 qDebug("playIt"); 710 qDebug("playIt");
@@ -777,7 +743,7 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
777 } 743 }
778} 744}
779 745
780void PlayListWidget::tabChanged(QWidget *widg) { 746void PlayListWidget::tabChanged(QWidget *) {
781 747
782 switch ( tabWidget->currentPageIndex()) { 748 switch ( tabWidget->currentPageIndex()) {
783 case 0: 749 case 0:
@@ -820,21 +786,25 @@ void PlayListWidget::tabChanged(QWidget *widg) {
820} 786}
821 787
822void PlayListWidget::btnPlay(bool b) { 788void PlayListWidget::btnPlay(bool b) {
823 789 qDebug("<<<<<<<<<<<<<<<BtnPlay");
824// mediaPlayerState->setPlaying(b); 790// mediaPlayerState->setPlaying(b);
825 switch ( tabWidget->currentPageIndex()) { 791 switch ( tabWidget->currentPageIndex()) {
826 case 0: 792 case 0:
827 { 793 {
794 qDebug("1");
828// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 795// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
829// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 796// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
830// QMessageBox::message("Note","You are trying to play\na malformed url."); 797// QMessageBox::message("Note","You are trying to play\na malformed url.");
831// } else { 798// } else {
832 mediaPlayerState->setPlaying(b); 799 mediaPlayerState->setPlaying(b);
800 insanityBool=FALSE;
801 qDebug("insanity");
833// } 802// }
834 } 803 }
835 break; 804 break;
836 case 1: 805 case 1:
837 { 806 {
807 qDebug("2");
838 addToSelection( audioView->currentItem() ); 808 addToSelection( audioView->currentItem() );
839 mediaPlayerState->setPlaying(b); 809 mediaPlayerState->setPlaying(b);
840 d->selectedFiles->removeSelected( ); 810 d->selectedFiles->removeSelected( );
@@ -845,6 +815,8 @@ void PlayListWidget::btnPlay(bool b) {
845 break; 815 break;
846 case 2: 816 case 2:
847 { 817 {
818 qDebug("3");
819
848 addToSelection( videoView->currentItem() ); 820 addToSelection( videoView->currentItem() );
849 mediaPlayerState->setPlaying(b); 821 mediaPlayerState->setPlaying(b);
850 qApp->processEvents(); 822 qApp->processEvents();
@@ -863,16 +835,16 @@ void PlayListWidget::deletePlaylist() {
863 (tr("You really want to delete\nthis playlist?")), 835 (tr("You really want to delete\nthis playlist?")),
864 (tr("Yes")), (tr("No")), 0 )){ 836 (tr("Yes")), (tr("No")), 0 )){
865 case 0: // Yes clicked, 837 case 0: // Yes clicked,
866// QFile().remove(playLists->selected()->file()); 838 QFile().remove(playLists->selectedDocument().file());
867// QFile().remove(playLists->selected()->linkFile()); 839 QFile().remove(playLists->selectedDocument().linkFile());
868// playLists->reread(); 840 playLists->reread();
869 break; 841 break;
870 case 1: // Cancel 842 case 1: // Cancel
871 break; 843 break;
872 }; 844 };
873} 845}
874 846
875void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 847void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
876{ 848{
877 switch (mouse) { 849 switch (mouse) {
878 case 1: 850 case 1:
@@ -894,11 +866,12 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
894 866
895void PlayListWidget::playSelected() 867void PlayListWidget::playSelected()
896{ 868{
897 btnPlay( TRUE); 869 qDebug("playSelected");
870 btnPlay( true);
898// d->selectedFiles->unSelect(); 871// d->selectedFiles->unSelect();
899} 872}
900 873
901void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 874void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
902{ 875{
903 switch (mouse) { 876 switch (mouse) {
904 case 1: 877 case 1:
@@ -922,7 +895,7 @@ void PlayListWidget::listDelete() {
922 cfg.setGroup("PlayList"); 895 cfg.setGroup("PlayList");
923 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 896 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
924 QString file; 897 QString file;
925 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 898// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
926 switch ( tabWidget->currentPageIndex()) { 899 switch ( tabWidget->currentPageIndex()) {
927 case 0: 900 case 0:
928 break; 901 break;
@@ -961,24 +934,24 @@ void PlayListWidget::listDelete() {
961} 934}
962 935
963void PlayListWidget::scanForAudio() { 936void PlayListWidget::scanForAudio() {
964 qDebug("scan for audio"); 937// qDebug("scan for audio");
965 files.detachChildren(); 938 files.detachChildren();
966 QListIterator<DocLnk> sdit( files.children() ); 939 QListIterator<DocLnk> sdit( files.children() );
967 for ( ; sdit.current(); ++sdit ) { 940 for ( ; sdit.current(); ++sdit ) {
968 delete sdit.current(); 941 delete sdit.current();
969 } 942 }
970 Global::findDocuments(&files, "audio/*"); 943 Global::findDocuments( &files, audioMimes);
971 audioScan = TRUE; 944 audioScan = true;
972} 945}
973void PlayListWidget::scanForVideo() { 946void PlayListWidget::scanForVideo() {
974 qDebug("scan for video"); 947// qDebug("scan for video");
975 vFiles.detachChildren(); 948 vFiles.detachChildren();
976 QListIterator<DocLnk> sdit( vFiles.children() ); 949 QListIterator<DocLnk> sdit( vFiles.children() );
977 for ( ; sdit.current(); ++sdit ) { 950 for ( ; sdit.current(); ++sdit ) {
978 delete sdit.current(); 951 delete sdit.current();
979 } 952 }
980 Global::findDocuments(&vFiles, "video/*"); 953 Global::findDocuments(&vFiles, "video/*");
981 videoScan = TRUE; 954 videoScan = true;
982} 955}
983 956
984void PlayListWidget::populateAudioView() { 957void PlayListWidget::populateAudioView() {
@@ -1006,7 +979,7 @@ void PlayListWidget::populateAudioView() {
1006 size=0; 979 size=0;
1007 else 980 else
1008 size = QFile( dit.current()->file() ).size(); 981 size = QFile( dit.current()->file() ).size();
1009 qDebug(dit.current()->name()); 982// qDebug(dit.current()->name());
1010 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 983 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
1011 QString::number(size ), storage); 984 QString::number(size ), storage);
1012 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 985 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
@@ -1043,43 +1016,234 @@ void PlayListWidget::populateVideoView() {
1043} 1016}
1044 1017
1045void PlayListWidget::openFile() { 1018void PlayListWidget::openFile() {
1019 qDebug("<<<<<<<<<OPEN File");
1046 QString filename, name; 1020 QString filename, name;
1047 InputDialog *fileDlg; 1021 InputDialog *fileDlg;
1048 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1022 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1049 fileDlg->exec(); 1023 fileDlg->exec();
1050 if( fileDlg->result() == 1 ) { 1024 if( fileDlg->result() == 1 ) {
1051 filename = fileDlg->LineEdit1->text(); 1025 filename = fileDlg->text();
1052// http://205.188.234.129:8030
1053// http://66.28.68.70:8000
1054// filename.replace(QRegExp("%20")," ");
1055 qDebug("Selected filename is "+filename); 1026 qDebug("Selected filename is "+filename);
1056 if(filename.right(3) == "m3u") 1027// Om3u *m3uList;
1028 DocLnk lnk;
1029 Config cfg( "OpiePlayer" );
1030 cfg.setGroup("PlayList");
1031
1032 if(filename.left(4) == "http") {
1033 QString m3uFile, m3uFilePath;
1034 if(filename.find(":",8,TRUE) != -1) { //found a port
1035 m3uFile = filename.left( filename.find( ":",8,TRUE));
1036 m3uFile = m3uFile.right( 7);
1037 } else if(filename.left(4) == "http"){
1038 m3uFile=filename;
1039 m3uFile = m3uFile.right( m3uFile.length() - 7);
1040 } else{
1041 m3uFile=filename;
1042 }
1043
1044// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
1045 lnk.setName( filename ); //sets name
1046 lnk.setFile( filename ); //sets file name
1047 lnk.setIcon("opieplayer2/musicfile");
1048 d->selectedFiles->addToSelection( lnk );
1049 writeCurrentM3u();
1050 }
1051 else if( filename.right( 3) == "m3u" ) {
1057 readm3u( filename); 1052 readm3u( filename);
1058 else if(filename.right(3) == "pls") 1053
1054 } else if( filename.right(3) == "pls" ) {
1059 readPls( filename); 1055 readPls( filename);
1060 else { 1056 } else {
1057 d->selectedFiles->addToSelection( DocLnk(filename) );
1058 writeCurrentM3u();
1059 }
1060 }
1061
1062 if( fileDlg ) {
1063 delete fileDlg;
1064 }
1065}
1066
1067
1068/*
1069reads m3u and shows files/urls to playlist widget */
1070void PlayListWidget::readm3u( const QString &filename ) {
1071 qDebug( "read m3u filename " + filename );
1072
1073 Om3u *m3uList;
1074 QString s, name;
1075 m3uList = new Om3u( filename, IO_ReadOnly );
1076 m3uList->readM3u();
1061 DocLnk lnk; 1077 DocLnk lnk;
1078 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1079 s = *it;
1080// qDebug("reading "+ s);
1081 if(s.left(4)=="http") {
1082 lnk.setName( s ); //sets file name
1083 lnk.setIcon("opieplayer2/musicfile");
1084 if(s.right(4) != '.' || s.right(5) != '.')
1085 lnk.setFile( s+"/"); //if url with no extension
1086 else
1087 lnk.setFile( s ); //sets file name
1088
1089 } else {
1090 // if( QFileInfo( s ).exists() ) {
1091 lnk.setName( QFileInfo(s).baseName());
1092 // if(s.right(4) == '.') {//if regular file
1093 if(s.left(1) != "/") {
1094 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1095 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1096 lnk.setIcon("SoundPlayer");
1097 } else {
1098 // qDebug("set link2 "+s);
1099 lnk.setFile( s);
1100 lnk.setIcon("SoundPlayer");
1101 }
1102 }
1103 d->selectedFiles->addToSelection( lnk );
1104 }
1105 Config config( "OpiePlayer" );
1106 config.setGroup( "PlayList" );
1107
1108 config.writeEntry("CurrentPlaylist",filename);
1109 config.write();
1110 currentPlayList=filename;
1111
1112// m3uList->write();
1113 m3uList->close();
1114 if(m3uList) delete m3uList;
1062 1115
1063 lnk.setName(filename); //sets file name 1116 d->selectedFiles->setSelectedItem( s);
1064 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1117 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
1065 filename += "/"; 1118
1066 lnk.setFile(filename); //sets File property 1119}
1067 1120
1121/*
1122reads pls and adds files/urls to playlist */
1123void PlayListWidget::readPls( const QString &filename ) {
1124
1125 qDebug( "pls filename is " + filename );
1126 Om3u *m3uList;
1127 QString s, name;
1128 m3uList = new Om3u( filename, IO_ReadOnly );
1129 m3uList->readPls();
1130
1131 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1132 s = *it;
1133 // s.replace( QRegExp( "%20" )," " );
1134 DocLnk lnk( s );
1135 QFileInfo f( s );
1136 QString name = f.baseName();
1137
1138 if( name.left( 4 ) == "http" ) {
1139 name = s.right( s.length() - 7);
1140 } else {
1141 name = s;
1142 }
1143
1144 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1145
1146 lnk.setName( name );
1147 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1148 lnk.setFile( s );
1149 } else { //if its a url
1150 if( name.right( 1 ).find( '/' ) == -1) {
1151 s += "/";
1152 }
1153 lnk.setFile( s );
1154 }
1068 lnk.setType("audio/x-mpegurl"); 1155 lnk.setType("audio/x-mpegurl");
1069 lnk.setExec("opieplayer");
1070 lnk.setIcon("opieplayer/MPEGPlayer");
1071 1156
1072 if(!lnk.writeLink()) 1157 lnk.writeLink();
1073 qDebug("Writing doclink did not work");
1074 d->selectedFiles->addToSelection( lnk); 1158 d->selectedFiles->addToSelection( lnk);
1075// if(fileDlg2)
1076// delete fileDlg2;
1077 } 1159 }
1160
1161 m3uList->close();
1162 if(m3uList) delete m3uList;
1078 } 1163 }
1079 if(fileDlg) 1164
1080 delete fileDlg; 1165/*
1166 writes current playlist to current m3u file */
1167void PlayListWidget::writeCurrentM3u() {
1168 qDebug("writing to current m3u");
1169 Config cfg( "OpiePlayer" );
1170 cfg.setGroup("PlayList");
1171 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1172
1173 if( d->selectedFiles->first()) {
1174 Om3u *m3uList;
1175 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1176
1177 do {
1178 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1179 m3uList->add( d->selectedFiles->current()->file() );
1180 }
1181 while ( d->selectedFiles->next() );
1182 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1183 m3uList->write();
1184 m3uList->close();
1185
1186 if(m3uList) delete m3uList;
1187 }
1188}
1189
1190 /*
1191 writes current playlist to m3u file */
1192void PlayListWidget::writem3u() {
1193 InputDialog *fileDlg;
1194 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1195 fileDlg->exec();
1196 QString name, filename, list;
1197 Om3u *m3uList;
1198
1199 if( fileDlg->result() == 1 ) {
1200 name = fileDlg->text();
1201// qDebug( filename );
1202
1203 if( name.left( 1) != "/" ) {
1204 filename = QPEApplication::documentDir() + "/" + name;
1205 }
1206
1207 if( name.right( 3 ) != "m3u" ) {
1208 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1209 }
1210
1211 if( d->selectedFiles->first()) {
1212 m3uList = new Om3u(filename, IO_ReadWrite);
1213
1214 do {
1215 m3uList->add( d->selectedFiles->current()->file());
1216 }
1217 while ( d->selectedFiles->next() );
1218 // qDebug( list );
1219 m3uList->write();
1220 m3uList->close();
1221 if(m3uList) delete m3uList;
1222
1223 if(fileDlg) delete fileDlg;
1224
1225 DocLnk lnk;
1226 lnk.setFile( filename);
1227 lnk.setIcon("opieplayer2/playlist2");
1228 lnk.setName( name); //sets file name
1229
1230 // qDebug(filename);
1231 Config config( "OpiePlayer" );
1232 config.setGroup( "PlayList" );
1233
1234 config.writeEntry("CurrentPlaylist",filename);
1235 currentPlayList=filename;
1236
1237 if(!lnk.writeLink()) {
1238 qDebug("Writing doclink did not work");
1081} 1239}
1082 1240
1241 setCaption(tr("OpiePlayer: ") + name);
1242 }
1243 }
1244}
1245
1246
1083void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1247void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1084{ 1248{
1085 switch ( e->key() ) { 1249 switch ( e->key() ) {
@@ -1141,7 +1305,7 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1141 } 1305 }
1142} 1306}
1143 1307
1144void PlayListWidget::keyPressEvent( QKeyEvent *e) 1308void PlayListWidget::keyPressEvent( QKeyEvent *)
1145{ 1309{
1146// qDebug("Key press"); 1310// qDebug("Key press");
1147// switch ( e->key() ) { 1311// switch ( e->key() ) {
@@ -1186,147 +1350,3 @@ void PlayListWidget::doUnblank() {
1186 h <<-3;// v[1]; // -3 Force on 1350 h <<-3;// v[1]; // -3 Force on
1187} 1351}
1188 1352
1189void PlayListWidget::readm3u(const QString &filename) {
1190
1191 qDebug("m3u filename is "+filename);
1192 QFile f(filename);
1193
1194 if(f.open(IO_ReadOnly)) {
1195 QTextStream t(&f);
1196 QString s;//, first, second;
1197 int i=0;
1198 while ( !t.atEnd()) {
1199// Lview->insertLine(t.readLine(),-1);
1200 s=t.readLine();
1201
1202 if(s.find("#",0,TRUE) == -1) {
1203 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1204 if(s.left(2) == "E:" || s.left(2) == "P:") {
1205 s=s.right(s.length()-2);
1206 DocLnk lnk( s );
1207 QFileInfo f(s);
1208 QString name = f.baseName();
1209 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1210 lnk.setName( name);
1211 s=s.replace( QRegExp("\\"),"/");
1212 lnk.setFile( s);
1213 lnk.writeLink();
1214// lnk.setIcon(opieplayer/MPEGPlayer);
1215 qDebug("add "+name);
1216 d->selectedFiles->addToSelection( lnk);
1217 } else { // is url
1218
1219 s.replace(QRegExp("%20")," ");
1220 DocLnk lnk( s);
1221 QString name;
1222 if(name.left(4)=="http")
1223 name = s.right( s.length() - 7);
1224 else
1225 name=s;
1226// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1227 lnk.setName(name);
1228 if(s.at(s.length()-4) == '.')
1229 lnk.setFile( s);
1230 else
1231 lnk.setFile( s+"/");
1232// lnk.setFile( filename);
1233// lnk.setComment( s+"/");
1234 lnk.setType("audio/x-mpegurl");
1235 lnk.writeLink();
1236// lnk.setIcon( "opieplayer/MPEGPlayer");
1237// qDebug("add "+s);
1238 d->selectedFiles->addToSelection( lnk);
1239 }
1240 i++;
1241 }
1242 }
1243 }
1244 }
1245 f.close();
1246}
1247
1248void PlayListWidget::writem3u() {
1249
1250 InputDialog *fileDlg;
1251 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1252 fileDlg->exec();
1253 QString filename,list;
1254 if( fileDlg->result() == 1 ) {
1255 filename = fileDlg->LineEdit1->text();
1256 qDebug(filename);
1257 int noOfFiles = 0;
1258 d->selectedFiles->first();
1259 do {
1260// we dont check for existance because of url's
1261// qDebug(d->selectedFiles->current()->file());
1262 list += d->selectedFiles->current()->file()+"\n";
1263 noOfFiles++;
1264 }
1265 while ( d->selectedFiles->next() );
1266 qDebug(list);
1267 if(filename.left(1) != "/")
1268 filename=QPEApplication::documentDir()+"/"+filename;
1269 if(filename.right(3) != "m3u")
1270 filename=filename+".m3u";
1271
1272 QFile f(filename);
1273 f.open(IO_WriteOnly);
1274 f.writeBlock(list, list.length());
1275 f.close();
1276 }
1277 if(fileDlg) delete fileDlg;
1278}
1279
1280void PlayListWidget::readPls(const QString &filename) {
1281
1282 qDebug("pls filename is "+filename);
1283 QFile f(filename);
1284
1285 if(f.open(IO_ReadOnly)) {
1286 QTextStream t(&f);
1287 QString s;//, first, second;
1288 int i=0;
1289 while ( !t.atEnd()) {
1290 s=t.readLine();
1291 if(s.left(4) == "File") {
1292 s=s.right(s.length() - 6);
1293 s.replace(QRegExp("%20")," ");
1294 qDebug("adding "+s+" to playlist");
1295// numberofentries=2
1296// File1=http
1297// Title
1298// Length
1299// Version
1300// File2=http
1301
1302 s=s.replace( QRegExp("\\"),"/");
1303 DocLnk lnk( s );
1304 QFileInfo f(s);
1305 QString name = f.baseName();
1306 if(name.left(4)=="http")
1307 name = s.right( s.length() - 7);
1308 else
1309 name=s;
1310 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1311// QFileInfo f(s);
1312// QString name = f.baseName();
1313// name = name.left(name.length()-4);
1314// name = name.right(name.findRev("/",0,TRUE));
1315 lnk.setName( name);
1316 if(s.at(s.length()-4) == '.') // if this is probably a file
1317 lnk.setFile( s);
1318 else { //if its a url
1319 if( name.right(1).find('/') == -1)
1320 s+="/";
1321 lnk.setFile( s);
1322 }
1323 lnk.setType("audio/x-mpegurl");
1324
1325 qDebug("DocLnk add "+name);
1326 d->selectedFiles->addToSelection( lnk);
1327 }
1328 }
1329 i++;
1330 }
1331}
1332
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 7718a8c..1be5a15 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -26,6 +26,7 @@
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include "om3u.h"
29/* #include <qtimer.h> */ 30/* #include <qtimer.h> */
30 31
31 32
@@ -50,7 +51,7 @@ public:
50 QLabel *libString; 51 QLabel *libString;
51 bool fromSetDocument; 52 bool fromSetDocument;
52 bool insanityBool; 53 bool insanityBool;
53 QString setDocFileRef; 54 QString setDocFileRef, currentPlayList;
54 // retrieve the current playlist entry (media file link) 55 // retrieve the current playlist entry (media file link)
55 const DocLnk *current(); 56 const DocLnk *current();
56 void useSelectedDocument(); 57 void useSelectedDocument();
@@ -85,7 +86,9 @@ private:
85 void populateAudioView(); 86 void populateAudioView();
86 void populateVideoView(); 87 void populateVideoView();
87private slots: 88private slots:
89
88 void writem3u(); 90 void writem3u();
91 void writeCurrentM3u();
89 void scanForAudio(); 92 void scanForAudio();
90 void scanForVideo(); 93 void scanForVideo();
91 void openFile(); 94 void openFile();