summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-04 00:41:07 (UTC)
committer llornkcor <llornkcor>2002-11-04 00:41:07 (UTC)
commit08fdebd78a4266642a7bdb2b1ead6e306bda64ad (patch) (unidiff)
tree8266160d575107b710457c3dfcd84e415268a92d
parentdc44b0babe9ffa7b29cc6269596703bab8edf6ab (diff)
downloadopie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.zip
opie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.tar.gz
opie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.tar.bz2
various
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp76
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp35
-rw-r--r--core/multimedia/opieplayer/audiowidget.h13
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp59
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h2
5 files changed, 92 insertions, 93 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 020f6be..136e06c 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -30,36 +30,26 @@
30 30
31 31
32#include <errno.h> 32#include <errno.h>
33 33
34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
35#include "qpe/qcopenvelope_qws.h" 35#include "qpe/qcopenvelope_qws.h"
36#endif 36#endif
37 37
38// #ifdef Q_WS_WIN
39// #include <windows.h>
40// #include <mmsystem.h>
41// #include <mmreg.h>
42// #endif
43#if defined(Q_WS_X11) || defined(Q_WS_QWS) 38#if defined(Q_WS_X11) || defined(Q_WS_QWS)
44#include <fcntl.h> 39#include <fcntl.h>
45#include <sys/ioctl.h> 40#include <sys/ioctl.h>
46#include <sys/soundcard.h> 41#include <sys/soundcard.h>
47#include <sys/stat.h> 42#include <sys/stat.h>
48#include <sys/time.h> 43#include <sys/time.h>
49#include <sys/types.h> 44#include <sys/types.h>
50#include <unistd.h> 45#include <unistd.h>
51#endif 46#endif
52 47
53// #if defined(Q_OS_WIN32)
54// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
55// static const int timerResolutionMilliSeconds = 30;
56// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
57// #else
58# if defined(QT_QWS_IPAQ) 48# if defined(QT_QWS_IPAQ)
59static const int sound_fragment_shift = 14; 49static const int sound_fragment_shift = 14;
60# else 50# else
61static const int sound_fragment_shift = 16; 51static const int sound_fragment_shift = 16;
62# endif 52# endif
63static const int sound_fragment_bytes = (1<<sound_fragment_shift); 53static const int sound_fragment_bytes = (1<<sound_fragment_shift);
64//#endif 54//#endif
65 55
@@ -96,73 +86,39 @@ int AudioDevicePrivate::dspFd = 0;
96bool AudioDevicePrivate::muted = FALSE; 86bool AudioDevicePrivate::muted = FALSE;
97unsigned int AudioDevicePrivate::leftVolume = 0; 87unsigned int AudioDevicePrivate::leftVolume = 0;
98unsigned int AudioDevicePrivate::rightVolume = 0; 88unsigned int AudioDevicePrivate::rightVolume = 0;
99 89
100 90
101void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 91void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
102 muted = AudioDevicePrivate::muted; 92 muted = AudioDevicePrivate::muted;
103 unsigned int volume; 93 unsigned int volume;
104// #ifdef Q_OS_WIN32
105// HWAVEOUT handle;
106// WAVEFORMATEX formatData;
107// formatData.cbSize = sizeof(WAVEFORMATEX);
108// formatData.wFormatTag = WAVE_FORMAT_PCM;
109// formatData.nAvgBytesPerSec = 4 * 44000;
110// formatData.nBlockAlign = 4;
111// formatData.nChannels = 2;
112// formatData.nSamplesPerSec = 44000;
113// formatData.wBitsPerSample = 16;
114// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
115// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
116// // qDebug( "get volume of audio device failed" );
117// waveOutClose( handle );
118// leftVolume = volume & 0xFFFF;
119// rightVolume = volume >> 16;
120// #else
121 int mixerHandle = open( "/dev/mixer", O_RDWR ); 94 int mixerHandle = open( "/dev/mixer", O_RDWR );
122 if ( mixerHandle >= 0 ) { 95 if ( mixerHandle >= 0 ) {
123 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) 96 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
124 perror("ioctl(\"MIXER_READ\")"); 97 perror("ioctl(\"MIXER_READ\")");
125 close( mixerHandle ); 98 close( mixerHandle );
126 } else 99 } else
127 perror("open(\"/dev/mixer\")"); 100 perror("open(\"/dev/mixer\")");
128 leftVolume = ((volume & 0x00FF) << 16) / 101; 101 leftVolume = ((volume & 0x00FF) << 16) / 101;
129 rightVolume = ((volume & 0xFF00) << 8) / 101; 102 rightVolume = ((volume & 0xFF00) << 8) / 101;
130//#endif
131} 103}
132 104
133 105
134void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 106void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
135 AudioDevicePrivate::muted = muted; 107 AudioDevicePrivate::muted = muted;
136 if ( muted ) { 108 if ( muted ) {
137 AudioDevicePrivate::leftVolume = leftVolume; 109 AudioDevicePrivate::leftVolume = leftVolume;
138 AudioDevicePrivate::rightVolume = rightVolume; 110 AudioDevicePrivate::rightVolume = rightVolume;
139 leftVolume = 0; 111 leftVolume = 0;
140 rightVolume = 0; 112 rightVolume = 0;
141 } else { 113 } else {
142 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 114 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
143 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 115 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
144 } 116 }
145// #ifdef Q_OS_WIN32
146// HWAVEOUT handle;
147// WAVEFORMATEX formatData;
148// formatData.cbSize = sizeof(WAVEFORMATEX);
149// formatData.wFormatTag = WAVE_FORMAT_PCM;
150// formatData.nAvgBytesPerSec = 4 * 44000;
151// formatData.nBlockAlign = 4;
152// formatData.nChannels = 2;
153// formatData.nSamplesPerSec = 44000;
154// formatData.wBitsPerSample = 16;
155// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
156// unsigned int volume = (rightVolume << 16) | leftVolume;
157// if ( waveOutSetVolume( handle, volume ) )
158// // qDebug( "set volume of audio device failed" );
159// waveOutClose( handle );
160// #else
161 // Volume can be from 0 to 100 which is 101 distinct values 117 // Volume can be from 0 to 100 which is 101 distinct values
162 unsigned int rV = (rightVolume * 101) >> 16; 118 unsigned int rV = (rightVolume * 101) >> 16;
163 119
164# if 0 120# if 0
165 unsigned int lV = (leftVolume * 101) >> 16; 121 unsigned int lV = (leftVolume * 101) >> 16;
166 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 122 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
167 int mixerHandle = 0; 123 int mixerHandle = 0;
168 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 124 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
@@ -185,17 +141,16 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
185#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 141#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
186 // Send notification that the volume has changed 142 // Send notification that the volume has changed
187 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 143 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
188#endif 144#endif
189} 145}
190 146
191 147
192 148
193
194AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 149AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
195 qDebug("creating new audio device"); 150 qDebug("creating new audio device");
196 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 151 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
197 d = new AudioDevicePrivate; 152 d = new AudioDevicePrivate;
198 d->frequency = f; 153 d->frequency = f;
199 d->channels = chs; 154 d->channels = chs;
200 d->bytesPerSample = bps; 155 d->bytesPerSample = bps;
201 qDebug("%d",bps); 156 qDebug("%d",bps);
@@ -261,52 +216,34 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
261 216
262} 217}
263 218
264 219
265AudioDevice::~AudioDevice() { 220AudioDevice::~AudioDevice() {
266 qDebug("destryo audiodevice"); 221 qDebug("destryo audiodevice");
267 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 222 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
268 223
269// #ifdef Q_OS_WIN32
270// waveOutClose( (HWAVEOUT)d->handle );
271// #else
272# ifndef KEEP_DEVICE_OPEN 224# ifndef KEEP_DEVICE_OPEN
273 close( d->handle ); // Now it should be safe to shut the handle 225 close( d->handle ); // Now it should be safe to shut the handle
274# endif 226# endif
275 delete d->unwrittenBuffer; 227 delete d->unwrittenBuffer;
276 delete d; 228 delete d;
277//#endif
278 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; 229 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
279 230
280} 231}
281 232
282 233
283void AudioDevice::volumeChanged( bool muted ) 234void AudioDevice::volumeChanged( bool muted )
284{ 235{
285 AudioDevicePrivate::muted = muted; 236 AudioDevicePrivate::muted = muted;
286} 237}
287 238
288 239
289void AudioDevice::write( char *buffer, unsigned int length ) 240void AudioDevice::write( char *buffer, unsigned int length )
290{ 241{
291// #ifdef Q_OS_WIN32
292// // returns immediately and (to be implemented) emits completedIO() when finished writing
293// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
294// // maybe the buffer should be copied so that this fool proof, but its a performance hit
295// lpWaveHdr->lpData = buffer;
296// lpWaveHdr->dwBufferLength = length;
297// lpWaveHdr->dwFlags = 0L;
298// lpWaveHdr->dwLoops = 0L;
299// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
300// // waveOutWrite returns immediately. the data is sent in the background.
301// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
302// qDebug( "failed to write block to audio device" );
303// // emit completedIO();
304// #else
305 int t = ::write( d->handle, buffer, length ); 242 int t = ::write( d->handle, buffer, length );
306 if ( t<0 ) t = 0; 243 if ( t<0 ) t = 0;
307 if ( t != (int)length) { 244 if ( t != (int)length) {
308 qDebug("Ahhh!! memcpys 1"); 245 qDebug("Ahhh!! memcpys 1");
309 memcpy(d->unwrittenBuffer,buffer+t,length-t); 246 memcpy(d->unwrittenBuffer,buffer+t,length-t);
310 d->unwritten = length-t; 247 d->unwritten = length-t;
311 } 248 }
312//#endif 249//#endif
@@ -333,19 +270,16 @@ unsigned int AudioDevice::bytesPerSample() const
333 270
334unsigned int AudioDevice::bufferSize() const 271unsigned int AudioDevice::bufferSize() const
335{ 272{
336 return d->bufferSize; 273 return d->bufferSize;
337} 274}
338 275
339unsigned int AudioDevice::canWrite() const 276unsigned int AudioDevice::canWrite() const
340{ 277{
341// #ifdef Q_OS_WIN32
342// return bufferSize(); // Any better?
343// #else
344 audio_buf_info info; 278 audio_buf_info info;
345 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { 279 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
346 d->can_GETOSPACE = FALSE; 280 d->can_GETOSPACE = FALSE;
347 fcntl( d->handle, F_SETFL, O_NONBLOCK ); 281 fcntl( d->handle, F_SETFL, O_NONBLOCK );
348 } 282 }
349 if ( d->can_GETOSPACE ) { 283 if ( d->can_GETOSPACE ) {
350 int t = info.fragments * sound_fragment_bytes; 284 int t = info.fragments * sound_fragment_bytes;
351 return QMIN(t,(int)bufferSize()); 285 return QMIN(t,(int)bufferSize());
@@ -360,30 +294,20 @@ unsigned int AudioDevice::canWrite() const
360 d->unwritten = 0; 294 d->unwritten = 0;
361 } 295 }
362 } 296 }
363 if ( d->unwritten ) 297 if ( d->unwritten )
364 return 0; 298 return 0;
365 else 299 else
366 return d->bufferSize; 300 return d->bufferSize;
367 } 301 }
368//#endif
369} 302}
370 303
371 304
372int AudioDevice::bytesWritten() { 305int AudioDevice::bytesWritten() {
373// #ifdef Q_OS_WIN32
374// MMTIME pmmt = { TIME_BYTES, 0 };
375// if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
376// qDebug( "failed to get audio device position" );
377// return -1;
378// }
379// return pmmt.u.cb;
380// #else
381 int buffered = 0; 306 int buffered = 0;
382 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 307 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
383 qDebug( "failed to get audio device position" ); 308 qDebug( "failed to get audio device position" );
384 return -1; 309 return -1;
385 } 310 }
386 return buffered; 311 return buffered;
387//#endif
388} 312}
389 313
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index d20d560..ef7c8dc 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -141,24 +141,24 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
141 resizeEvent( NULL ); 141 resizeEvent( NULL );
142 142
143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
145 145
146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
151 151
152 // Intialise state 152 // Intialise state
153 setLength( mediaPlayerState->length() ); 153 setLength( mediaPlayerState->length() );
154 setPosition( mediaPlayerState->position() ); 154 setPosition( mediaPlayerState->position() );
155 setLooping( mediaPlayerState->fullscreen() ); 155 setLooping( mediaPlayerState->fullscreen() );
156 setPaused( mediaPlayerState->paused() ); 156// setPaused( mediaPlayerState->paused() );
157 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
158 158
159} 159}
160 160
161 161
162AudioWidget::~AudioWidget() { 162AudioWidget::~AudioWidget() {
163 163
164 for ( int i = 0; i < 10; i++ ) { 164 for ( int i = 0; i < 10; i++ ) {
@@ -358,31 +358,48 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
358 if ( isOnButton && !audioButtons[i].isHeld ) { 358 if ( isOnButton && !audioButtons[i].isHeld ) {
359 audioButtons[i].isHeld = TRUE; 359 audioButtons[i].isHeld = TRUE;
360 toggleButton(i); 360 toggleButton(i);
361 switch (i) { 361 switch (i) {
362 case AudioVolumeUp: 362 case AudioVolumeUp:
363 qDebug("more clicked"); 363 qDebug("more clicked");
364 emit moreClicked(); 364 emit moreClicked();
365 return; 365 return;
366 case AudioVolumeDown: emit lessClicked(); return; 366 case AudioVolumeDown:
367 qDebug("less clicked");
368 emit lessClicked();
369 return;
370 case AudioForward:
371 emit forwardClicked();
372 return;
373 case AudioBack:
374 emit backClicked();
375 return;
367 } 376 }
368 } else if ( !isOnButton && audioButtons[i].isHeld ) { 377 } else if ( !isOnButton && audioButtons[i].isHeld ) {
369 audioButtons[i].isHeld = FALSE; 378 audioButtons[i].isHeld = FALSE;
370 toggleButton(i); 379 toggleButton(i);
371 } 380 }
372 } else { 381 } else {
373 if ( audioButtons[i].isHeld ) { 382 if ( audioButtons[i].isHeld ) {
374 audioButtons[i].isHeld = FALSE; 383 audioButtons[i].isHeld = FALSE;
375 if ( !audioButtons[i].isToggle ) 384 if ( !audioButtons[i].isToggle )
376 setToggleButton( i, FALSE ); 385 setToggleButton( i, FALSE );
377 switch (i) { 386 switch (i) {
378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 387 case AudioPlay:
388 if( mediaPlayerState->isPaused ) {
389 mediaPlayerState->setPaused( FALSE );
390 return;
391 } else if( !mediaPlayerState->isPaused ) {
392 mediaPlayerState->setPaused( TRUE );
393 return;
394 }
395// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 396 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
380 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 397// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
381 case AudioNext: mediaPlayerState->setNext(); return; 398 case AudioNext: mediaPlayerState->setNext(); return;
382 case AudioPrevious: mediaPlayerState->setPrev(); return; 399 case AudioPrevious: mediaPlayerState->setPrev(); return;
383 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 400 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
384 case AudioVolumeUp: emit moreReleased(); return; 401 case AudioVolumeUp: emit moreReleased(); return;
385 case AudioVolumeDown: emit lessReleased(); return; 402 case AudioVolumeDown: emit lessReleased(); return;
386 case AudioPlayList: mediaPlayerState->setList(); return; 403 case AudioPlayList: mediaPlayerState->setList(); return;
387 } 404 }
388 } 405 }
@@ -458,26 +475,26 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
458 } else { 475 } else {
459// toggleButton(0); 476// toggleButton(0);
460 mediaPlayerState->setPlaying(TRUE); 477 mediaPlayerState->setPlaying(TRUE);
461// toggleButton(0); 478// toggleButton(0);
462 } 479 }
463 } 480 }
464 break; 481 break;
465 case Key_Down: //volume 482 case Key_Down: //volume
466 toggleButton(6); 483// toggleButton(6);
467 emit lessClicked(); 484 emit lessClicked();
468 emit lessReleased(); 485 emit lessReleased();
469 toggleButton(6); 486// toggleButton(6);
470 break; 487 break;
471 case Key_Up: //volume 488 case Key_Up: //volume
472 toggleButton(5); 489// toggleButton(5);
473 emit moreClicked(); 490 emit moreClicked();
474 emit moreReleased(); 491 emit moreReleased();
475 toggleButton(5); 492// toggleButton(5);
476 break; 493 break;
477 case Key_Right: //next in playlist 494 case Key_Right: //next in playlist
478// toggleButton(3); 495// toggleButton(3);
479 mediaPlayerState->setNext(); 496 mediaPlayerState->setNext();
480// toggleButton(3); 497// toggleButton(3);
481 break; 498 break;
482 case Key_Left: // previous in playlist 499 case Key_Left: // previous in playlist
483// toggleButton(4); 500// toggleButton(4);
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index c686741..96bc55c 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -31,54 +31,59 @@
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qframe.h> 32#include <qframe.h>
33 33
34#include <opie/oticker.h> 34#include <opie/oticker.h>
35 35
36class QPixmap; 36class QPixmap;
37 37
38enum AudioButtons { 38enum AudioButtons {
39 AudioPlay, 39 AudioPlay=0,
40 AudioStop, 40 AudioStop,
41 AudioPause,
42 AudioNext, 41 AudioNext,
43 AudioPrevious, 42 AudioPrevious,
44 AudioVolumeUp, 43 AudioVolumeUp,
45 AudioVolumeDown, 44 AudioVolumeDown,
46 AudioLoop, 45 AudioLoop,
47 AudioPlayList 46 AudioPlayList,
47 AudioForward,
48 AudioBack
48}; 49};
49 50
50 51
51//#define USE_DBLBUF 52//#define USE_DBLBUF
52 53
53class AudioWidget : public QWidget { 54class AudioWidget : public QWidget {
54 Q_OBJECT 55 Q_OBJECT
55public: 56public:
56 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 57 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
57 ~AudioWidget(); 58 ~AudioWidget();
58 void setTickerText( const QString &text ) { songInfo.setText( text ); } 59 void setTickerText( const QString &text ) { songInfo.setText( text ); }
59 bool isStreaming; 60 bool isStreaming;
60public slots: 61public slots:
61 void updateSlider( long, long ); 62 void updateSlider( long, long );
62 void sliderPressed( ); 63 void sliderPressed( );
63 void sliderReleased( ); 64 void sliderReleased( );
64 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 65// void setPaused( bool b) { setToggleButton( AudioPause, b ); }
65 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 66 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
66 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 67 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
67 void setPosition( long ); 68 void setPosition( long );
68 void setLength( long ); 69 void setLength( long );
69 void setView( char ); 70 void setView( char );
70 71
71signals: 72signals:
72 void moreClicked(); 73 void moreClicked();
73 void lessClicked(); 74 void lessClicked();
74 void moreReleased(); 75 void moreReleased();
75 void lessReleased(); 76 void lessReleased();
76 void sliderMoved(long); 77 void sliderMoved(long);
78 void forwardClicked();
79 void backClicked();
80 void forwardReleased();
81 void backReleased();
77 82
78protected: 83protected:
79 void doBlank(); 84 void doBlank();
80 void doUnblank(); 85 void doUnblank();
81 void paintEvent( QPaintEvent *pe ); 86 void paintEvent( QPaintEvent *pe );
82 void showEvent( QShowEvent *se ); 87 void showEvent( QShowEvent *se );
83 void resizeEvent( QResizeEvent *re ); 88 void resizeEvent( QResizeEvent *re );
84 void mouseMoveEvent( QMouseEvent *event ); 89 void mouseMoveEvent( QMouseEvent *event );
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index b0963cf..4f3823a 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -101,24 +101,26 @@ void MediaPlayer::setPlaying( bool play ) {
101 if ( currentFile == NULL ) { 101 if ( currentFile == NULL ) {
102 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); 102 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
103 mediaPlayerState->setPlaying( FALSE ); 103 mediaPlayerState->setPlaying( FALSE );
104 return; 104 return;
105 } 105 }
106 106
107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
108 QMessageBox::critical( 0, tr( "File not found"), 108 QMessageBox::critical( 0, tr( "File not found"),
109 tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 109 tr( "The following file was not found: <i>" )
110 + currentFile->file() + "</i>" );
110 mediaPlayerState->setPlaying( FALSE ); 111 mediaPlayerState->setPlaying( FALSE );
111 return; 112 return;
112 } 113 }
113 114
114 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 115 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
115 QMessageBox::critical( 0, tr( "No decoder found"), 116 QMessageBox::critical( 0, tr( "No decoder found"),
116 tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 117 tr( "Sorry, no appropriate decoders found for this file: <i>" )
118 + currentFile->file() + "</i>" );
117 mediaPlayerState->setPlaying( FALSE ); 119 mediaPlayerState->setPlaying( FALSE );
118 return; 120 return;
119 } 121 }
120 122
121 if ( !loopControl->init( currentFile->file() ) ) { 123 if ( !loopControl->init( currentFile->file() ) ) {
122 QMessageBox::critical( 0, tr( "Error opening file"), 124 QMessageBox::critical( 0, tr( "Error opening file"),
123 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); 125 tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
124 mediaPlayerState->setPlaying( FALSE ); 126 mediaPlayerState->setPlaying( FALSE );
@@ -171,29 +173,80 @@ void MediaPlayer::startDecreasingVolume() {
171 AudioDevice::decreaseVolume(); 173 AudioDevice::decreaseVolume();
172} 174}
173 175
174 176
175void MediaPlayer::startIncreasingVolume() { 177void MediaPlayer::startIncreasingVolume() {
176 volumeDirection = +1; 178 volumeDirection = +1;
177 startTimer( 100 ); 179 startTimer( 100 );
178 AudioDevice::increaseVolume(); 180 AudioDevice::increaseVolume();
181
179} 182}
180 183
184bool drawnOnScreenDisplay = FALSE;
185unsigned int onScreenDisplayVolume = 0;
186const int yoff = 110;
181 187
182void MediaPlayer::stopChangingVolume() { 188void MediaPlayer::stopChangingVolume() {
183 killTimers(); 189 killTimers();
190
191 // Get rid of the on-screen display stuff
192 drawnOnScreenDisplay = FALSE;
193 onScreenDisplayVolume = 0;
194 int w = audioUI->width();
195 int h = audioUI->height();
196 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
184} 197}
185 198
186 199
187void MediaPlayer::timerEvent( QTimerEvent * ) { 200void MediaPlayer::timerEvent( QTimerEvent * ) {
201// qDebug("timer");
188 if ( volumeDirection == +1 ) 202 if ( volumeDirection == +1 )
189 AudioDevice::increaseVolume(); 203 AudioDevice::increaseVolume();
190 else if ( volumeDirection == -1 ) 204 else if ( volumeDirection == -1 )
191 AudioDevice::decreaseVolume(); 205 AudioDevice::decreaseVolume();
206
207 // Display an on-screen display volume
208 unsigned int l, r, v; bool m;
209 AudioDevice::getVolume( l, r, m );
210 v = ((l + r) * 11) / (2*0xFFFF);
211
212 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
213// qDebug("returning %d, %d, %d, %d", v, l, r, m);
214 return;
215 }
216
217 int w = audioUI->width();
218 int h = audioUI->height();
219
220 if ( drawnOnScreenDisplay ) {
221 if ( onScreenDisplayVolume > v )
222 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40,
223 (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
224 }
225
226 drawnOnScreenDisplay = TRUE;
227 onScreenDisplayVolume = v;
228
229 QPainter p( audioUI );
230 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
231 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
232
233 QFont f;
234 f.setPixelSize( 20 );
235 f.setBold( TRUE );
236 p.setFont( f );
237 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
238
239 for ( unsigned int i = 0; i < 10; i++ ) {
240 if ( v > i )
241 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
242 else
243 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
244 }
192} 245}
193 246
194void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 247void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
195 switch ( e->key() ) { 248 switch ( e->key() ) {
196////////////////////////////// Zaurus keys 249////////////////////////////// Zaurus keys
197 case Key_Home: 250 case Key_Home:
198 break; 251 break;
199 case Key_F9: //activity 252 case Key_F9: //activity
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 26185c5..1c65599 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -28,16 +28,17 @@ class MediaPlayerDecoder;
28class Config; 28class Config;
29 29
30 30
31class MediaPlayerState : public QObject { 31class MediaPlayerState : public QObject {
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 MediaPlayerState( QObject *parent, const char *name ); 34 MediaPlayerState( QObject *parent, const char *name );
35 ~MediaPlayerState(); 35 ~MediaPlayerState();
36 bool isPaused;
36 37
37 bool isStreaming; 38 bool isStreaming;
38 bool fullscreen() { return isFullscreen; } 39 bool fullscreen() { return isFullscreen; }
39 bool scaled() { return isScaled; } 40 bool scaled() { return isScaled; }
40 bool looping() { return isLooping; } 41 bool looping() { return isLooping; }
41 bool shuffled() { return isShuffled; } 42 bool shuffled() { return isShuffled; }
42 bool playlist() { return usePlaylist; } 43 bool playlist() { return usePlaylist; }
43 bool paused() { return isPaused; } 44 bool paused() { return isPaused; }
@@ -96,17 +97,16 @@ signals:
96 void next(); 97 void next();
97 98
98private: 99private:
99 bool isFullscreen; 100 bool isFullscreen;
100 bool isScaled; 101 bool isScaled;
101 bool isLooping; 102 bool isLooping;
102 bool isShuffled; 103 bool isShuffled;
103 bool usePlaylist; 104 bool usePlaylist;
104 bool isPaused;
105 bool isPlaying; 105 bool isPlaying;
106 long curPosition; 106 long curPosition;
107 long curLength; 107 long curLength;
108 char curView; 108 char curView;
109 109
110 MediaPlayerDecoder *decoder; 110 MediaPlayerDecoder *decoder;
111 MediaPlayerDecoder *libmpeg3decoder; 111 MediaPlayerDecoder *libmpeg3decoder;
112// MediaPlayerDecoder *libwavdecoder; 112// MediaPlayerDecoder *libwavdecoder;