author | llornkcor <llornkcor> | 2002-11-04 00:41:07 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-04 00:41:07 (UTC) |
commit | 08fdebd78a4266642a7bdb2b1ead6e306bda64ad (patch) (side-by-side diff) | |
tree | 8266160d575107b710457c3dfcd84e415268a92d /core | |
parent | dc44b0babe9ffa7b29cc6269596703bab8edf6ab (diff) | |
download | opie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.zip opie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.tar.gz opie-08fdebd78a4266642a7bdb2b1ead6e306bda64ad.tar.bz2 |
various
-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 | 57 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.h | 2 |
5 files changed, 91 insertions, 92 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 @@ -37,7 +37,2 @@ -// #ifdef Q_WS_WIN -// #include <windows.h> -// #include <mmsystem.h> -// #include <mmreg.h> -// #endif #if defined(Q_WS_X11) || defined(Q_WS_QWS) @@ -52,7 +47,2 @@ -// #if defined(Q_OS_WIN32) -// static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; -// static const int timerResolutionMilliSeconds = 30; -// static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; -// #else # if defined(QT_QWS_IPAQ) @@ -103,19 +93,2 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume unsigned int volume; -// #ifdef Q_OS_WIN32 -// HWAVEOUT handle; -// WAVEFORMATEX formatData; -// formatData.cbSize = sizeof(WAVEFORMATEX); -// formatData.wFormatTag = WAVE_FORMAT_PCM; -// formatData.nAvgBytesPerSec = 4 * 44000; -// formatData.nBlockAlign = 4; -// formatData.nChannels = 2; -// formatData.nSamplesPerSec = 44000; -// formatData.wBitsPerSample = 16; -// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); -// if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) -// // qDebug( "get volume of audio device failed" ); -// waveOutClose( handle ); -// leftVolume = volume & 0xFFFF; -// rightVolume = volume >> 16; -// #else int mixerHandle = open( "/dev/mixer", O_RDWR ); @@ -129,3 +102,2 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume rightVolume = ((volume & 0xFF00) << 8) / 101; -//#endif } @@ -144,18 +116,2 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, } -// #ifdef Q_OS_WIN32 -// HWAVEOUT handle; -// WAVEFORMATEX formatData; -// formatData.cbSize = sizeof(WAVEFORMATEX); -// formatData.wFormatTag = WAVE_FORMAT_PCM; -// formatData.nAvgBytesPerSec = 4 * 44000; -// formatData.nBlockAlign = 4; -// formatData.nChannels = 2; -// formatData.nSamplesPerSec = 44000; -// formatData.wBitsPerSample = 16; -// waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); -// unsigned int volume = (rightVolume << 16) | leftVolume; -// if ( waveOutSetVolume( handle, volume ) ) -// // qDebug( "set volume of audio device failed" ); -// waveOutClose( handle ); -// #else // Volume can be from 0 to 100 which is 101 distinct values @@ -192,3 +148,2 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, - AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { @@ -268,5 +223,2 @@ AudioDevice::~AudioDevice() { -// #ifdef Q_OS_WIN32 -// waveOutClose( (HWAVEOUT)d->handle ); -// #else # ifndef KEEP_DEVICE_OPEN @@ -276,3 +228,2 @@ AudioDevice::~AudioDevice() { delete d; -//#endif QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; @@ -290,16 +241,2 @@ void AudioDevice::write( char *buffer, unsigned int length ) { -// #ifdef Q_OS_WIN32 -// // returns immediately and (to be implemented) emits completedIO() when finished writing -// WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); -// // maybe the buffer should be copied so that this fool proof, but its a performance hit -// lpWaveHdr->lpData = buffer; -// lpWaveHdr->dwBufferLength = length; -// lpWaveHdr->dwFlags = 0L; -// lpWaveHdr->dwLoops = 0L; -// waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); -// // waveOutWrite returns immediately. the data is sent in the background. -// if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) -// qDebug( "failed to write block to audio device" ); -// // emit completedIO(); -// #else int t = ::write( d->handle, buffer, length ); @@ -340,5 +277,2 @@ unsigned int AudioDevice::canWrite() const { -// #ifdef Q_OS_WIN32 -// return bufferSize(); // Any better? -// #else audio_buf_info info; @@ -367,3 +301,2 @@ unsigned int AudioDevice::canWrite() const } -//#endif } @@ -372,10 +305,2 @@ unsigned int AudioDevice::canWrite() const int AudioDevice::bytesWritten() { -// #ifdef Q_OS_WIN32 -// MMTIME pmmt = { TIME_BYTES, 0 }; -// if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { -// qDebug( "failed to get audio device position" ); -// return -1; -// } -// return pmmt.u.cb; -// #else int buffered = 0; @@ -386,3 +311,2 @@ int AudioDevice::bytesWritten() { return buffered; -//#endif } 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 @@ -148,3 +148,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); - connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); +// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); @@ -155,3 +155,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : setLooping( mediaPlayerState->fullscreen() ); - setPaused( mediaPlayerState->paused() ); +// setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); @@ -365,3 +365,12 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { return; - case AudioVolumeDown: emit lessClicked(); return; + case AudioVolumeDown: + qDebug("less clicked"); + emit lessClicked(); + return; + case AudioForward: + emit forwardClicked(); + return; + case AudioBack: + emit backClicked(); + return; } @@ -377,5 +386,13 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { switch (i) { - case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; + case AudioPlay: + if( mediaPlayerState->isPaused ) { + mediaPlayerState->setPaused( FALSE ); + return; + } else if( !mediaPlayerState->isPaused ) { + mediaPlayerState->setPaused( TRUE ); + return; + } +// case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; case AudioStop: mediaPlayerState->setPlaying(FALSE); return; - case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; +// case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; @@ -465,12 +482,12 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) case Key_Down: //volume - toggleButton(6); +// toggleButton(6); emit lessClicked(); emit lessReleased(); - toggleButton(6); +// toggleButton(6); break; case Key_Up: //volume - toggleButton(5); +// toggleButton(5); emit moreClicked(); emit moreReleased(); - toggleButton(5); +// toggleButton(5); break; 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 @@ -38,5 +38,4 @@ class QPixmap; enum AudioButtons { - AudioPlay, + AudioPlay=0, AudioStop, - AudioPause, AudioNext, @@ -46,3 +45,5 @@ enum AudioButtons { AudioLoop, - AudioPlayList + AudioPlayList, + AudioForward, + AudioBack }; @@ -63,3 +64,3 @@ public slots: void sliderReleased( ); - void setPaused( bool b) { setToggleButton( AudioPause, b ); } +// void setPaused( bool b) { setToggleButton( AudioPause, b ); } void setLooping( bool b) { setToggleButton( AudioLoop, b ); } @@ -76,2 +77,6 @@ signals: void sliderMoved(long); + void forwardClicked(); + void backClicked(); + void forwardReleased(); + void backReleased(); 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 @@ -108,3 +108,4 @@ void MediaPlayer::setPlaying( bool play ) { QMessageBox::critical( 0, tr( "File not found"), - tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); + tr( "The following file was not found: <i>" ) + + currentFile->file() + "</i>" ); mediaPlayerState->setPlaying( FALSE ); @@ -115,3 +116,4 @@ void MediaPlayer::setPlaying( bool play ) { QMessageBox::critical( 0, tr( "No decoder found"), - tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); + tr( "Sorry, no appropriate decoders found for this file: <i>" ) + + currentFile->file() + "</i>" ); mediaPlayerState->setPlaying( FALSE ); @@ -178,4 +180,8 @@ void MediaPlayer::startIncreasingVolume() { AudioDevice::increaseVolume(); + } +bool drawnOnScreenDisplay = FALSE; +unsigned int onScreenDisplayVolume = 0; +const int yoff = 110; @@ -183,2 +189,9 @@ void MediaPlayer::stopChangingVolume() { killTimers(); + + // Get rid of the on-screen display stuff + drawnOnScreenDisplay = FALSE; + onScreenDisplayVolume = 0; + int w = audioUI->width(); + int h = audioUI->height(); + audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } @@ -187,2 +200,3 @@ void MediaPlayer::stopChangingVolume() { void MediaPlayer::timerEvent( QTimerEvent * ) { +// qDebug("timer"); if ( volumeDirection == +1 ) @@ -191,2 +205,41 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { AudioDevice::decreaseVolume(); + + // Display an on-screen display volume + unsigned int l, r, v; bool m; + AudioDevice::getVolume( l, r, m ); + v = ((l + r) * 11) / (2*0xFFFF); + + if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { +// qDebug("returning %d, %d, %d, %d", v, l, r, m); + return; + } + + int w = audioUI->width(); + int h = audioUI->height(); + + if ( drawnOnScreenDisplay ) { + if ( onScreenDisplayVolume > v ) + audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, + (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); + } + + drawnOnScreenDisplay = TRUE; + onScreenDisplayVolume = v; + + QPainter p( audioUI ); + p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); + p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); + + QFont f; + f.setPixelSize( 20 ); + f.setBold( TRUE ); + p.setFont( f ); + p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); + + for ( unsigned int i = 0; i < 10; i++ ) { + if ( v > i ) + p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); + else + p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); + } } 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 @@ -35,2 +35,3 @@ public: ~MediaPlayerState(); + bool isPaused; @@ -103,3 +104,2 @@ private: bool usePlaylist; - bool isPaused; bool isPlaying; |