Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5411a64..8d8e4e5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -8,12 +8,13 @@ #include <qwidgetstack.h> #include <qfile.h> #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" +#include "volumecontrol.h" #include "mediaplayerstate.h" extern AudioWidget *audioUI; @@ -36,15 +37,19 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); + volControl = new VolumeControl; + } MediaPlayer::~MediaPlayer() { + delete xineControl; + delete volControl; } void MediaPlayer::pauseCheck( bool b ) { // Only pause if playing if ( b && !mediaPlayerState->playing() ) { mediaPlayerState->setPaused( FALSE ); @@ -68,13 +73,13 @@ void MediaPlayer::setPlaying( bool play ) { } const DocLnk *playListCurrent = playList->current(); if ( playListCurrent != NULL ) { currentFile = playListCurrent; } - + xineControl->play( currentFile->file() ); xineControl->length(); long seconds = mediaPlayerState->length();// QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); qDebug(time); @@ -89,13 +94,13 @@ void MediaPlayer::setPlaying( bool play ) { // if ( !fileInfo.isEmpty() ) // tickerText += ", " + fileInfo; // audioUI->setTickerText( tickerText + "." ); audioUI->setTickerText( currentFile->file( ) ); - + } void MediaPlayer::prev() { if ( playList->prev() ) { play(); @@ -122,22 +127,20 @@ void MediaPlayer::next() { } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); - // da kommt demnächst osound denk ich mal - /////////////////////////// lets just move those change volume here - // AudioDevice::decreaseVolume(); + volControl->decVol(2); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); - // AudioDevice::increaseVolume(); + volControl->incVol(2); } bool drawnOnScreenDisplay = FALSE; unsigned int onScreenDisplayVolume = 0; const int yoff = 110; @@ -151,33 +154,35 @@ void MediaPlayer::stopChangingVolume() { int h = audioUI->height(); audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } void MediaPlayer::timerEvent( QTimerEvent * ) { - // if ( volumeDirection == +1 ) - // AudioDevice::increaseVolume(); - // else if ( volumeDirection == -1 ) - // AudioDevice::decreaseVolume(); + if ( volumeDirection == +1 ) { + volControl->incVol(2); + } else if ( volumeDirection == -1 ) { + volControl->decVol(2); + } -// Display an on-screen display volume - unsigned int l, r, v; bool m; -// TODO FIXME -// AudioDevice::getVolume( l, r, m ); -// v = ((l + r) * 11) / (2*0xFFFF); + // TODO FIXME + int v; + v = volControl->getVolume(); + v = v / 10; - if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) - return; + if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { + 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 ); + 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 ); @@ -188,16 +193,17 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { 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 ); + 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 ); + } } } void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys |