author | llornkcor <llornkcor> | 2002-08-03 11:26:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-03 11:26:12 (UTC) |
commit | 3b1ab71b7bfe42310661764e1089200290c7b817 (patch) (unidiff) | |
tree | 361ad970ec2f4c06bd7d9cc1a94b45040539f844 /noncore/multimedia | |
parent | 7d4b246bc728b73e9d38e110619222dd89c1fd1c (diff) | |
download | opie-3b1ab71b7bfe42310661764e1089200290c7b817.zip opie-3b1ab71b7bfe42310661764e1089200290c7b817.tar.gz opie-3b1ab71b7bfe42310661764e1089200290c7b817.tar.bz2 |
initial fx for time readout
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 22 |
2 files changed, 35 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 300a5c8..303834a 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -53,97 +53,97 @@ void Ticker::drawContents( QPainter *p ) { | |||
53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
54 | QPixmap pm( width(), height() ); | 54 | QPixmap pm( width(), height() ); |
55 | pm.fill( colorGroup().base() ); | 55 | pm.fill( colorGroup().base() ); |
56 | QPainter pmp( &pm ); | 56 | QPainter pmp( &pm ); |
57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
59 | } | 59 | } |
60 | p->drawPixmap( 0, 0, pm ); | 60 | p->drawPixmap( 0, 0, pm ); |
61 | } | 61 | } |
62 | 62 | ||
63 | struct MediaButton { | 63 | struct MediaButton { |
64 | bool isToggle, isHeld, isDown; | 64 | bool isToggle, isHeld, isDown; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | //Layout information for the audioButtons (and if it is a toggle button or not) | 67 | //Layout information for the audioButtons (and if it is a toggle button or not) |
68 | MediaButton audioButtons[] = { | 68 | MediaButton audioButtons[] = { |
69 | { TRUE, FALSE, FALSE }, // play | 69 | { TRUE, FALSE, FALSE }, // play |
70 | { FALSE, FALSE, FALSE }, // stop | 70 | { FALSE, FALSE, FALSE }, // stop |
71 | { TRUE, FALSE, FALSE }, // pause | 71 | { TRUE, FALSE, FALSE }, // pause |
72 | { FALSE, FALSE, FALSE }, // next | 72 | { FALSE, FALSE, FALSE }, // next |
73 | { FALSE, FALSE, FALSE }, // previous | 73 | { FALSE, FALSE, FALSE }, // previous |
74 | { FALSE, FALSE, FALSE }, // volume up | 74 | { FALSE, FALSE, FALSE }, // volume up |
75 | { FALSE, FALSE, FALSE }, // volume down | 75 | { FALSE, FALSE, FALSE }, // volume down |
76 | { TRUE, FALSE, FALSE }, // repeat/loop | 76 | { TRUE, FALSE, FALSE }, // repeat/loop |
77 | { FALSE, FALSE, FALSE }, // playlist | 77 | { FALSE, FALSE, FALSE }, // playlist |
78 | { FALSE, FALSE, FALSE }, // forward | 78 | { FALSE, FALSE, FALSE }, // forward |
79 | { FALSE, FALSE, FALSE } // back | 79 | { FALSE, FALSE, FALSE } // back |
80 | }; | 80 | }; |
81 | 81 | ||
82 | const char *skin_mask_file_names[11] = { | 82 | const char *skin_mask_file_names[11] = { |
83 | "play", "stop", "pause", "next", "prev", "up", | 83 | "play", "stop", "pause", "next", "prev", "up", |
84 | "down", "loop", "playlist", "forward", "back" | 84 | "down", "loop", "playlist", "forward", "back" |
85 | }; | 85 | }; |
86 | 86 | ||
87 | 87 | ||
88 | static void changeTextColor( QWidget *w ) { | 88 | static void changeTextColor( QWidget *w ) { |
89 | QPalette p = w->palette(); | 89 | QPalette p = w->palette(); |
90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
92 | w->setPalette( p ); | 92 | w->setPalette( p ); |
93 | } | 93 | } |
94 | 94 | ||
95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
96 | 96 | ||
97 | 97 | ||
98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
100 | setCaption( tr("OpiePlayer") ); | 100 | setCaption( tr("OpiePlayer") ); |
101 | 101 | ||
102 | Config cfg("OpiePlayer"); | 102 | Config cfg("OpiePlayer"); |
103 | cfg.setGroup("AudioWidget"); | 103 | cfg.setGroup("AudioWidget"); |
104 | skin = cfg.readEntry("Skin","default"); | 104 | skin = cfg.readEntry("Skin","default"); |
105 | //skin = "scaleTest"; | 105 | //skin = "scaleTest"; |
106 | // color of background, frame, degree of transparency | 106 | // color of background, frame, degree of transparency |
107 | 107 | ||
108 | QString skinPath = "opieplayer/skins/" + skin; | 108 | QString skinPath = "opieplayer/skins/" + skin; |
109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
112 | 112 | ||
113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
114 | imgButtonMask->fill( 0 ); | 114 | imgButtonMask->fill( 0 ); |
115 | 115 | ||
116 | for ( int i = 0; i < 11; i++ ) { | 116 | for ( int i = 0; i < 11; i++ ) { |
117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
118 | masks[i] = new QBitmap( filename ); | 118 | masks[i] = new QBitmap( filename ); |
119 | 119 | ||
120 | if ( !masks[i]->isNull() ) { | 120 | if ( !masks[i]->isNull() ) { |
121 | QImage imgMask = masks[i]->convertToImage(); | 121 | QImage imgMask = masks[i]->convertToImage(); |
122 | uchar **dest = imgButtonMask->jumpTable(); | 122 | uchar **dest = imgButtonMask->jumpTable(); |
123 | for ( int y = 0; y < imgUp->height(); y++ ) { | 123 | for ( int y = 0; y < imgUp->height(); y++ ) { |
124 | uchar *line = dest[y]; | 124 | uchar *line = dest[y]; |
125 | for ( int x = 0; x < imgUp->width(); x++ ) | 125 | for ( int x = 0; x < imgUp->width(); x++ ) |
126 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 126 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
127 | line[x] = i + 1; | 127 | line[x] = i + 1; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | for ( int i = 0; i < 11; i++ ) { | 133 | for ( int i = 0; i < 11; i++ ) { |
134 | buttonPixUp[i] = NULL; | 134 | buttonPixUp[i] = NULL; |
135 | buttonPixDown[i] = NULL; | 135 | buttonPixDown[i] = NULL; |
136 | } | 136 | } |
137 | 137 | ||
138 | setBackgroundPixmap( *pixBg ); | 138 | setBackgroundPixmap( *pixBg ); |
139 | 139 | ||
140 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 140 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
141 | changeTextColor( &songInfo ); | 141 | changeTextColor( &songInfo ); |
142 | 142 | ||
143 | slider.setFixedHeight( 20 ); | 143 | slider.setFixedHeight( 20 ); |
144 | slider.setMinValue( 0 ); | 144 | slider.setMinValue( 0 ); |
145 | slider.setMaxValue( 1 ); | 145 | slider.setMaxValue( 1 ); |
146 | slider.setFocusPolicy( QWidget::NoFocus ); | 146 | slider.setFocusPolicy( QWidget::NoFocus ); |
147 | slider.setBackgroundPixmap( *pixBg ); | 147 | slider.setBackgroundPixmap( *pixBg ); |
148 | 148 | ||
149 | time.setFocusPolicy( QWidget::NoFocus ); | 149 | time.setFocusPolicy( QWidget::NoFocus ); |
@@ -206,138 +206,145 @@ QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | |||
206 | 206 | ||
207 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 207 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
208 | int h = height(); | 208 | int h = height(); |
209 | int w = width(); | 209 | int w = width(); |
210 | 210 | ||
211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
212 | slider.setFixedWidth( w - 110 ); | 212 | slider.setFixedWidth( w - 110 ); |
213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
216 | 216 | ||
217 | xoff = ( w - imgUp->width() ) / 2; | 217 | xoff = ( w - imgUp->width() ) / 2; |
218 | yoff = (( h - imgUp->height() ) / 2) - 10; | 218 | yoff = (( h - imgUp->height() ) / 2) - 10; |
219 | QPoint p( xoff, yoff ); | 219 | QPoint p( xoff, yoff ); |
220 | 220 | ||
221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
223 | 223 | ||
224 | for ( int i = 0; i < 11; i++ ) { | 224 | for ( int i = 0; i < 11; i++ ) { |
225 | if ( !masks[i]->isNull() ) { | 225 | if ( !masks[i]->isNull() ) { |
226 | delete buttonPixUp[i]; | 226 | delete buttonPixUp[i]; |
227 | delete buttonPixDown[i]; | 227 | delete buttonPixDown[i]; |
228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | delete pixUp; | 233 | delete pixUp; |
234 | delete pixDn; | 234 | delete pixDn; |
235 | } | 235 | } |
236 | 236 | ||
237 | static bool audioSliderBeingMoved = FALSE; | 237 | static bool audioSliderBeingMoved = FALSE; |
238 | 238 | ||
239 | 239 | ||
240 | void AudioWidget::sliderPressed() { | 240 | void AudioWidget::sliderPressed() { |
241 | audioSliderBeingMoved = TRUE; | 241 | audioSliderBeingMoved = TRUE; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | void AudioWidget::sliderReleased() { | 245 | void AudioWidget::sliderReleased() { |
246 | audioSliderBeingMoved = FALSE; | 246 | audioSliderBeingMoved = FALSE; |
247 | if ( slider.width() == 0 ) | 247 | if ( slider.width() == 0 ) |
248 | return; | 248 | return; |
249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
250 | mediaPlayerState->setPosition( val ); | 250 | mediaPlayerState->setPosition( val ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void AudioWidget::setPosition( long i ) { | 253 | void AudioWidget::setPosition( long i ) { |
254 | // qDebug("set position %d",i); | 254 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
255 | updateSlider( i, mediaPlayerState->length() ); | 255 | updateSlider( i, mediaPlayerState->length() ); |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AudioWidget::setLength( long max ) { | 259 | void AudioWidget::setLength( long max ) { |
260 | updateSlider( mediaPlayerState->position(), max ); | 260 | updateSlider( mediaPlayerState->position(), max ); |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | void AudioWidget::setView( char view ) { | 264 | void AudioWidget::setView( char view ) { |
265 | if (mediaPlayerState->streaming() ) { | 265 | slider.show(); |
266 | if( !slider.isHidden()) slider.hide(); | 266 | |
267 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 267 | // this isnt working for some reason |
268 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 268 | |
269 | } else { | 269 | // if ( mediaPlayerState->streaming() ) { |
270 | // qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | ||
271 | // if( !slider.isHidden()) slider.hide(); | ||
272 | // disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
273 | // disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
274 | // } else { | ||
270 | // this stops the slider from being moved, thus | 275 | // this stops the slider from being moved, thus |
271 | // does not stop stream when it reaches the end | 276 | // does not stop stream when it reaches the end |
272 | slider.show(); | 277 | slider.show(); |
273 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 278 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
274 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 279 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
275 | } | 280 | // } |
276 | 281 | ||
277 | if ( view == 'a' ) { | 282 | if ( view == 'a' ) { |
278 | startTimer( 150 ); | 283 | startTimer( 150 ); |
279 | showMaximized(); | 284 | showMaximized(); |
280 | } else { | 285 | } else { |
281 | killTimers(); | 286 | killTimers(); |
282 | hide(); | 287 | hide(); |
283 | } | 288 | } |
284 | } | 289 | } |
285 | 290 | ||
286 | 291 | ||
287 | static QString timeAsString( long length ) { | 292 | static QString timeAsString( long length ) { |
288 | length /= 44100; | 293 | length /= 44100; |
289 | int minutes = length / 60; | 294 | int minutes = length / 60; |
290 | int seconds = length % 60; | 295 | int seconds = length % 60; |
291 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 296 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
292 | } | 297 | } |
293 | 298 | ||
294 | void AudioWidget::updateSlider( long i, long max ) { | 299 | void AudioWidget::updateSlider( long i, long max ) { |
300 | |||
295 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 301 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
302 | |||
296 | if ( max == 0 ) { | 303 | if ( max == 0 ) { |
297 | return; | 304 | return; |
298 | } | 305 | } |
299 | // Will flicker too much if we don't do this | 306 | // Will flicker too much if we don't do this |
300 | // Scale to something reasonable | 307 | // Scale to something reasonable |
301 | int width = slider.width(); | 308 | int width = slider.width(); |
302 | int val = int((double)i * width / max); | 309 | int val = int((double)i * width / max); |
303 | if ( !audioSliderBeingMoved ) { | 310 | if ( !audioSliderBeingMoved ) { |
304 | if ( slider.value() != val ) { | 311 | if ( slider.value() != val ) { |
305 | slider.setValue( val ); | 312 | slider.setValue( val ); |
306 | } | 313 | } |
307 | 314 | ||
308 | if ( slider.maxValue() != width ) { | 315 | if ( slider.maxValue() != width ) { |
309 | slider.setMaxValue( width ); | 316 | slider.setMaxValue( width ); |
310 | } | 317 | } |
311 | } | 318 | } |
312 | } | 319 | } |
313 | 320 | ||
314 | 321 | ||
315 | void AudioWidget::setToggleButton( int i, bool down ) { | 322 | void AudioWidget::setToggleButton( int i, bool down ) { |
316 | if ( down != audioButtons[i].isDown ) { | 323 | if ( down != audioButtons[i].isDown ) { |
317 | toggleButton( i ); | 324 | toggleButton( i ); |
318 | } | 325 | } |
319 | } | 326 | } |
320 | 327 | ||
321 | 328 | ||
322 | void AudioWidget::toggleButton( int i ) { | 329 | void AudioWidget::toggleButton( int i ) { |
323 | audioButtons[i].isDown = !audioButtons[i].isDown; | 330 | audioButtons[i].isDown = !audioButtons[i].isDown; |
324 | QPainter p(this); | 331 | QPainter p(this); |
325 | paintButton ( &p, i ); | 332 | paintButton ( &p, i ); |
326 | } | 333 | } |
327 | 334 | ||
328 | 335 | ||
329 | void AudioWidget::paintButton( QPainter *p, int i ) { | 336 | void AudioWidget::paintButton( QPainter *p, int i ) { |
330 | if ( audioButtons[i].isDown ) | 337 | if ( audioButtons[i].isDown ) |
331 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 338 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
332 | else | 339 | else |
333 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 340 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
334 | } | 341 | } |
335 | 342 | ||
336 | 343 | ||
337 | void AudioWidget::timerEvent( QTimerEvent * ) { | 344 | void AudioWidget::timerEvent( QTimerEvent * ) { |
338 | // static int frame = 0; | 345 | // static int frame = 0; |
339 | // if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 346 | // if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
340 | // frame = frame >= 7 ? 0 : frame + 1; | 347 | // frame = frame >= 7 ? 0 : frame + 1; |
341 | // } | 348 | // } |
342 | } | 349 | } |
343 | 350 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 13cc4ed..5411a64 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -26,100 +26,118 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | |||
26 | 26 | ||
27 | 27 | ||
28 | xineControl = new XineControl(); | 28 | xineControl = new XineControl(); |
29 | // QPEApplication::grabKeyboard(); // EVIL | 29 | // QPEApplication::grabKeyboard(); // EVIL |
30 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 30 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
31 | 31 | ||
32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
33 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 33 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
34 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 34 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
35 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 35 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
36 | 36 | ||
37 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 37 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
41 | 41 | ||
42 | } | 42 | } |
43 | 43 | ||
44 | MediaPlayer::~MediaPlayer() { | 44 | MediaPlayer::~MediaPlayer() { |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaPlayer::pauseCheck( bool b ) { | 47 | void MediaPlayer::pauseCheck( bool b ) { |
48 | // Only pause if playing | 48 | // Only pause if playing |
49 | if ( b && !mediaPlayerState->playing() ) { | 49 | if ( b && !mediaPlayerState->playing() ) { |
50 | mediaPlayerState->setPaused( FALSE ); | 50 | mediaPlayerState->setPaused( FALSE ); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | void MediaPlayer::play() { | 54 | void MediaPlayer::play() { |
55 | mediaPlayerState->setPlaying( FALSE ); | 55 | mediaPlayerState->setPlaying( FALSE ); |
56 | mediaPlayerState->setPlaying( TRUE ); | 56 | mediaPlayerState->setPlaying( TRUE ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void MediaPlayer::setPlaying( bool play ) { | 59 | void MediaPlayer::setPlaying( bool play ) { |
60 | if ( !play ) { | 60 | if ( !play ) { |
61 | mediaPlayerState->setPaused( FALSE ); | 61 | mediaPlayerState->setPaused( FALSE ); |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | 64 | ||
65 | if ( mediaPlayerState->paused() ) { | 65 | if ( mediaPlayerState->paused() ) { |
66 | mediaPlayerState->setPaused( FALSE ); | 66 | mediaPlayerState->setPaused( FALSE ); |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | 69 | ||
70 | const DocLnk *playListCurrent = playList->current(); | 70 | const DocLnk *playListCurrent = playList->current(); |
71 | if ( playListCurrent != NULL ) { | 71 | if ( playListCurrent != NULL ) { |
72 | currentFile = playListCurrent; | 72 | currentFile = playListCurrent; |
73 | } | 73 | } |
74 | |||
75 | xineControl->play( currentFile->file() ); | ||
74 | 76 | ||
75 | audioUI->setTickerText( currentFile->file( ) ); | 77 | xineControl->length(); |
78 | long seconds = mediaPlayerState->length();// | ||
79 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | ||
80 | qDebug(time); | ||
76 | 81 | ||
77 | xineControl->play( currentFile->file() ); | 82 | QString tickerText; |
83 | if( currentFile->file().left(4) == "http" ) | ||
84 | tickerText= tr( " File: " ) + currentFile->name(); | ||
85 | else | ||
86 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | ||
87 | |||
88 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | ||
89 | |||
90 | // if ( !fileInfo.isEmpty() ) | ||
91 | // tickerText += ", " + fileInfo; | ||
92 | // audioUI->setTickerText( tickerText + "." ); | ||
93 | |||
94 | audioUI->setTickerText( currentFile->file( ) ); | ||
95 | |||
78 | } | 96 | } |
79 | 97 | ||
80 | 98 | ||
81 | void MediaPlayer::prev() { | 99 | void MediaPlayer::prev() { |
82 | if ( playList->prev() ) { | 100 | if ( playList->prev() ) { |
83 | play(); | 101 | play(); |
84 | } else if ( mediaPlayerState->looping() ) { | 102 | } else if ( mediaPlayerState->looping() ) { |
85 | if ( playList->last() ) { | 103 | if ( playList->last() ) { |
86 | play(); | 104 | play(); |
87 | } | 105 | } |
88 | } else { | 106 | } else { |
89 | mediaPlayerState->setList(); | 107 | mediaPlayerState->setList(); |
90 | } | 108 | } |
91 | } | 109 | } |
92 | 110 | ||
93 | 111 | ||
94 | void MediaPlayer::next() { | 112 | void MediaPlayer::next() { |
95 | if ( playList->next() ) { | 113 | if ( playList->next() ) { |
96 | play(); | 114 | play(); |
97 | } else if ( mediaPlayerState->looping() ) { | 115 | } else if ( mediaPlayerState->looping() ) { |
98 | if ( playList->first() ) { | 116 | if ( playList->first() ) { |
99 | play(); | 117 | play(); |
100 | } | 118 | } |
101 | } else { | 119 | } else { |
102 | mediaPlayerState->setList(); | 120 | mediaPlayerState->setList(); |
103 | } | 121 | } |
104 | } | 122 | } |
105 | 123 | ||
106 | 124 | ||
107 | void MediaPlayer::startDecreasingVolume() { | 125 | void MediaPlayer::startDecreasingVolume() { |
108 | volumeDirection = -1; | 126 | volumeDirection = -1; |
109 | startTimer( 100 ); | 127 | startTimer( 100 ); |
110 | // da kommt demnächst osound denk ich mal | 128 | // da kommt demnächst osound denk ich mal |
111 | /////////////////////////// lets just move those change volume here | 129 | /////////////////////////// lets just move those change volume here |
112 | // AudioDevice::decreaseVolume(); | 130 | // AudioDevice::decreaseVolume(); |
113 | } | 131 | } |
114 | 132 | ||
115 | 133 | ||
116 | void MediaPlayer::startIncreasingVolume() { | 134 | void MediaPlayer::startIncreasingVolume() { |
117 | volumeDirection = +1; | 135 | volumeDirection = +1; |
118 | startTimer( 100 ); | 136 | startTimer( 100 ); |
119 | // AudioDevice::increaseVolume(); | 137 | // AudioDevice::increaseVolume(); |
120 | } | 138 | } |
121 | 139 | ||
122 | 140 | ||
123 | bool drawnOnScreenDisplay = FALSE; | 141 | bool drawnOnScreenDisplay = FALSE; |
124 | unsigned int onScreenDisplayVolume = 0; | 142 | unsigned int onScreenDisplayVolume = 0; |
125 | const int yoff = 110; | 143 | const int yoff = 110; |