author | simon <simon> | 2002-12-02 20:09:10 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 20:09:10 (UTC) |
commit | e1ef407b16b652755f9c8eefce0f617ec3996998 (patch) (side-by-side diff) | |
tree | 6db64108908f1eee41955caa0e9d7f1d7878e5a8 /noncore/multimedia | |
parent | acfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7 (diff) | |
download | opie-e1ef407b16b652755f9c8eefce0f617ec3996998.zip opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.gz opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.bz2 |
- MediaPlayer no more uses the MediaPlayerState instance as singleton
-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 @@ -21,13 +21,13 @@ int main(int argc, char **argv) { pl.showMaximized(); AudioWidget aw( 0, "audioUI" ); 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 @@ -24,34 +24,33 @@ #include <sys/ioctl.h> 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() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); @@ -71,51 +70,51 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) MediaPlayer::~MediaPlayer() { delete xineControl; 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; if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { //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(); if ( xineControl->getMetaInfo().isEmpty() ) { tickerText = tr( " File: " ) + fileName; @@ -134,41 +133,41 @@ 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(); } } } 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(); } void MediaPlayer::startDecreasingVolume() { @@ -343,12 +342,12 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { break; } } 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 @@ -38,17 +38,18 @@ #include <qframe.h> #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 ); void play(); void next(); @@ -65,11 +66,12 @@ protected: private: bool isBlanked, l, r; int fd, fl; int volumeDirection; XineControl *xineControl; VolumeControl *volControl; + MediaPlayerState &mediaPlayerState; }; #endif // MEDIA_PLAYER_H |