summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 20:09:10 (UTC)
committer simon <simon>2002-12-02 20:09:10 (UTC)
commite1ef407b16b652755f9c8eefce0f617ec3996998 (patch) (side-by-side diff)
tree6db64108908f1eee41955caa0e9d7f1d7878e5a8
parentacfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7 (diff)
downloadopie-e1ef407b16b652755f9c8eefce0f617ec3996998.zip
opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.gz
opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.bz2
- MediaPlayer no more uses the MediaPlayerState instance as singleton
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp55
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h4
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
@@ -25,5 +25,5 @@ int main(int argc, char **argv) {
videoUI = &vw;
a.processEvents();
- MediaPlayer mp( 0, "mediaPlayer" );
+ MediaPlayer mp( st, 0, "mediaPlayer" );
a.showMainDocumentWidget(&pl);
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
@@ -28,11 +28,10 @@ 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;
@@ -43,11 +42,11 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name )
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() ) );
@@ -75,12 +74,12 @@ MediaPlayer::~MediaPlayer() {
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 );
}
@@ -90,6 +89,6 @@ void MediaPlayer::setPlaying( bool play ) {
}
- if ( mediaPlayerState->isPaused() ) {
- mediaPlayerState->setPaused( FALSE );
+ if ( mediaPlayerState.isPaused() ) {
+ mediaPlayerState.setPaused( FALSE );
return;
}
@@ -101,10 +100,10 @@ void MediaPlayer::setPlaying( bool play ) {
// 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 );
}
@@ -113,5 +112,5 @@ void MediaPlayer::setPlaying( bool play ) {
xineControl->play( playListEntry.file );
- long seconds = mediaPlayerState->length();
+ long seconds = mediaPlayerState.length();
time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
@@ -138,10 +137,10 @@ void MediaPlayer::prev() {
if ( playList->prev() ) {
play();
- } else if ( mediaPlayerState->isLooping() ) {
+ } else if ( mediaPlayerState.isLooping() ) {
if ( playList->last() ) {
play();
}
} else {
- mediaPlayerState->setList();
+ mediaPlayerState.setList();
}
}
@@ -154,17 +153,17 @@ void MediaPlayer::next() {
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();
@@ -347,5 +346,5 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
void MediaPlayer::cleanUp() {// this happens on closing
Config cfg( "OpiePlayer" );
- mediaPlayerState->writeConfig( cfg );
+ mediaPlayerState.writeConfig( cfg );
playList->writeDefaultPlaylist( );
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
@@ -42,9 +42,10 @@
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:
@@ -69,4 +70,5 @@ private:
XineControl *xineControl;
VolumeControl *volControl;
+ MediaPlayerState &mediaPlayerState;
};