summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp4
-rw-r--r--core/multimedia/opieplayer/audiowidget.h1
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp30
-rw-r--r--core/multimedia/opieplayer/mpegplayer.pro2
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp8
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp173
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h1
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp19
8 files changed, 158 insertions, 80 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 3901446..cda3f77 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -199,62 +199,64 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
199 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 199 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
200 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 200 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
201 } 201 }
202} 202}
203 203
204 204
205void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 205void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
206 for ( int i = 0; i < numButtons; i++ ) { 206 for ( int i = 0; i < numButtons; i++ ) {
207 int size = audioButtons[i].isBig; 207 int size = audioButtons[i].isBig;
208 int x = audioButtons[i].xPos; 208 int x = audioButtons[i].xPos;
209 int y = audioButtons[i].yPos; 209 int y = audioButtons[i].yPos;
210 if ( event->state() == QMouseEvent::LeftButton ) { 210 if ( event->state() == QMouseEvent::LeftButton ) {
211 // The test to see if the mouse click is inside the circular button or not 211 // The test to see if the mouse click is inside the circular button or not
212 // (compared with the radius squared to avoid a square-root of our distance) 212 // (compared with the radius squared to avoid a square-root of our distance)
213 int radius = 32 + 13 * size; 213 int radius = 32 + 13 * size;
214 QPoint center = QPoint( x + radius, y + radius ); 214 QPoint center = QPoint( x + radius, y + radius );
215 QPoint dXY = center - event->pos(); 215 QPoint dXY = center - event->pos();
216 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 216 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
217 bool isOnButton = dist <= (radius * radius); 217 bool isOnButton = dist <= (radius * radius);
218// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 218// QRect r( x, y, 64 + 22*size, 64 + 22*size );
219// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 219// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
220 if ( isOnButton && !audioButtons[i].isHeld ) { 220 if ( isOnButton && !audioButtons[i].isHeld ) {
221 audioButtons[i].isHeld = TRUE; 221 audioButtons[i].isHeld = TRUE;
222 toggleButton(i); 222 toggleButton(i);
223 qDebug("button toggled %d",i); 223 qDebug("button toggled1 %d",i);
224 switch (i) { 224 switch (i) {
225 case AudioVolumeUp: emit moreClicked(); return; 225 case AudioVolumeUp: emit moreClicked(); return;
226 case AudioVolumeDown: emit lessClicked(); return; 226 case AudioVolumeDown: emit lessClicked(); return;
227 } 227 }
228 } else if ( !isOnButton && audioButtons[i].isHeld ) { 228 } else if ( !isOnButton && audioButtons[i].isHeld ) {
229 audioButtons[i].isHeld = FALSE; 229 audioButtons[i].isHeld = FALSE;
230 toggleButton(i); 230 toggleButton(i);
231 qDebug("button toggled2 %d",i);
231 } 232 }
232 } else { 233 } else {
233 if ( audioButtons[i].isHeld ) { 234 if ( audioButtons[i].isHeld ) {
234 audioButtons[i].isHeld = FALSE; 235 audioButtons[i].isHeld = FALSE;
235 if ( !audioButtons[i].isToggle ) 236 if ( !audioButtons[i].isToggle )
236 setToggleButton( i, FALSE ); 237 setToggleButton( i, FALSE );
238 qDebug("button toggled3 %d",i);
237 switch (i) { 239 switch (i) {
238 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 240 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
239 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 241 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
240 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 242 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
241 case AudioNext: mediaPlayerState->setNext(); return; 243 case AudioNext: mediaPlayerState->setNext(); return;
242 case AudioPrevious: mediaPlayerState->setPrev(); return; 244 case AudioPrevious: mediaPlayerState->setPrev(); return;
243 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 245 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
244 case AudioVolumeUp: emit moreReleased(); return; 246 case AudioVolumeUp: emit moreReleased(); return;
245 case AudioVolumeDown: emit lessReleased(); return; 247 case AudioVolumeDown: emit lessReleased(); return;
246 case AudioPlayList: mediaPlayerState->setList(); return; 248 case AudioPlayList: mediaPlayerState->setList(); return;
247 } 249 }
248 } 250 }
249 } 251 }
250 } 252 }
251} 253}
252 254
253 255
254void AudioWidget::mousePressEvent( QMouseEvent *event ) { 256void AudioWidget::mousePressEvent( QMouseEvent *event ) {
255 mouseMoveEvent( event ); 257 mouseMoveEvent( event );
256} 258}
257 259
258 260
259void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 261void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
260 mouseMoveEvent( event ); 262 mouseMoveEvent( event );
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index a2850aa..d1d72b6 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -1,43 +1,44 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20
20#ifndef AUDIO_WIDGET_H 21#ifndef AUDIO_WIDGET_H
21#define AUDIO_WIDGET_H 22#define AUDIO_WIDGET_H
22 23
23#include <qwidget.h> 24#include <qwidget.h>
24#include <qpainter.h> 25#include <qpainter.h>
25#include <qdrawutil.h> 26#include <qdrawutil.h>
26#include <qpixmap.h> 27#include <qpixmap.h>
27#include <qstring.h> 28#include <qstring.h>
28#include <qslider.h> 29#include <qslider.h>
29#include <qframe.h> 30#include <qframe.h>
30 31
31 32
32class QPixmap; 33class QPixmap;
33 34
34 35
35enum AudioButtons { 36enum AudioButtons {
36 AudioPlay, 37 AudioPlay,
37 AudioStop, 38 AudioStop,
38 AudioPause, 39 AudioPause,
39 AudioNext, 40 AudioNext,
40 AudioPrevious, 41 AudioPrevious,
41 AudioVolumeUp, 42 AudioVolumeUp,
42 AudioVolumeDown, 43 AudioVolumeDown,
43 AudioLoop, 44 AudioLoop,
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 4b2827e..b9f96de 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -1,46 +1,45 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added changes Fri 02-15-2002 20// L.J.Potter added changes Fri 02-15-2002
21 21
22
23#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
24 23
25#ifdef Q_WS_QWS 24#ifdef Q_WS_QWS
26#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
27#endif 26#endif
28#include <stdio.h> 27#include <stdio.h>
29#include <stdlib.h> 28#include <stdlib.h>
30#include <string.h> 29#include <string.h>
31#include <pthread.h> 30#include <pthread.h>
32#include <errno.h> 31#include <errno.h>
33#include <unistd.h> 32#include <unistd.h>
34#include "loopcontrol.h" 33#include "loopcontrol.h"
35#include "videowidget.h" 34#include "videowidget.h"
36#include "audiodevice.h" 35#include "audiodevice.h"
37#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
38#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
39 38
40 39
41extern VideoWidget *videoUI; // now only needed to tell it to play a frame 40extern VideoWidget *videoUI; // now only needed to tell it to play a frame
42extern MediaPlayerState *mediaPlayerState; 41extern MediaPlayerState *mediaPlayerState;
43 42
44 43
45//#define DecodeLoopDebug(x) qDebug x 44//#define DecodeLoopDebug(x) qDebug x
46#define DecodeLoopDebug(x) 45#define DecodeLoopDebug(x)
@@ -200,71 +199,72 @@ void LoopControl::startVideo() {
200 current_frame++; 199 current_frame++;
201 } 200 }
202 201
203 if ( prev_frame == -1 || current_frame > prev_frame ) { 202 if ( prev_frame == -1 || current_frame > prev_frame ) {
204 if ( current_frame > prev_frame + 1 ) { 203 if ( current_frame > prev_frame + 1 ) {
205 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 204 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
206 } 205 }
207 moreVideo = videoUI->playVideo(); 206 moreVideo = videoUI->playVideo();
208 prev_frame = current_frame; 207 prev_frame = current_frame;
209 } 208 }
210 209
211 } else { 210 } else {
212 211
213 moreVideo = FALSE; 212 moreVideo = FALSE;
214 killTimer( videoId ); 213 killTimer( videoId );
215 214
216 } 215 }
217 216
218 } 217 }
219} 218}
220 219
221 220
222void LoopControl::startAudio() { 221void LoopControl::startAudio() {
223 222
223//qDebug("start audio");
224 audioMutex->lock(); 224 audioMutex->lock();
225 if ( moreAudio ) { 225 if ( moreAudio ) {
226 226
227 if ( !isMuted && mediaPlayerState->curDecoder() ) { 227 if ( !isMuted && mediaPlayerState->curDecoder() ) {
228 228
229 currentSample = audioSampleCounter + 1; 229 currentSample = audioSampleCounter + 1;
230 230
231 if ( currentSample != audioSampleCounter + 1 ) 231 if ( currentSample != audioSampleCounter + 1 )
232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
233 233
234 long samplesRead = 0; 234 long samplesRead = 0;
235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
237 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 237 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
238 238
239// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 239// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
240// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 240// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
241// } 241// }
242// else if ( sampleWaitTime <= -5000 ) { 242// else if ( sampleWaitTime <= -5000 ) {
243// // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 243// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
244// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 244// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
245// currentSample = sampleWeShouldBeAt; 245// currentSample = sampleWeShouldBeAt;
246// } 246// }
247 247
248 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 248 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
249 audioSampleCounter = currentSample + samplesRead - 1; 249 audioSampleCounter = currentSample + samplesRead - 1;
250 250
251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
252 252
253 } else { 253 } else {
254 254
255 moreAudio = FALSE; 255 moreAudio = FALSE;
256 256
257 } 257 }
258 258
259 } 259 }
260 260
261 audioMutex->unlock(); 261 audioMutex->unlock();
262} 262}
263 263
264 264
265void LoopControl::killTimers() { 265void LoopControl::killTimers() {
266 266
267 audioMutex->lock(); 267 audioMutex->lock();
268 268
269 if ( hasVideoChannel ) 269 if ( hasVideoChannel )
270 killTimer( videoId ); 270 killTimer( videoId );
@@ -357,69 +357,67 @@ bool LoopControl::init( const QString& filename ) {
357 current_frame = total_video_frames = total_audio_samples = 0; 357 current_frame = total_video_frames = total_audio_samples = 0;
358 358
359 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 359 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
360 360
361 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 361 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
362 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 362 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
363 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 363 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
364 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 364 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
365 mediaPlayerState->libMpeg3Decoder()->close(); 365 mediaPlayerState->libMpeg3Decoder()->close();
366 } 366 }
367 } 367 }
368 368
369 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 369 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
370 audioMutex->unlock(); 370 audioMutex->unlock();
371 return FALSE; 371 return FALSE;
372 } 372 }
373 373
374 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 374 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
375 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 375 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
376 376
377 if ( hasAudioChannel ) { 377 if ( hasAudioChannel ) {
378 int astream = 0; 378 int astream = 0;
379 379
380 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 380 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
381// qDebug( "LC- channels = %d", channels ); 381 qDebug( "LC- channels = %d", channels );
382 382
383 if ( !total_audio_samples ) 383 if ( !total_audio_samples )
384 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 384 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
385 385
386// total_audio_samples += 1000; 386// total_audio_samples += 1000;
387 387
388 mediaPlayerState->setLength( total_audio_samples ); 388 mediaPlayerState->setLength( total_audio_samples );
389 389
390 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 390 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
391// qDebug( "LC- frequency = %d", freq ); 391 qDebug( "LC- frequency = %d", freq );
392 392
393 audioSampleCounter = 0; 393 audioSampleCounter = 0;
394 int bits_per_sample; 394 int bits_per_sample;
395 if ( mediaPlayerState->curDecoder()->pluginName() == QString("WavPlugin") ) { 395 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) {
396 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); 396 bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
397// qDebug("using stupid hack"); 397 qDebug("using stupid hack");
398 } else { 398 } else {
399 bits_per_sample=0; 399 bits_per_sample=0;
400// freq=44100;
401 channels=2;
402 } 400 }
403 401
404 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 402 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
405 audioBuffer = new char[ audioDevice->bufferSize() ]; 403 audioBuffer = new char[ audioDevice->bufferSize() ];
406 channels = audioDevice->channels(); 404 channels = audioDevice->channels();
407 405
408 //### must check which frequency is actually used. 406 //### must check which frequency is actually used.
409 static const int size = 1; 407 static const int size = 1;
410 short int buf[size]; 408 short int buf[size];
411 long samplesRead = 0; 409 long samplesRead = 0;
412 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 410 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
413 } 411 }
414 412
415 if ( hasVideoChannel ) { 413 if ( hasVideoChannel ) {
416 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 414 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
417 415
418 mediaPlayerState->setLength( total_video_frames ); 416 mediaPlayerState->setLength( total_video_frames );
419 417
420 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 418 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
421 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 419 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
422 420
423 if ( framerate <= 1.0 ) { 421 if ( framerate <= 1.0 ) {
424 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 422 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
425 framerate = 25; 423 framerate = 25;
diff --git a/core/multimedia/opieplayer/mpegplayer.pro b/core/multimedia/opieplayer/mpegplayer.pro
index b9e9ffe..241e29e 100644
--- a/core/multimedia/opieplayer/mpegplayer.pro
+++ b/core/multimedia/opieplayer/mpegplayer.pro
@@ -1,26 +1,26 @@
1TEMPLATE = app 1TEMPLATE = 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 playlistselection.h mediaplayerstate.h \
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h 6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h
7SOURCES = main.cpp \ 7SOURCES = main.cpp \
8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ 8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \
9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp 9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp
10TARGET = mpegplayer 10TARGET = mpegplayer
11INCLUDEPATH += $(OPIEDIR)/include 11INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 12DEPENDPATH += $(OPIEDIR)/include
13LIBS += -lqpe -lpthread 13LIBS += -lqpe -lpthread
14 14
15# INTERFACES = 15# INTERFACES =
16# INCLUDEPATH += $(OPIEDIR)/include 16# INCLUDEPATH += $(OPIEDIR)/include
17# CONFIG+=static 17# CONFIG+=static
18# TMAKE_CXXFLAGS += -DQPIM_STANDALONE 18# TMAKE_CXXFLAGS += -DQPIM_STANDALONE
19# LIBS += libmpeg3/libmpeg3.a -lpthread 19# LIBS += libmpeg3/libmpeg3.a -lpthread
20# LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so 20# LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so
21 21
22INCLUDEPATH += $(OPIEDIR)/include 22INCLUDEPATH += $(OPIEDIR)/include
23DEPENDPATH += $(OPIEDIR)/include 23DEPENDPATH += $(OPIEDIR)/include
24 24
25TRANSLATIONS = ../i18n/de/mpegplayer.ts 25TRANSLATIONS += ../i18n/de/mpegplayer.ts
26TRANSLATIONS += ../i18n/pt_BR/mpegplayer.ts 26TRANSLATIONS += ../i18n/pt_BR/mpegplayer.ts
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 991301a..756e3b4 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -34,69 +34,69 @@ class PlayListSelectionItem : public QListViewItem {
34public: 34public:
35 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 35 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
36 setText( 0, f->name() ); 36 setText( 0, f->name() );
37 setPixmap( 0, f->pixmap() ); 37 setPixmap( 0, f->pixmap() );
38 } 38 }
39 39
40 ~PlayListSelectionItem() { 40 ~PlayListSelectionItem() {
41 }; 41 };
42 42
43 const DocLnk *file() const { return fl; } 43 const DocLnk *file() const { return fl; }
44 44
45private: 45private:
46 const DocLnk *fl; 46 const DocLnk *fl;
47}; 47};
48 48
49 49
50PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 50PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
51 : QListView( parent, name ) 51 : QListView( parent, name )
52{ 52{
53 qDebug("starting playlistselector"); 53 qDebug("starting playlistselector");
54// #ifdef USE_PLAYLIST_BACKGROUND 54// #ifdef USE_PLAYLIST_BACKGROUND
55// setStaticBackground( TRUE ); 55// setStaticBackground( TRUE );
56// setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); 56// setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) );
57 57
58 setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); 58// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) );
59// #endif 59// #endif
60// addColumn("Title",236); 60// addColumn("Title",236);
61// setAllColumnsShowFocus( TRUE ); 61// setAllColumnsShowFocus( TRUE );
62 addColumn( tr( "Playlist Selection" ) ); 62 addColumn( tr( "Playlist Selection" ) );
63 header()->hide(); 63 header()->hide();
64 setSorting( -1, FALSE ); 64 setSorting( -1, FALSE );
65} 65}
66 66
67 67
68PlayListSelection::~PlayListSelection() { 68PlayListSelection::~PlayListSelection() {
69} 69}
70 70
71 71
72// #ifdef USE_PLAYLIST_BACKGROUND 72// #ifdef USE_PLAYLIST_BACKGROUND
73void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 73void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
74// qDebug("drawBackground"); 74// qDebug("drawBackground");
75 p->fillRect( r, QBrush( white ) ); 75 p->fillRect( r, QBrush( white ) );
76 QImage logo = Resource::loadImage( "launcher/opielogo" ); 76// QImage logo = Resource::loadImage( "launcher/opielogo" );
77 if ( !logo.isNull() ) 77// if ( !logo.isNull() )
78 p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 78// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
79} 79}
80// #endif 80// #endif
81 81
82 82
83void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 83void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
84 if ( event->state() == QMouseEvent::LeftButton ) { 84 if ( event->state() == QMouseEvent::LeftButton ) {
85 QListViewItem *currentItem = selectedItem(); 85 QListViewItem *currentItem = selectedItem();
86 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 86 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
87 if ( currentItem && currentItem->itemAbove() == itemUnder ) 87 if ( currentItem && currentItem->itemAbove() == itemUnder )
88 moveSelectedUp(); 88 moveSelectedUp();
89 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 89 else if ( currentItem && currentItem->itemBelow() == itemUnder )
90 moveSelectedDown(); 90 moveSelectedDown();
91 } 91 }
92} 92}
93 93
94 94
95const DocLnk *PlayListSelection::current() { 95const DocLnk *PlayListSelection::current() {
96 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 96 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
97 if ( item ) 97 if ( item )
98 return item->file(); 98 return item->file();
99 return NULL; 99 return NULL;
100} 100}
101 101
102 102
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 524747e..cf665c8 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -85,48 +85,49 @@ public:
85 setToggleButton( t ); 85 setToggleButton( t );
86 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 86 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
87 QPEMenuToolFocusManager::manager()->addWidget( this ); 87 QPEMenuToolFocusManager::manager()->addWidget( this );
88 } 88 }
89}; 89};
90 90
91 91
92class MenuItem : public QAction { 92class MenuItem : public QAction {
93public: 93public:
94 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 94 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
95 : QAction( text, QString::null, 0, 0 ) { 95 : QAction( text, QString::null, 0, 0 ) {
96 connect( this, SIGNAL( activated() ), handler, slot ); 96 connect( this, SIGNAL( activated() ), handler, slot );
97 addTo( parent ); 97 addTo( parent );
98 } 98 }
99}; 99};
100 100
101 101
102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
103 : QMainWindow( parent, name, fl ) { 103 : QMainWindow( parent, name, fl ) {
104 104
105 d = new PlayListWidgetPrivate; 105 d = new PlayListWidgetPrivate;
106 d->setDocumentUsed = FALSE; 106 d->setDocumentUsed = FALSE;
107 d->current = NULL; 107 d->current = NULL;
108 fromSetDocument = FALSE; 108 fromSetDocument = FALSE;
109 insanityBool=FALSE;
109// menuTimer = new QTimer( this ,"menu timer"), 110// menuTimer = new QTimer( this ,"menu timer"),
110// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 111// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
111 112
112 setBackgroundMode( PaletteButton ); 113 setBackgroundMode( PaletteButton );
113 114
114 setCaption( tr("OpiePlayer") ); 115 setCaption( tr("OpiePlayer") );
115 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 116 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
116 117
117 setToolBarsMovable( FALSE ); 118 setToolBarsMovable( FALSE );
118 119
119 // Create Toolbar 120 // Create Toolbar
120 QPEToolBar *toolbar = new QPEToolBar( this ); 121 QPEToolBar *toolbar = new QPEToolBar( this );
121 toolbar->setHorizontalStretchable( TRUE ); 122 toolbar->setHorizontalStretchable( TRUE );
122 123
123 // Create Menubar 124 // Create Menubar
124 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 125 QPEMenuBar *menu = new QPEMenuBar( toolbar );
125 menu->setMargin( 0 ); 126 menu->setMargin( 0 );
126 127
127 QPEToolBar *bar = new QPEToolBar( this ); 128 QPEToolBar *bar = new QPEToolBar( this );
128 bar->setLabel( tr( "Play Operations" ) ); 129 bar->setLabel( tr( "Play Operations" ) );
129// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", 130// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list",
130// this , SLOT( addSelected()) ); 131// this , SLOT( addSelected()) );
131 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 132 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
132 tbDeletePlaylist->setFlat(TRUE); 133 tbDeletePlaylist->setFlat(TRUE);
@@ -185,86 +186,86 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
185 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 186 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
186 d->playListFrame = vbox3; 187 d->playListFrame = vbox3;
187 d->playListFrame ->setMinimumSize(235,260); 188 d->playListFrame ->setMinimumSize(235,260);
188 189
189 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 190 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
190 191
191 d->selectedFiles = new PlayListSelection( hbox2); 192 d->selectedFiles = new PlayListSelection( hbox2);
192 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 193 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
193 194
194 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 195 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
195 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 196 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
196 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 197 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
197 198
198 199
199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 200 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
200 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 201 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
201 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 202 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
202 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 203 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 204 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
204 205
205 QWidget *aTab; 206 QWidget *aTab;
206 aTab = new QWidget( tabWidget, "aTab" ); 207 aTab = new QWidget( tabWidget, "aTab" );
207 audioView = new QListView( aTab, "Audioview" ); 208 audioView = new QListView( aTab, "Audioview" );
208 audioView->setMinimumSize(233,260); 209 audioView->setMinimumSize(233,260);
209 audioView->addColumn( "Title",150); 210 audioView->addColumn( "Title",140);
210 audioView->addColumn("Size", 45); 211 audioView->addColumn("Size", -1);
211 audioView->addColumn("Media",35); 212 audioView->addColumn("Media",-1);
212 audioView->setColumnAlignment(1, Qt::AlignRight); 213 audioView->setColumnAlignment(1, Qt::AlignRight);
213 audioView->setColumnAlignment(2, Qt::AlignRight); 214 audioView->setColumnAlignment(2, Qt::AlignRight);
214 audioView->setAllColumnsShowFocus(TRUE); 215 audioView->setAllColumnsShowFocus(TRUE);
215 tabWidget->insertTab(aTab,"Audio"); 216 tabWidget->insertTab(aTab,"Audio");
216 217
217 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 218 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
218 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 219 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
219 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 220 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
220 221
221 222
222// audioView 223// audioView
223 Global::findDocuments(&files, "audio/*"); 224 Global::findDocuments(&files, "audio/*");
224 QListIterator<DocLnk> dit( files.children() ); 225 QListIterator<DocLnk> dit( files.children() );
225 QString storage; 226 QString storage;
226 for ( ; dit.current(); ++dit ) { 227 for ( ; dit.current(); ++dit ) {
227 QListViewItem * newItem; 228 QListViewItem * newItem;
228 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 229 if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
229 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 230 else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
230 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 231 else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD";
231 else storage="RAM"; 232 else storage="RAM";
232 if ( QFile( dit.current()->file()).exists() ) { 233 if ( QFile( dit.current()->file()).exists() ) {
233 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 234 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
234 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); 235 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
235 } 236 }
236 } 237 }
237// videowidget 238// videowidget
238 239
239 QWidget *vTab; 240 QWidget *vTab;
240 vTab = new QWidget( tabWidget, "vTab" ); 241 vTab = new QWidget( tabWidget, "vTab" );
241 videoView = new QListView( vTab, "Videoview" ); 242 videoView = new QListView( vTab, "Videoview" );
242 videoView->setMinimumSize(233,260); 243 videoView->setMinimumSize(233,260);
243 244
244 videoView->addColumn("Title",150); 245 videoView->addColumn("Title",140);
245 videoView->addColumn("Size",45); 246 videoView->addColumn("Size",-1);
246 videoView->addColumn("Media",35); 247 videoView->addColumn("Media",-1);
247 videoView->setColumnAlignment(1, Qt::AlignRight); 248 videoView->setColumnAlignment(1, Qt::AlignRight);
248 videoView->setColumnAlignment(2, Qt::AlignRight); 249 videoView->setColumnAlignment(2, Qt::AlignRight);
249 videoView->setAllColumnsShowFocus(TRUE); 250 videoView->setAllColumnsShowFocus(TRUE);
250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 251 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 252 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 253 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
253 254
254 tabWidget->insertTab( vTab,"Video"); 255 tabWidget->insertTab( vTab,"Video");
255 256
256 Global::findDocuments(&vFiles, "video/*"); 257 Global::findDocuments(&vFiles, "video/*");
257 QListIterator<DocLnk> Vdit( vFiles.children() ); 258 QListIterator<DocLnk> Vdit( vFiles.children() );
258 for ( ; Vdit.current(); ++Vdit ) { 259 for ( ; Vdit.current(); ++Vdit ) {
259 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; 260 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
260 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; 261 else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF";
261 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; 262 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
262 else storage="RAM"; 263 else storage="RAM";
263 QListViewItem * newItem; 264 QListViewItem * newItem;
264 if ( QFile( Vdit.current()->file()).exists() ) { 265 if ( QFile( Vdit.current()->file()).exists() ) {
265 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 266 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
266 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); 267 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
267 } 268 }
268 } 269 }
269 270
270//playlists list 271//playlists list
@@ -465,80 +466,92 @@ void PlayListWidget::setActiveWindow() {
465 mediaPlayerState->setView( 'l' ); // invalidate 466 mediaPlayerState->setView( 'l' ); // invalidate
466 mediaPlayerState->setView( origView ); // now switch back 467 mediaPlayerState->setView( origView ); // now switch back
467} 468}
468 469
469 470
470void PlayListWidget::useSelectedDocument() { 471void PlayListWidget::useSelectedDocument() {
471 d->setDocumentUsed = FALSE; 472 d->setDocumentUsed = FALSE;
472} 473}
473 474
474 475
475const DocLnk *PlayListWidget::current() { // this is fugly 476const DocLnk *PlayListWidget::current() { // this is fugly
476 477
477// if( fromSetDocument) { 478// if( fromSetDocument) {
478// qDebug("from setDoc"); 479// qDebug("from setDoc");
479// DocLnkSet files; 480// DocLnkSet files;
480// Global::findDocuments(&files, "video/*;audio/*"); 481// Global::findDocuments(&files, "video/*;audio/*");
481// QListIterator<DocLnk> dit( files.children() ); 482// QListIterator<DocLnk> dit( files.children() );
482// for ( ; dit.current(); ++dit ) { 483// for ( ; dit.current(); ++dit ) {
483// if(dit.current()->linkFile() == setDocFileRef) { 484// if(dit.current()->linkFile() == setDocFileRef) {
484// qDebug(setDocFileRef); 485// qDebug(setDocFileRef);
485// return dit; 486// return dit;
486// } 487// }
487// } 488// }
488// } else 489// } else
489 switch (tabWidget->currentPageIndex()) { 490// qDebug("current");
490 case 0: //playlist 491// switch (tabWidget->currentPageIndex()) {
491 { 492// case 0: //playlist
492 if ( mediaPlayerState->playlist() ) { 493// {
493 return d->selectedFiles->current(); 494 qDebug("playlist");
494 } 495 if ( mediaPlayerState->playlist() ) {
495 else if ( d->setDocumentUsed && d->current ) { 496 return d->selectedFiles->current();
496 return d->current;
497 } else {
498 return d->files->selected();
499 }
500 } 497 }
501 break; 498 else if ( d->setDocumentUsed && d->current ) {
502 case 1: { //audio 499 return d->current;
503 Global::findDocuments(&files, "audio/*"); 500 } else {
504 QListIterator<DocLnk> dit( files.children() ); 501 return d->files->selected();
505 for ( ; dit.current(); ++dit ) {
506 if( dit.current()->name() == audioView->currentItem()->text(0))
507 return dit;
508 }
509 }
510 break;
511 case 2: { // video
512 Global::findDocuments(&vFiles, "video/*");
513 QListIterator<DocLnk> Vdit( vFiles.children() );
514 for ( ; Vdit.current(); ++Vdit ) {
515 if( Vdit.current()->name() == videoView->currentItem()->text(0))
516 return Vdit;
517 }
518 } 502 }
519 break; 503// }
520 }; 504// break;
505// case 1://audio
506// {
507// qDebug("audioView");
508// Global::findDocuments(&files, "audio/*");
509// QListIterator<DocLnk> dit( files.children() );
510// for ( ; dit.current(); ++dit ) {
511// if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
512// qDebug("here");
513// insanityBool=TRUE;
514// return dit;
515// }
516// }
517// }
518// break;
519// case 2: // video
520// {
521// qDebug("videoView");
522// Global::findDocuments(&vFiles, "video/*");
523// QListIterator<DocLnk> Vdit( vFiles.children() );
524// for ( ; Vdit.current(); ++Vdit ) {
525// if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
526// insanityBool=TRUE;
527// return Vdit;
528// }
529// }
530// }
531// break;
532// };
533// return 0;
521} 534}
522 535
523bool PlayListWidget::prev() { 536bool PlayListWidget::prev() {
524 if ( mediaPlayerState->playlist() ) { 537 if ( mediaPlayerState->playlist() ) {
525 if ( mediaPlayerState->shuffled() ) { 538 if ( mediaPlayerState->shuffled() ) {
526 const DocLnk *cur = current(); 539 const DocLnk *cur = current();
527 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 540 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
528 for ( int i = 0; i < j; i++ ) { 541 for ( int i = 0; i < j; i++ ) {
529 if ( !d->selectedFiles->next() ) 542 if ( !d->selectedFiles->next() )
530 d->selectedFiles->first(); 543 d->selectedFiles->first();
531 } 544 }
532 if ( cur == current() ) 545 if ( cur == current() )
533 if ( !d->selectedFiles->next() ) 546 if ( !d->selectedFiles->next() )
534 d->selectedFiles->first(); 547 d->selectedFiles->first();
535 return TRUE; 548 return TRUE;
536 } else { 549 } else {
537 if ( !d->selectedFiles->prev() ) { 550 if ( !d->selectedFiles->prev() ) {
538 if ( mediaPlayerState->looping() ) { 551 if ( mediaPlayerState->looping() ) {
539 return d->selectedFiles->last(); 552 return d->selectedFiles->last();
540 } else { 553 } else {
541 return FALSE; 554 return FALSE;
542 } 555 }
543 } 556 }
544 return TRUE; 557 return TRUE;
@@ -633,60 +646,91 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
633 readConfig(cfg); 646 readConfig(cfg);
634 tabWidget->setCurrentPage(0); 647 tabWidget->setCurrentPage(0);
635 Config config( "MediaPlayer" ); 648 Config config( "MediaPlayer" );
636 config.writeEntry("CurrentPlaylist", name); 649 config.writeEntry("CurrentPlaylist", name);
637 d->selectedFiles->first(); 650 d->selectedFiles->first();
638 } 651 }
639} 652}
640 653
641void PlayListWidget::setPlaylist( bool shown ) { 654void PlayListWidget::setPlaylist( bool shown ) {
642 if ( shown ) 655 if ( shown )
643 d->playListFrame->show(); 656 d->playListFrame->show();
644 else 657 else
645 d->playListFrame->hide(); 658 d->playListFrame->hide();
646} 659}
647 660
648void PlayListWidget::setView( char view ) { 661void PlayListWidget::setView( char view ) {
649 if ( view == 'l' ) 662 if ( view == 'l' )
650 showMaximized(); 663 showMaximized();
651 else 664 else
652 hide(); 665 hide();
653} 666}
654 667
655void PlayListWidget::addSelected() { 668void PlayListWidget::addSelected() {
656 669
657 switch (tabWidget->currentPageIndex()) { 670 Config cfg( "MediaPlayer" );
658 case 0: //playlist 671 cfg.setGroup("PlayList");
659 break; 672 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
660 case 1: { //audio 673 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
661 addToSelection( audioView->selectedItem() ); 674
662 } 675 switch (tabWidget->currentPageIndex()) {
663 break; 676 case 0: //playlist
664 case 2: { // video 677 break;
665 addToSelection( videoView->selectedItem() ); 678 case 1: { //audio
666 } 679 for ( int i = 0; i < noOfFiles; i++ ) {
667 break; 680 QString entryName;
668 }; 681 entryName.sprintf( "File%i", i + 1 );
682 QString linkFile = cfg.readEntry( entryName );
683 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) {
684 int result= QMessageBox::warning(this,"OpiePlayer",
685 tr("This is all ready in your playlist.\nContinue?"),
686 tr("Yes"),tr("No"),0,0,1);
687 if (result !=0)
688 return;
689 }
690 }
691 addToSelection( audioView->selectedItem() );
692 tabWidget->setCurrentPage(1);
693 }
694 break;
695 case 2: { // video
696 for ( int i = 0; i < noOfFiles; i++ ) {
697 QString entryName;
698 entryName.sprintf( "File%i", i + 1 );
699 QString linkFile = cfg.readEntry( entryName );
700 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
701 int result= QMessageBox::warning(this,"OpiePlayer",
702 tr("This is all ready in your playlist.\nContinue?"),
703 tr("Yes"),tr("No"),0,0,1);
704 if (result !=0)
705 return;
706 }
707 }
708 addToSelection( videoView->selectedItem() );
709 tabWidget->setCurrentPage(2);
710 }
711 break;
712 };
669} 713}
670 714
671void PlayListWidget::removeSelected() { 715void PlayListWidget::removeSelected() {
672 d->selectedFiles->removeSelected( ); 716 d->selectedFiles->removeSelected( );
673} 717}
674 718
675 719
676void PlayListWidget::playIt( QListViewItem *it) { 720void PlayListWidget::playIt( QListViewItem *it) {
677// d->setDocumentUsed = FALSE; 721// d->setDocumentUsed = FALSE;
678 mediaPlayerState->setPlaying(TRUE); 722 mediaPlayerState->setPlaying(TRUE);
679} 723}
680 724
681void PlayListWidget::addToSelection( QListViewItem *it) { 725void PlayListWidget::addToSelection( QListViewItem *it) {
682 d->setDocumentUsed = FALSE; 726 d->setDocumentUsed = FALSE;
683 727
684 if(it) { 728 if(it) {
685// qDebug("add to selection"); 729// qDebug("add to selection");
686 switch (tabWidget->currentPageIndex()) { 730 switch (tabWidget->currentPageIndex()) {
687 case 1: { 731 case 1: {
688// qDebug("case 1"); 732// qDebug("case 1");
689 QListIterator<DocLnk> dit( files.children() ); 733 QListIterator<DocLnk> dit( files.children() );
690 for ( ; dit.current(); ++dit ) { 734 for ( ; dit.current(); ++dit ) {
691// qDebug(dit.current()->name()); 735// qDebug(dit.current()->name());
692 if( dit.current()->name() == it->text(0)) { 736 if( dit.current()->name() == it->text(0)) {
@@ -734,49 +778,80 @@ void PlayListWidget::tabChanged(QWidget *widg) {
734 } 778 }
735 break; 779 break;
736 case 2: 780 case 2:
737 { 781 {
738 if( !tbDeletePlaylist->isHidden()) 782 if( !tbDeletePlaylist->isHidden())
739 tbDeletePlaylist->hide(); 783 tbDeletePlaylist->hide();
740 d->tbRemoveFromList->setEnabled(FALSE); 784 d->tbRemoveFromList->setEnabled(FALSE);
741 d->tbAddToList->setEnabled(TRUE); 785 d->tbAddToList->setEnabled(TRUE);
742 } 786 }
743 break; 787 break;
744 case 3: 788 case 3:
745 { 789 {
746 if( tbDeletePlaylist->isHidden()) 790 if( tbDeletePlaylist->isHidden())
747 tbDeletePlaylist->show(); 791 tbDeletePlaylist->show();
748 playLists->reread(); 792 playLists->reread();
749 } 793 }
750 break; 794 break;
751 }; 795 };
752} 796}
753 797
754 798
755/* 799/*
756 play button is pressed*/ 800 play button is pressed*/
757void PlayListWidget::btnPlay(bool b) { 801void PlayListWidget::btnPlay(bool b) {
758 mediaPlayerState->setPlaying(b); 802// mediaPlayerState->setPlaying(b);
803 switch ( tabWidget->currentPageIndex()) {
804 case 0:
805 {
806 mediaPlayerState->setPlaying(b);
807 }
808 break;
809 case 1:
810 {
811 addToSelection( audioView->selectedItem() );
812 mediaPlayerState->setPlaying(b);
813// qApp->processEvents();
814 d->selectedFiles->removeSelected( );
815 tabWidget->setCurrentPage(1);
816// mediaPlayerState->setPlaying(FALSE);
817 }
818 break;
819 case 2:
820 {
821 addToSelection( videoView->selectedItem() );
822 mediaPlayerState->setPlaying(b);
823 qApp->processEvents();
824 d->selectedFiles->removeSelected( );
825 tabWidget->setCurrentPage(2);
826// mediaPlayerState->setPlaying(FALSE);
827 }
828 break;
829 };
830
831
832
833
759} 834}
760 835
761void PlayListWidget::deletePlaylist() { 836void PlayListWidget::deletePlaylist() {
762 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 837 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
763 (tr("You really want to delete\nthis playlist?")), 838 (tr("You really want to delete\nthis playlist?")),
764 (tr("Yes")), (tr("No")), 0 )){ 839 (tr("Yes")), (tr("No")), 0 )){
765 case 0: // Yes clicked, 840 case 0: // Yes clicked,
766 QFile().remove(playLists->selected()->file()); 841 QFile().remove(playLists->selected()->file());
767 QFile().remove(playLists->selected()->linkFile()); 842 QFile().remove(playLists->selected()->linkFile());
768 playLists->reread(); 843 playLists->reread();
769 break; 844 break;
770 case 1: // Cancel 845 case 1: // Cancel
771 break; 846 break;
772 }; 847 };
773 848
774} 849}
775 850
776void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 851void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
777{ 852{
778 switch (mouse) { 853 switch (mouse) {
779 case 1: 854 case 1:
780 break; 855 break;
781 case 2:{ 856 case 2:{
782 QPopupMenu m; 857 QPopupMenu m;
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index effc600..10a42df 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -28,48 +28,49 @@
28 28
29/* #include <qtimer.h> */ 29/* #include <qtimer.h> */
30 30
31 31
32class PlayListWidgetPrivate; 32class PlayListWidgetPrivate;
33class Config; 33class Config;
34class QListViewItem; 34class QListViewItem;
35class QListView; 35class QListView;
36class QPoint; 36class QPoint;
37class QAction; 37class QAction;
38class QLabel; 38class QLabel;
39 39
40class PlayListWidget : public QMainWindow { 40class PlayListWidget : public QMainWindow {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 44 ~PlayListWidget();
45 QTabWidget * tabWidget; 45 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 46 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 47 DocLnkSet files;
48 DocLnkSet vFiles; 48 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 49 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 50 QLabel *libString;
51 bool fromSetDocument; 51 bool fromSetDocument;
52 bool insanityBool;
52 QString setDocFileRef; 53 QString setDocFileRef;
53 // retrieve the current playlist entry (media file link) 54 // retrieve the current playlist entry (media file link)
54 const DocLnk *current(); 55 const DocLnk *current();
55 void useSelectedDocument(); 56 void useSelectedDocument();
56/* QTimer * menuTimer; */ 57/* QTimer * menuTimer; */
57 FileSelector* playLists; 58 FileSelector* playLists;
58 QPushButton *tbDeletePlaylist; 59 QPushButton *tbDeletePlaylist;
59public slots: 60public slots:
60 void setDocument( const QString& fileref ); 61 void setDocument( const QString& fileref );
61 void addToSelection( const DocLnk& ); // Add a media file to the playlist 62 void addToSelection( const DocLnk& ); // Add a media file to the playlist
62 void addToSelection( QListViewItem* ); // Add a media file to the playlist 63 void addToSelection( QListViewItem* ); // Add a media file to the playlist
63 void setActiveWindow(); // need to handle this to show the right view 64 void setActiveWindow(); // need to handle this to show the right view
64 void setPlaylist( bool ); // Show/Hide the playlist 65 void setPlaylist( bool ); // Show/Hide the playlist
65 void setView( char ); 66 void setView( char );
66 void clearList(); 67 void clearList();
67 void addAllToList(); 68 void addAllToList();
68 void addAllMusicToList(); 69 void addAllMusicToList();
69 void addAllVideoToList(); 70 void addAllVideoToList();
70 void saveList(); // Save the playlist 71 void saveList(); // Save the playlist
71 void loadList( const DocLnk &); // Load a playlist 72 void loadList( const DocLnk &); // Load a playlist
72 void playIt( QListViewItem *); 73 void playIt( QListViewItem *);
73 74
74 void btnPlay(bool); 75 void btnPlay(bool);
75 void deletePlaylist(); 76 void deletePlaylist();
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index bb5f9e8..23b36e5 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -182,59 +182,60 @@ void VideoWidget::paintButton( QPainter *p, int i ) {
182} 182}
183 183
184 184
185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
186 for ( int i = 0; i < numButtons; i++ ) { 186 for ( int i = 0; i < numButtons; i++ ) {
187 int x = videoButtons[i].xPos; 187 int x = videoButtons[i].xPos;
188 int y = videoButtons[i].yPos; 188 int y = videoButtons[i].yPos;
189 if ( event->state() == QMouseEvent::LeftButton ) { 189 if ( event->state() == QMouseEvent::LeftButton ) {
190 // The test to see if the mouse click is inside the circular button or not 190 // The test to see if the mouse click is inside the circular button or not
191 // (compared with the radius squared to avoid a square-root of our distance) 191 // (compared with the radius squared to avoid a square-root of our distance)
192 int radius = 16; 192 int radius = 16;
193 QPoint center = QPoint( x + radius, y + radius ); 193 QPoint center = QPoint( x + radius, y + radius );
194 QPoint dXY = center - event->pos(); 194 QPoint dXY = center - event->pos();
195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
196 bool isOnButton = dist <= (radius * radius); 196 bool isOnButton = dist <= (radius * radius);
197 if ( isOnButton != videoButtons[i].isHeld ) { 197 if ( isOnButton != videoButtons[i].isHeld ) {
198 videoButtons[i].isHeld = isOnButton; 198 videoButtons[i].isHeld = isOnButton;
199 toggleButton(i); 199 toggleButton(i);
200 } 200 }
201 } else { 201 } else {
202 if ( videoButtons[i].isHeld ) { 202 if ( videoButtons[i].isHeld ) {
203 videoButtons[i].isHeld = FALSE; 203 videoButtons[i].isHeld = FALSE;
204 if ( !videoButtons[i].isToggle ) 204 if ( !videoButtons[i].isToggle )
205 setToggleButton( i, FALSE ); 205 setToggleButton( i, FALSE );
206 switch (i) {
207 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
208 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
209 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
210 case VideoNext: mediaPlayerState->setNext(); return;
211 case VideoPrevious: mediaPlayerState->setPrev(); return;
212 case VideoPlayList: mediaPlayerState->setList(); return;
213 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
214 }
215 } 206 }
216 } 207 }
208 switch (i) {
209 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
210 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
211 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
212 case VideoNext: mediaPlayerState->setNext(); return;
213 case VideoPrevious: mediaPlayerState->setPrev(); return;
214 case VideoPlayList: mediaPlayerState->setList(); return;
215 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
216 }
217
217 } 218 }
218} 219}
219 220
220 221
221void VideoWidget::mousePressEvent( QMouseEvent *event ) { 222void VideoWidget::mousePressEvent( QMouseEvent *event ) {
222 mouseMoveEvent( event ); 223 mouseMoveEvent( event );
223} 224}
224 225
225 226
226void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 227void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
227 if ( mediaPlayerState->fullscreen() ) { 228 if ( mediaPlayerState->fullscreen() ) {
228 mediaPlayerState->setFullscreen( FALSE ); 229 mediaPlayerState->setFullscreen( FALSE );
229 makeVisible(); 230 makeVisible();
230 231
231 mouseMoveEvent( event ); 232 mouseMoveEvent( event );
232 } 233 }
233} 234}
234 235
235 236
236void VideoWidget::makeVisible() { 237void VideoWidget::makeVisible() {
237 if ( mediaPlayerState->fullscreen() ) { 238 if ( mediaPlayerState->fullscreen() ) {
238 setBackgroundMode( QWidget::NoBackground ); 239 setBackgroundMode( QWidget::NoBackground );
239 showFullScreen(); 240 showFullScreen();
240 resize( qApp->desktop()->size() ); 241 resize( qApp->desktop()->size() );