author | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
commit | 657eeb18141838eeb0d18351a6755d7fa686f9d9 (patch) (unidiff) | |
tree | 049c19f776543aee296ce0cd3a1fde8c37ec374b /noncore/multimedia/opieplayer2/mediaplayer.cpp | |
parent | bba0335bbea81519beafb7fec1979a0abbd8a7ea (diff) | |
download | opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.zip opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.gz opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.bz2 |
mediadetect no longer needed, also beginning of id3 etc tag info support along with some other small fixes
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 553e3c1..8da7f73 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -27,25 +27,25 @@ | |||
27 | extern AudioWidget *audioUI; | 27 | extern AudioWidget *audioUI; |
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | extern MediaPlayerState *mediaPlayerState; | 30 | extern MediaPlayerState *mediaPlayerState; |
31 | 31 | ||
32 | 32 | ||
33 | #define FBIOBLANK 0x4611 | 33 | #define FBIOBLANK 0x4611 |
34 | 34 | ||
35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
36 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 36 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
37 | 37 | ||
38 | playList->setCaption(tr("OpiePlayer: Initializating")); | 38 | playList->setCaption(tr("OpiePlayer: Initializating")); |
39 | 39 | ||
40 | qApp->processEvents(); | 40 | qApp->processEvents(); |
41 | // QPEApplication::grabKeyboard(); // EVIL | 41 | // QPEApplication::grabKeyboard(); // EVIL |
42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
43 | 43 | ||
44 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 44 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
45 | 45 | ||
46 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
47 | 47 | ||
48 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 48 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
49 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 49 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
50 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
51 | 51 | ||
@@ -91,55 +91,68 @@ void MediaPlayer::setPlaying( bool play ) { | |||
91 | } | 91 | } |
92 | 92 | ||
93 | QString tickerText, time, fileName; | 93 | QString tickerText, time, fileName; |
94 | if( playList->whichList() == 0 ) { //check for filelist | 94 | if( playList->whichList() == 0 ) { //check for filelist |
95 | const DocLnk *playListCurrent = playList->current(); | 95 | const DocLnk *playListCurrent = playList->current(); |
96 | if ( playListCurrent != NULL ) { | 96 | if ( playListCurrent != NULL ) { |
97 | currentFile = playListCurrent; | 97 | currentFile = playListCurrent; |
98 | } | 98 | } |
99 | xineControl->play( currentFile->file() ); | 99 | xineControl->play( currentFile->file() ); |
100 | fileName = currentFile->name(); | 100 | fileName = currentFile->name(); |
101 | long seconds = mediaPlayerState->length();// | 101 | long seconds = mediaPlayerState->length();// |
102 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 102 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
103 | qDebug(time); | 103 | //qDebug(time); |
104 | 104 | ||
105 | } else { //if playing in file list.. play in a different way | 105 | } else { |
106 | // random and looping settings enabled causes problems here, | 106 | //if playing in file list.. play in a different way |
107 | // since there is no selected file in the playlist, but a selected file in the file list, | 107 | // random and looping settings enabled causes problems here, |
108 | // so we remember and shutoff | 108 | // since there is no selected file in the playlist, but a selected file in the file list, |
109 | // so we remember and shutoff | ||
109 | l = mediaPlayerState->looping(); | 110 | l = mediaPlayerState->looping(); |
110 | if(l) | 111 | if(l) { |
111 | mediaPlayerState->setLooping( false ); | 112 | mediaPlayerState->setLooping( false ); |
113 | } | ||
112 | r = mediaPlayerState->shuffled(); | 114 | r = mediaPlayerState->shuffled(); |
113 | mediaPlayerState->setShuffled(false); | 115 | mediaPlayerState->setShuffled( false ); |
114 | 116 | ||
115 | fileName = playList->currentFileListPathName(); | 117 | fileName = playList->currentFileListPathName(); |
116 | xineControl->play( fileName); | 118 | xineControl->play( fileName ); |
117 | long seconds = mediaPlayerState->length();// | 119 | long seconds = mediaPlayerState->length(); |
118 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 120 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
119 | qDebug(time); | 121 | //qDebug(time); |
120 | if( fileName.left(4) != "http" ) | 122 | if( fileName.left(4) != "http" ) { |
121 | fileName = QFileInfo( fileName).baseName(); | 123 | fileName = QFileInfo( fileName ).baseName(); |
124 | } | ||
122 | 125 | ||
123 | } | 126 | } |
124 | if( fileName.left(4) == "http" ) | 127 | |
125 | tickerText= tr( " File: " ) + fileName; | 128 | if( fileName.left(4) == "http" ) { |
126 | else | 129 | if ( xineControl->getMetaInfo().isEmpty() ) { |
127 | tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time; | 130 | tickerText = tr( " File: " ) + fileName; |
131 | } else { | ||
132 | tickerText = xineControl->getMetaInfo(); | ||
133 | } | ||
134 | } else { | ||
135 | if ( xineControl->getMetaInfo().isEmpty() ) { | ||
136 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | ||
137 | } else { | ||
138 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | ||
139 | } | ||
140 | } | ||
128 | audioUI->setTickerText( tickerText ); | 141 | audioUI->setTickerText( tickerText ); |
129 | } | 142 | } |
130 | 143 | ||
131 | 144 | ||
132 | void MediaPlayer::prev() { | 145 | void MediaPlayer::prev() { |
133 | if(playList->whichList() == 0) { //if using the playlist | 146 | if( playList->whichList() == 0 ) { //if using the playlist |
134 | if ( playList->prev() ) { | 147 | if ( playList->prev() ) { |
135 | play(); | 148 | play(); |
136 | } else if ( mediaPlayerState->looping() ) { | 149 | } else if ( mediaPlayerState->looping() ) { |
137 | if ( playList->last() ) { | 150 | if ( playList->last() ) { |
138 | play(); | 151 | play(); |
139 | } | 152 | } |
140 | } else { | 153 | } else { |
141 | mediaPlayerState->setList(); | 154 | mediaPlayerState->setList(); |
142 | } | 155 | } |
143 | } | 156 | } |
144 | } | 157 | } |
145 | 158 | ||
@@ -183,103 +196,103 @@ void MediaPlayer::startIncreasingVolume() { | |||
183 | 196 | ||
184 | bool drawnOnScreenDisplay = FALSE; | 197 | bool drawnOnScreenDisplay = FALSE; |
185 | unsigned int onScreenDisplayVolume = 0; | 198 | unsigned int onScreenDisplayVolume = 0; |
186 | const int yoff = 110; | 199 | const int yoff = 110; |
187 | 200 | ||
188 | void MediaPlayer::stopChangingVolume() { | 201 | void MediaPlayer::stopChangingVolume() { |
189 | killTimers(); | 202 | killTimers(); |
190 | // Get rid of the on-screen display stuff | 203 | // Get rid of the on-screen display stuff |
191 | drawnOnScreenDisplay = FALSE; | 204 | drawnOnScreenDisplay = FALSE; |
192 | onScreenDisplayVolume = 0; | 205 | onScreenDisplayVolume = 0; |
193 | int w=0; | 206 | int w=0; |
194 | int h=0; | 207 | int h=0; |
195 | if( !xineControl->hasVideo()) { | 208 | if( !xineControl->hasVideo() ) { |
196 | w = audioUI->width(); | 209 | w = audioUI->width(); |
197 | h = audioUI->height(); | 210 | h = audioUI->height(); |
198 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 211 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
199 | } else { | 212 | } else { |
200 | w = videoUI->width(); | 213 | w = videoUI->width(); |
201 | h = videoUI->height(); | 214 | h = videoUI->height(); |
202 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 215 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
203 | } | 216 | } |
204 | } | 217 | } |
205 | 218 | ||
206 | 219 | ||
207 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 220 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
208 | if ( volumeDirection == +1 ) { | 221 | if ( volumeDirection == +1 ) { |
209 | volControl->incVol(2); | 222 | volControl->incVol( 2 ); |
210 | } else if ( volumeDirection == -1 ) { | 223 | } else if ( volumeDirection == -1 ) { |
211 | volControl->decVol(2); | 224 | volControl->decVol( 2 ); |
212 | } | 225 | } |
213 | 226 | ||
214 | 227 | ||
215 | // TODO FIXME | 228 | // TODO FIXME |
216 | // huh?? | 229 | // huh?? |
217 | unsigned int v= 0; | 230 | unsigned int v= 0; |
218 | v = volControl->volume(); | 231 | v = volControl->volume(); |
219 | v = v / 10; | 232 | v = v / 10; |
220 | 233 | ||
221 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 234 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
222 | return; | 235 | return; |
223 | } | 236 | } |
224 | 237 | ||
225 | int w=0; int h=0; | 238 | int w=0; int h=0; |
226 | if( !xineControl->hasVideo()) { | 239 | if( !xineControl->hasVideo() ) { |
227 | w = audioUI->width(); | 240 | w = audioUI->width(); |
228 | h = audioUI->height(); | 241 | h = audioUI->height(); |
229 | 242 | ||
230 | if ( drawnOnScreenDisplay ) { | 243 | if ( drawnOnScreenDisplay ) { |
231 | if ( onScreenDisplayVolume > v ) { | 244 | if ( onScreenDisplayVolume > v ) { |
232 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 245 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
233 | } | 246 | } |
234 | } | 247 | } |
235 | drawnOnScreenDisplay = TRUE; | 248 | drawnOnScreenDisplay = TRUE; |
236 | onScreenDisplayVolume = v; | 249 | onScreenDisplayVolume = v; |
237 | QPainter p( audioUI ); | 250 | QPainter p( audioUI ); |
238 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 251 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
239 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 252 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
240 | 253 | ||
241 | QFont f; | 254 | QFont f; |
242 | f.setPixelSize( 20 ); | 255 | f.setPixelSize( 20 ); |
243 | f.setBold( TRUE ); | 256 | f.setBold( TRUE ); |
244 | p.setFont( f ); | 257 | p.setFont( f ); |
245 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 258 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
246 | 259 | ||
247 | for ( unsigned int i = 0; i < 10; i++ ) { | 260 | for ( unsigned int i = 0; i < 10; i++ ) { |
248 | if ( v > i ) { | 261 | if ( v > i ) { |
249 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 262 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
250 | } else { | 263 | } else { |
251 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 264 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
252 | } | 265 | } |
253 | } | 266 | } |
254 | } else { | 267 | } else { |
255 | w = videoUI->width(); | 268 | w = videoUI->width(); |
256 | h = videoUI->height(); | 269 | h = videoUI->height(); |
257 | 270 | ||
258 | if ( drawnOnScreenDisplay ) { | 271 | if ( drawnOnScreenDisplay ) { |
259 | if ( onScreenDisplayVolume > v ) { | 272 | if ( onScreenDisplayVolume > v ) { |
260 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 273 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
261 | } | 274 | } |
262 | } | 275 | } |
263 | drawnOnScreenDisplay = TRUE; | 276 | drawnOnScreenDisplay = TRUE; |
264 | onScreenDisplayVolume = v; | 277 | onScreenDisplayVolume = v; |
265 | QPainter p( videoUI ); | 278 | QPainter p( videoUI ); |
266 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 279 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
267 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 280 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
268 | 281 | ||
269 | QFont f; | 282 | QFont f; |
270 | f.setPixelSize( 20 ); | 283 | f.setPixelSize( 20 ); |
271 | f.setBold( TRUE ); | 284 | f.setBold( TRUE ); |
272 | p.setFont( f ); | 285 | p.setFont( f ); |
273 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 286 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
274 | 287 | ||
275 | for ( unsigned int i = 0; i < 10; i++ ) { | 288 | for ( unsigned int i = 0; i < 10; i++ ) { |
276 | if ( v > i ) { | 289 | if ( v > i ) { |
277 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 290 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
278 | } else { | 291 | } else { |
279 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 292 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
280 | } | 293 | } |
281 | } | 294 | } |
282 | } | 295 | } |
283 | } | 296 | } |
284 | 297 | ||
285 | 298 | ||
@@ -318,16 +331,16 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | |||
318 | break; | 331 | break; |
319 | case Key_F13: //mail | 332 | case Key_F13: //mail |
320 | qDebug("Blank here"); | 333 | qDebug("Blank here"); |
321 | // mediaPlayerState->toggleBlank(); | 334 | // mediaPlayerState->toggleBlank(); |
322 | break; | 335 | break; |
323 | } | 336 | } |
324 | } | 337 | } |
325 | 338 | ||
326 | void MediaPlayer::cleanUp() {// this happens on closing | 339 | void MediaPlayer::cleanUp() {// this happens on closing |
327 | Config cfg( "OpiePlayer" ); | 340 | Config cfg( "OpiePlayer" ); |
328 | mediaPlayerState->writeConfig( cfg ); | 341 | mediaPlayerState->writeConfig( cfg ); |
329 | playList->writeConfig( cfg ); | 342 | playList->writeConfig( cfg ); |
330 | 343 | ||
331 | // QPEApplication::grabKeyboard(); | 344 | // QPEApplication::grabKeyboard(); |
332 | // QPEApplication::ungrabKeyboard(); | 345 | // QPEApplication::ungrabKeyboard(); |
333 | } | 346 | } |