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 | |
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 | |||
@@ -93,17 +93,17 @@ static void changeTextColor( QWidget *w ) { | |||
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) ) ); |
@@ -246,38 +246,43 @@ 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 | } |
@@ -287,17 +292,19 @@ void AudioWidget::setView( char view ) { | |||
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 ) { |
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 | |||
@@ -66,20 +66,38 @@ void MediaPlayer::setPlaying( bool play ) { | |||
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() ) { |