-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 | |||
@@ -25,5 +25,5 @@ int main(int argc, char **argv) { | |||
25 | videoUI = &vw; | 25 | videoUI = &vw; |
26 | a.processEvents(); | 26 | a.processEvents(); |
27 | MediaPlayer mp( 0, "mediaPlayer" ); | 27 | MediaPlayer mp( st, 0, "mediaPlayer" ); |
28 | 28 | ||
29 | a.showMainDocumentWidget(&pl); | 29 | 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; | |||
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | extern MediaPlayerState *mediaPlayerState; | ||
31 | 30 | ||
32 | 31 | ||
33 | #define FBIOBLANK 0x4611 | 32 | #define FBIOBLANK 0x4611 |
34 | 33 | ||
35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 34 | MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
36 | : QObject( parent, name ), volumeDirection( 0 ) { | 35 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { |
37 | 36 | ||
38 | fd=-1;fl=-1; | 37 | fd=-1;fl=-1; |
@@ -43,11 +42,11 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | |||
43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
44 | 43 | ||
45 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 44 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
46 | 45 | ||
47 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
48 | 47 | ||
49 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 48 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
50 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 49 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
51 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 50 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
52 | 51 | ||
53 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
@@ -75,12 +74,12 @@ MediaPlayer::~MediaPlayer() { | |||
75 | 74 | ||
76 | void MediaPlayer::pauseCheck( bool b ) { | 75 | void MediaPlayer::pauseCheck( bool b ) { |
77 | if ( b && !mediaPlayerState->isPlaying() ) { | 76 | if ( b && !mediaPlayerState.isPlaying() ) { |
78 | mediaPlayerState->setPaused( FALSE ); | 77 | mediaPlayerState.setPaused( FALSE ); |
79 | } | 78 | } |
80 | } | 79 | } |
81 | 80 | ||
82 | void MediaPlayer::play() { | 81 | void MediaPlayer::play() { |
83 | mediaPlayerState->setPlaying( FALSE ); | 82 | mediaPlayerState.setPlaying( FALSE ); |
84 | mediaPlayerState->setPlaying( TRUE ); | 83 | mediaPlayerState.setPlaying( TRUE ); |
85 | } | 84 | } |
86 | 85 | ||
@@ -90,6 +89,6 @@ void MediaPlayer::setPlaying( bool play ) { | |||
90 | } | 89 | } |
91 | 90 | ||
92 | if ( mediaPlayerState->isPaused() ) { | 91 | if ( mediaPlayerState.isPaused() ) { |
93 | mediaPlayerState->setPaused( FALSE ); | 92 | mediaPlayerState.setPaused( FALSE ); |
94 | return; | 93 | return; |
95 | } | 94 | } |
@@ -101,10 +100,10 @@ void MediaPlayer::setPlaying( bool play ) { | |||
101 | // since there is no selected file in the playlist, but a selected file in the file list, | 100 | // since there is no selected file in the playlist, but a selected file in the file list, |
102 | // so we remember and shutoff | 101 | // so we remember and shutoff |
103 | l = mediaPlayerState->isLooping(); | 102 | l = mediaPlayerState.isLooping(); |
104 | if(l) { | 103 | if(l) { |
105 | mediaPlayerState->setLooping( false ); | 104 | mediaPlayerState.setLooping( false ); |
106 | } | 105 | } |
107 | r = mediaPlayerState->isShuffled(); | 106 | r = mediaPlayerState.isShuffled(); |
108 | mediaPlayerState->setShuffled( false ); | 107 | mediaPlayerState.setShuffled( false ); |
109 | } | 108 | } |
110 | 109 | ||
@@ -113,5 +112,5 @@ void MediaPlayer::setPlaying( bool play ) { | |||
113 | xineControl->play( playListEntry.file ); | 112 | xineControl->play( playListEntry.file ); |
114 | 113 | ||
115 | long seconds = mediaPlayerState->length(); | 114 | long seconds = mediaPlayerState.length(); |
116 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 115 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
117 | 116 | ||
@@ -138,10 +137,10 @@ void MediaPlayer::prev() { | |||
138 | if ( playList->prev() ) { | 137 | if ( playList->prev() ) { |
139 | play(); | 138 | play(); |
140 | } else if ( mediaPlayerState->isLooping() ) { | 139 | } else if ( mediaPlayerState.isLooping() ) { |
141 | if ( playList->last() ) { | 140 | if ( playList->last() ) { |
142 | play(); | 141 | play(); |
143 | } | 142 | } |
144 | } else { | 143 | } else { |
145 | mediaPlayerState->setList(); | 144 | mediaPlayerState.setList(); |
146 | } | 145 | } |
147 | } | 146 | } |
@@ -154,17 +153,17 @@ void MediaPlayer::next() { | |||
154 | if ( playList->next() ) { | 153 | if ( playList->next() ) { |
155 | play(); | 154 | play(); |
156 | } else if ( mediaPlayerState->isLooping() ) { | 155 | } else if ( mediaPlayerState.isLooping() ) { |
157 | if ( playList->first() ) { | 156 | if ( playList->first() ) { |
158 | play(); | 157 | play(); |
159 | } | 158 | } |
160 | } else { | 159 | } else { |
161 | mediaPlayerState->setList(); | 160 | mediaPlayerState.setList(); |
162 | } | 161 | } |
163 | } else { //if playing from file list, let's just stop | 162 | } else { //if playing from file list, let's just stop |
164 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 163 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
165 | mediaPlayerState->setPlaying(false); | 164 | mediaPlayerState.setPlaying(false); |
166 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); | 165 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
167 | if(l) mediaPlayerState->setLooping(l); | 166 | if(l) mediaPlayerState.setLooping(l); |
168 | if(r) mediaPlayerState->setShuffled(r); | 167 | if(r) mediaPlayerState.setShuffled(r); |
169 | } | 168 | } |
170 | qApp->processEvents(); | 169 | qApp->processEvents(); |
@@ -347,5 +346,5 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | |||
347 | void MediaPlayer::cleanUp() {// this happens on closing | 346 | void MediaPlayer::cleanUp() {// this happens on closing |
348 | Config cfg( "OpiePlayer" ); | 347 | Config cfg( "OpiePlayer" ); |
349 | mediaPlayerState->writeConfig( cfg ); | 348 | mediaPlayerState.writeConfig( cfg ); |
350 | playList->writeDefaultPlaylist( ); | 349 | playList->writeDefaultPlaylist( ); |
351 | 350 | ||
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 @@ | |||
42 | class DocLnk; | 42 | class DocLnk; |
43 | class VolumeControl; | 43 | class VolumeControl; |
44 | class MediaPlayerState; | ||
44 | 45 | ||
45 | class MediaPlayer : public QObject { | 46 | class MediaPlayer : public QObject { |
46 | Q_OBJECT | 47 | Q_OBJECT |
47 | public: | 48 | public: |
48 | MediaPlayer( QObject *parent, const char *name ); | 49 | MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); |
49 | ~MediaPlayer(); | 50 | ~MediaPlayer(); |
50 | private slots: | 51 | private slots: |
@@ -69,4 +70,5 @@ private: | |||
69 | XineControl *xineControl; | 70 | XineControl *xineControl; |
70 | VolumeControl *volControl; | 71 | VolumeControl *volControl; |
72 | MediaPlayerState &mediaPlayerState; | ||
71 | }; | 73 | }; |
72 | 74 | ||