summaryrefslogtreecommitdiff
path: root/noncore
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 /noncore
parentacfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7 (diff)
downloadopie-e1ef407b16b652755f9c8eefce0f617ec3996998.zip
opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.gz
opie-e1ef407b16b652755f9c8eefce0f617ec3996998.tar.bz2
- MediaPlayer no more uses the MediaPlayerState instance as singleton
Diffstat (limited to 'noncore') (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
@@ -24,7 +24,7 @@ int main(int argc, char **argv) {
VideoWidget vw( 0, "videoUI" );
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
@@ -27,13 +27,12 @@
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" ) );
@@ -42,13 +41,13 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name )
// 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() ) );
@@ -74,14 +73,14 @@ 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 );
}
void MediaPlayer::setPlaying( bool play ) {
@@ -89,8 +88,8 @@ void MediaPlayer::setPlaying( bool play ) {
return;
}
- if ( mediaPlayerState->isPaused() ) {
- mediaPlayerState->setPaused( FALSE );
+ if ( mediaPlayerState.isPaused() ) {
+ mediaPlayerState.setPaused( FALSE );
return;
}
@@ -100,19 +99,19 @@ void MediaPlayer::setPlaying( bool play ) {
// 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" ) {
@@ -137,12 +136,12 @@ 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();
}
}
}
@@ -153,19 +152,19 @@ 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();
}
@@ -346,7 +345,7 @@ 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();
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
@@ -41,11 +41,12 @@
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 );
@@ -68,6 +69,7 @@ private:
int volumeDirection;
XineControl *xineControl;
VolumeControl *volControl;
+ MediaPlayerState &mediaPlayerState;
};