summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp120
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
@@ -31,10 +31,9 @@
31MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 31MediaPlayer::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
62MediaPlayer::~MediaPlayer() { 61MediaPlayer::~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
349void MediaPlayer::recreateAudioAndVideoWidgets() 348void 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
369AudioWidget *MediaPlayer::audioUI() const
370{
371 if ( !m_audioUI )
372 recreateAudioAndVideoWidgets();
373 return m_audioUI;
374}
375
376VideoWidget *MediaPlayer::videoUI() const
377{
378 if ( !m_videoUI )
379 recreateAudioAndVideoWidgets();
380 return m_videoUI;
381}
382
383XineControl *MediaPlayer::xineControl() const
384{
385 if ( !m_xineControl )
386 recreateAudioAndVideoWidgets();
387 return m_xineControl;
370} 388}
371 389
372void MediaPlayer::reloadSkins() 390void MediaPlayer::reloadSkins()
373{ 391{
374 audioUI->loadSkin(); 392 audioUI()->loadSkin();
375 videoUI->loadSkin(); 393 videoUI()->loadSkin();
376} 394}
377 395