author | simon <simon> | 2002-12-11 14:25:49 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 14:25:49 (UTC) |
commit | 7a17954c26add31f28b69989f54e0f28a17c8949 (patch) (unidiff) | |
tree | 8603026771be07c996f49a29375fda64c8cd0e67 /noncore/multimedia/opieplayer2/mediaplayer.cpp | |
parent | 16138f0cdf46994d20ade71b5621b82fb9386933 (diff) | |
download | opie-7a17954c26add31f28b69989f54e0f28a17c8949.zip opie-7a17954c26add31f28b69989f54e0f28a17c8949.tar.gz opie-7a17954c26add31f28b69989f54e0f28a17c8949.tar.bz2 |
- roll back the threaded xine initialization, the mediaplayer initialization
state and the PlayButton change set
- instead load the audio-/video widget and the xine control on-demand. much
faster and much simpler for startup
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 114 |
1 files changed, 66 insertions, 48 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 | |||
@@ -31,10 +31,9 @@ | |||
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" ) ); |
@@ -60,9 +59,9 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
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 | ||
@@ -103,26 +102,26 @@ void MediaPlayer::setPlaying( bool play ) { | |||
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 | ||
@@ -189,14 +188,14 @@ void MediaPlayer::stopChangingVolume() { | |||
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 | ||
@@ -220,18 +219,18 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
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 | ||
@@ -249,17 +248,17 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
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 | ||
@@ -346,32 +345,51 @@ void MediaPlayer::cleanUp() {// this happens on closing | |||
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" ); |
355 | |||
356 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | ||
357 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | ||
358 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | ||
359 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | ||
356 | 360 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 361 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 362 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 363 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | |||
366 | m_xineControl = new XineControl( m_videoUI->vidWidget(), mediaPlayerState ); | ||
367 | } | ||
361 | 368 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 369 | AudioWidget *MediaPlayer::audioUI() const |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 370 | { |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 371 | if ( !m_audioUI ) |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 372 | recreateAudioAndVideoWidgets(); |
373 | return m_audioUI; | ||
374 | } | ||
366 | 375 | ||
367 | xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); | 376 | VideoWidget *MediaPlayer::videoUI() const |
368 | connect( xineControl, SIGNAL( initialized() ), | 377 | { |
369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); | 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 | ||