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
@@ -19,16 +19,16 @@ int main(int argc, char **argv) {
PlayListWidget pl( 0, "playList" );
playList = &pl;
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
@@ -22,38 +22,37 @@
#include <linux/fb.h>
#include <sys/file.h>
#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() ) );
connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
@@ -69,55 +68,55 @@ 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;
} else {
tickerText = xineControl->getMetaInfo();
@@ -132,45 +131,45 @@ void MediaPlayer::setPlaying( bool play ) {
audioUI->setTickerText( tickerText );
}
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() {
volumeDirection = -1;
startTimer( 100 );
@@ -341,14 +340,14 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
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
@@ -36,21 +36,22 @@
#include <qmainwindow.h>
#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();
void prev();
void startIncreasingVolume();
@@ -63,13 +64,14 @@ protected:
void timerEvent( QTimerEvent *e );
void keyReleaseEvent( QKeyEvent *e);
private:
bool isBlanked, l, r;
int fd, fl;
int volumeDirection;
XineControl *xineControl;
VolumeControl *volControl;
+ MediaPlayerState &mediaPlayerState;
};
#endif // MEDIA_PLAYER_H