-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 76 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 35 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.h | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 59 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.h | 2 |
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 | |||
@@ -34,13 +34,8 @@ | |||
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> |
@@ -49,13 +44,8 @@ | |||
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) |
59 | static const int sound_fragment_shift = 14; | 49 | static const int sound_fragment_shift = 14; |
60 | # else | 50 | # else |
61 | static const int sound_fragment_shift = 16; | 51 | static const int sound_fragment_shift = 16; |
@@ -100,25 +90,8 @@ unsigned int AudioDevicePrivate::rightVolume = 0; | |||
100 | 90 | ||
101 | void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { | 91 | void 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\")"); |
@@ -126,9 +99,8 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume | |||
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 | ||
134 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { | 106 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { |
@@ -141,24 +113,8 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
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 |
@@ -189,9 +145,8 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
189 | } | 145 | } |
190 | 146 | ||
191 | 147 | ||
192 | 148 | ||
193 | |||
194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 149 | AudioDevice::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; |
@@ -265,17 +220,13 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | |||
265 | AudioDevice::~AudioDevice() { | 220 | AudioDevice::~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 | ||
@@ -287,22 +238,8 @@ void AudioDevice::volumeChanged( bool muted ) | |||
287 | 238 | ||
288 | 239 | ||
289 | void AudioDevice::write( char *buffer, unsigned int length ) | 240 | void 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"); |
@@ -337,11 +274,8 @@ unsigned int AudioDevice::bufferSize() const | |||
337 | } | 274 | } |
338 | 275 | ||
339 | unsigned int AudioDevice::canWrite() const | 276 | unsigned 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 ); |
@@ -364,26 +298,16 @@ unsigned int AudioDevice::canWrite() const | |||
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 | ||
372 | int AudioDevice::bytesWritten() { | 305 | int 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 | |||
@@ -145,16 +145,16 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
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 | ||
@@ -362,9 +362,18 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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); |
@@ -374,11 +383,19 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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; |
@@ -462,18 +479,18 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) | |||
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(); |
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 | |||
@@ -35,17 +35,18 @@ | |||
35 | 35 | ||
36 | class QPixmap; | 36 | class QPixmap; |
37 | 37 | ||
38 | enum AudioButtons { | 38 | enum 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 |
@@ -60,9 +61,9 @@ public: | |||
60 | public slots: | 61 | public 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 ); |
@@ -73,8 +74,12 @@ signals: | |||
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 | ||
78 | protected: | 83 | protected: |
79 | void doBlank(); | 84 | void doBlank(); |
80 | void doUnblank(); | 85 | void doUnblank(); |
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 | |||
@@ -105,16 +105,18 @@ void MediaPlayer::setPlaying( bool play ) { | |||
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 | ||
@@ -175,21 +177,72 @@ void MediaPlayer::startDecreasingVolume() { | |||
175 | void MediaPlayer::startIncreasingVolume() { | 177 | void 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 | ||
184 | bool drawnOnScreenDisplay = FALSE; | ||
185 | unsigned int onScreenDisplayVolume = 0; | ||
186 | const int yoff = 110; | ||
181 | 187 | ||
182 | void MediaPlayer::stopChangingVolume() { | 188 | void 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 | ||
187 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 200 | void 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 | ||
194 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 247 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
195 | switch ( e->key() ) { | 248 | switch ( e->key() ) { |
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 | |||
@@ -32,8 +32,9 @@ class MediaPlayerState : public QObject { | |||
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
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; } |
@@ -100,9 +101,8 @@ private: | |||
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; |