Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 120 |
1 files changed, 69 insertions, 51 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index c230d6f..bbc60dd 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -28,16 +28,15 @@ | |||
28 | 28 | ||
29 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
30 | 30 | ||
31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
33 | 33 | ||
34 | audioUI = 0; | 34 | m_audioUI = 0; |
35 | videoUI = 0; | 35 | m_videoUI = 0; |
36 | xineControl = 0; | 36 | m_xineControl = 0; |
37 | recreateAudioAndVideoWidgets(); | ||
38 | 37 | ||
39 | fd=-1;fl=-1; | 38 | fd=-1;fl=-1; |
40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 39 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
41 | 40 | ||
42 | qApp->processEvents(); | 41 | qApp->processEvents(); |
43 | // QPEApplication::grabKeyboard(); // EVIL | 42 | // QPEApplication::grabKeyboard(); // EVIL |
@@ -57,15 +56,15 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
57 | cfg.setGroup("PlayList"); | 56 | cfg.setGroup("PlayList"); |
58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 57 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 58 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
60 | } | 59 | } |
61 | 60 | ||
62 | MediaPlayer::~MediaPlayer() { | 61 | MediaPlayer::~MediaPlayer() { |
63 | delete xineControl; | 62 | delete m_xineControl; |
64 | delete audioUI; | 63 | delete m_audioUI; |
65 | delete videoUI; | 64 | delete m_videoUI; |
66 | delete volControl; | 65 | delete volControl; |
67 | } | 66 | } |
68 | 67 | ||
69 | void MediaPlayer::pauseCheck( bool b ) { | 68 | void MediaPlayer::pauseCheck( bool b ) { |
70 | if ( b && !mediaPlayerState.isPlaying() ) { | 69 | if ( b && !mediaPlayerState.isPlaying() ) { |
71 | mediaPlayerState.setPaused( FALSE ); | 70 | mediaPlayerState.setPaused( FALSE ); |
@@ -100,32 +99,32 @@ void MediaPlayer::setPlaying( bool play ) { | |||
100 | r = mediaPlayerState.isShuffled(); | 99 | r = mediaPlayerState.isShuffled(); |
101 | mediaPlayerState.setShuffled( false ); | 100 | mediaPlayerState.setShuffled( false ); |
102 | } | 101 | } |
103 | 102 | ||
104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 103 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
105 | fileName = playListEntry.name; | 104 | fileName = playListEntry.name; |
106 | xineControl->play( playListEntry.file ); | 105 | xineControl()->play( playListEntry.file ); |
107 | 106 | ||
108 | long seconds = mediaPlayerState.length(); | 107 | long seconds = mediaPlayerState.length(); |
109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 108 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
110 | 109 | ||
111 | if( fileName.left(4) == "http" ) { | 110 | if( fileName.left(4) == "http" ) { |
112 | fileName = QFileInfo( fileName ).baseName(); | 111 | fileName = QFileInfo( fileName ).baseName(); |
113 | if ( xineControl->getMetaInfo().isEmpty() ) { | 112 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
114 | tickerText = tr( " File: " ) + fileName; | 113 | tickerText = tr( " File: " ) + fileName; |
115 | } else { | 114 | } else { |
116 | tickerText = xineControl->getMetaInfo(); | 115 | tickerText = xineControl()->getMetaInfo(); |
117 | } | 116 | } |
118 | } else { | 117 | } else { |
119 | if ( xineControl->getMetaInfo().isEmpty() ) { | 118 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 119 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
121 | } else { | 120 | } else { |
122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 121 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
123 | } | 122 | } |
124 | } | 123 | } |
125 | audioUI->setTickerText( tickerText ); | 124 | audioUI()->setTickerText( tickerText ); |
126 | } | 125 | } |
127 | 126 | ||
128 | 127 | ||
129 | void MediaPlayer::prev() { | 128 | void MediaPlayer::prev() { |
130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 129 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
131 | if ( playList.prev() ) { | 130 | if ( playList.prev() ) { |
@@ -186,20 +185,20 @@ void MediaPlayer::stopChangingVolume() { | |||
186 | killTimers(); | 185 | killTimers(); |
187 | // Get rid of the on-screen display stuff | 186 | // Get rid of the on-screen display stuff |
188 | drawnOnScreenDisplay = FALSE; | 187 | drawnOnScreenDisplay = FALSE; |
189 | onScreenDisplayVolume = 0; | 188 | onScreenDisplayVolume = 0; |
190 | int w=0; | 189 | int w=0; |
191 | int h=0; | 190 | int h=0; |
192 | if( !xineControl->hasVideo() ) { | 191 | if( !xineControl()->hasVideo() ) { |
193 | w = audioUI->width(); | 192 | w = audioUI()->width(); |
194 | h = audioUI->height(); | 193 | h = audioUI()->height(); |
195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 194 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
196 | } else { | 195 | } else { |
197 | w = videoUI->width(); | 196 | w = videoUI()->width(); |
198 | h = videoUI->height(); | 197 | h = videoUI()->height(); |
199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 198 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
200 | } | 199 | } |
201 | } | 200 | } |
202 | 201 | ||
203 | 202 | ||
204 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 203 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
205 | if ( volumeDirection == +1 ) { | 204 | if ( volumeDirection == +1 ) { |
@@ -217,24 +216,24 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
217 | 216 | ||
218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 217 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
219 | return; | 218 | return; |
220 | } | 219 | } |
221 | 220 | ||
222 | int w=0; int h=0; | 221 | int w=0; int h=0; |
223 | if( !xineControl->hasVideo() ) { | 222 | if( !xineControl()->hasVideo() ) { |
224 | w = audioUI->width(); | 223 | w = audioUI()->width(); |
225 | h = audioUI->height(); | 224 | h = audioUI()->height(); |
226 | 225 | ||
227 | if ( drawnOnScreenDisplay ) { | 226 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 227 | if ( onScreenDisplayVolume > v ) { |
229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 228 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
230 | } | 229 | } |
231 | } | 230 | } |
232 | drawnOnScreenDisplay = TRUE; | 231 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 232 | onScreenDisplayVolume = v; |
234 | QPainter p( audioUI ); | 233 | QPainter p( audioUI() ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 234 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 236 | ||
238 | QFont f; | 237 | QFont f; |
239 | f.setPixelSize( 20 ); | 238 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 239 | f.setBold( TRUE ); |
@@ -246,23 +245,23 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 245 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 246 | } else { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 247 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 248 | } |
250 | } | 249 | } |
251 | } else { | 250 | } else { |
252 | w = videoUI->width(); | 251 | w = videoUI()->width(); |
253 | h = videoUI->height(); | 252 | h = videoUI()->height(); |
254 | 253 | ||
255 | if ( drawnOnScreenDisplay ) { | 254 | if ( drawnOnScreenDisplay ) { |
256 | if ( onScreenDisplayVolume > v ) { | 255 | if ( onScreenDisplayVolume > v ) { |
257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 256 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
258 | } | 257 | } |
259 | } | 258 | } |
260 | drawnOnScreenDisplay = TRUE; | 259 | drawnOnScreenDisplay = TRUE; |
261 | onScreenDisplayVolume = v; | 260 | onScreenDisplayVolume = v; |
262 | QPainter p( videoUI ); | 261 | QPainter p( videoUI() ); |
263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 262 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
265 | 264 | ||
266 | QFont f; | 265 | QFont f; |
267 | f.setPixelSize( 20 ); | 266 | f.setPixelSize( 20 ); |
268 | f.setBold( TRUE ); | 267 | f.setBold( TRUE ); |
@@ -343,35 +342,54 @@ void MediaPlayer::cleanUp() {// this happens on closing | |||
343 | playList.writeDefaultPlaylist( ); | 342 | playList.writeDefaultPlaylist( ); |
344 | 343 | ||
345 | // QPEApplication::grabKeyboard(); | 344 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 345 | // QPEApplication::ungrabKeyboard(); |
347 | } | 346 | } |
348 | 347 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() | 348 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
350 | { | 349 | { |
351 | delete xineControl; | 350 | delete m_xineControl; |
352 | delete audioUI; | 351 | delete m_audioUI; |
353 | delete videoUI; | 352 | delete m_videoUI; |
354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 353 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 354 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 355 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 356 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 357 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 358 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 360 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 361 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 362 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 363 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 365 | ||
367 | xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); | 366 | m_xineControl = new XineControl( m_videoUI->vidWidget(), mediaPlayerState ); |
368 | connect( xineControl, SIGNAL( initialized() ), | 367 | } |
369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); | 368 | |
369 | AudioWidget *MediaPlayer::audioUI() const | ||
370 | { | ||
371 | if ( !m_audioUI ) | ||
372 | recreateAudioAndVideoWidgets(); | ||
373 | return m_audioUI; | ||
374 | } | ||
375 | |||
376 | VideoWidget *MediaPlayer::videoUI() const | ||
377 | { | ||
378 | if ( !m_videoUI ) | ||
379 | recreateAudioAndVideoWidgets(); | ||
380 | return m_videoUI; | ||
381 | } | ||
382 | |||
383 | XineControl *MediaPlayer::xineControl() const | ||
384 | { | ||
385 | if ( !m_xineControl ) | ||
386 | recreateAudioAndVideoWidgets(); | ||
387 | return m_xineControl; | ||
370 | } | 388 | } |
371 | 389 | ||
372 | void MediaPlayer::reloadSkins() | 390 | void MediaPlayer::reloadSkins() |
373 | { | 391 | { |
374 | audioUI->loadSkin(); | 392 | audioUI()->loadSkin(); |
375 | videoUI->loadSkin(); | 393 | videoUI()->loadSkin(); |
376 | } | 394 | } |
377 | 395 | ||