-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 55 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 4 |
3 files changed, 31 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index e951554..24aba6c 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp @@ -23,9 +23,9 @@ int main(int argc, char **argv) { audioUI = &aw; VideoWidget vw( 0, "videoUI" ); videoUI = &vw; a.processEvents(); - MediaPlayer mp( 0, "mediaPlayer" ); + MediaPlayer mp( st, 0, "mediaPlayer" ); a.showMainDocumentWidget(&pl); return a.exec(); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 68bbae9..424259b 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -26,30 +26,29 @@ extern AudioWidget *audioUI; extern VideoWidget *videoUI; extern PlayListWidget *playList; -extern MediaPlayerState *mediaPlayerState; #define FBIOBLANK 0x4611 -MediaPlayer::MediaPlayer( QObject *parent, const char *name ) - : QObject( parent, name ), volumeDirection( 0 ) { +MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) + : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { fd=-1;fl=-1; playList->setCaption( tr( "OpiePlayer: Initializating" ) ); qApp->processEvents(); // QPEApplication::grabKeyboard(); // EVIL connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); - connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); + connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); - connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); + connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); - connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); - connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); - connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); + connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); + connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); + connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); @@ -73,25 +72,25 @@ MediaPlayer::~MediaPlayer() { delete volControl; } void MediaPlayer::pauseCheck( bool b ) { - if ( b && !mediaPlayerState->isPlaying() ) { - mediaPlayerState->setPaused( FALSE ); + if ( b && !mediaPlayerState.isPlaying() ) { + mediaPlayerState.setPaused( FALSE ); } } void MediaPlayer::play() { - mediaPlayerState->setPlaying( FALSE ); - mediaPlayerState->setPlaying( TRUE ); + mediaPlayerState.setPlaying( FALSE ); + mediaPlayerState.setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { return; } - if ( mediaPlayerState->isPaused() ) { - mediaPlayerState->setPaused( FALSE ); + if ( mediaPlayerState.isPaused() ) { + mediaPlayerState.setPaused( FALSE ); return; } QString tickerText, time, fileName; @@ -99,21 +98,21 @@ void MediaPlayer::setPlaying( bool play ) { //if playing in file list.. play in a different way // random and looping settings enabled causes problems here, // since there is no selected file in the playlist, but a selected file in the file list, // so we remember and shutoff - l = mediaPlayerState->isLooping(); + l = mediaPlayerState.isLooping(); if(l) { - mediaPlayerState->setLooping( false ); + mediaPlayerState.setLooping( false ); } - r = mediaPlayerState->isShuffled(); - mediaPlayerState->setShuffled( false ); + r = mediaPlayerState.isShuffled(); + mediaPlayerState.setShuffled( false ); } PlayListWidget::Entry playListEntry = playList->currentEntry(); fileName = playListEntry.name; xineControl->play( playListEntry.file ); - long seconds = mediaPlayerState->length(); + long seconds = mediaPlayerState.length(); time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); if( fileName.left(4) == "http" ) { fileName = QFileInfo( fileName ).baseName(); @@ -136,14 +135,14 @@ void MediaPlayer::setPlaying( bool play ) { void MediaPlayer::prev() { if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist if ( playList->prev() ) { play(); - } else if ( mediaPlayerState->isLooping() ) { + } else if ( mediaPlayerState.isLooping() ) { if ( playList->last() ) { play(); } } else { - mediaPlayerState->setList(); + mediaPlayerState.setList(); } } } @@ -152,21 +151,21 @@ void MediaPlayer::next() { if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist if ( playList->next() ) { play(); - } else if ( mediaPlayerState->isLooping() ) { + } else if ( mediaPlayerState.isLooping() ) { if ( playList->first() ) { play(); } } else { - mediaPlayerState->setList(); + mediaPlayerState.setList(); } } else { //if playing from file list, let's just stop qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); - mediaPlayerState->setPlaying(false); - mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); - if(l) mediaPlayerState->setLooping(l); - if(r) mediaPlayerState->setShuffled(r); + mediaPlayerState.setPlaying(false); + mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); + if(l) mediaPlayerState.setLooping(l); + if(r) mediaPlayerState.setShuffled(r); } qApp->processEvents(); } @@ -345,9 +344,9 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { } void MediaPlayer::cleanUp() {// this happens on closing Config cfg( "OpiePlayer" ); - mediaPlayerState->writeConfig( cfg ); + mediaPlayerState.writeConfig( cfg ); playList->writeDefaultPlaylist( ); // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index de3886e..6aeac7c 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h @@ -40,13 +40,14 @@ #include "xinecontrol.h" class DocLnk; class VolumeControl; +class MediaPlayerState; class MediaPlayer : public QObject { Q_OBJECT public: - MediaPlayer( QObject *parent, const char *name ); + MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); ~MediaPlayer(); private slots: void setPlaying( bool ); void pauseCheck( bool ); @@ -67,8 +68,9 @@ private: int fd, fl; int volumeDirection; XineControl *xineControl; VolumeControl *volControl; + MediaPlayerState &mediaPlayerState; }; #endif // MEDIA_PLAYER_H |