summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/mediaplayer.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index b0963cf..4f3823a 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -103,20 +103,22 @@ void MediaPlayer::setPlaying( bool play ) {
103 mediaPlayerState->setPlaying( FALSE ); 103 mediaPlayerState->setPlaying( FALSE );
104 return; 104 return;
105 } 105 }
106 106
107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { 107 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
108 QMessageBox::critical( 0, tr( "File not found"), 108 QMessageBox::critical( 0, tr( "File not found"),
109 tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); 109 tr( "The following file was not found: <i>" )
110 + currentFile->file() + "</i>" );
110 mediaPlayerState->setPlaying( FALSE ); 111 mediaPlayerState->setPlaying( FALSE );
111 return; 112 return;
112 } 113 }
113 114
114 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { 115 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
115 QMessageBox::critical( 0, tr( "No decoder found"), 116 QMessageBox::critical( 0, tr( "No decoder found"),
116 tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); 117 tr( "Sorry, no appropriate decoders found for this file: <i>" )
118 + currentFile->file() + "</i>" );
117 mediaPlayerState->setPlaying( FALSE ); 119 mediaPlayerState->setPlaying( FALSE );
118 return; 120 return;
119 } 121 }
120 122
121 if ( !loopControl->init( currentFile->file() ) ) { 123 if ( !loopControl->init( currentFile->file() ) ) {
122 QMessageBox::critical( 0, tr( "Error opening file"), 124 QMessageBox::critical( 0, tr( "Error opening file"),
@@ -173,25 +175,76 @@ void MediaPlayer::startDecreasingVolume() {
173 175
174 176
175void MediaPlayer::startIncreasingVolume() { 177void MediaPlayer::startIncreasingVolume() {
176 volumeDirection = +1; 178 volumeDirection = +1;
177 startTimer( 100 ); 179 startTimer( 100 );
178 AudioDevice::increaseVolume(); 180 AudioDevice::increaseVolume();
181
179} 182}
180 183
184bool drawnOnScreenDisplay = FALSE;
185unsigned int onScreenDisplayVolume = 0;
186const int yoff = 110;
181 187
182void MediaPlayer::stopChangingVolume() { 188void MediaPlayer::stopChangingVolume() {
183 killTimers(); 189 killTimers();
190
191 // Get rid of the on-screen display stuff
192 drawnOnScreenDisplay = FALSE;
193 onScreenDisplayVolume = 0;
194 int w = audioUI->width();
195 int h = audioUI->height();
196 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
184} 197}
185 198
186 199
187void MediaPlayer::timerEvent( QTimerEvent * ) { 200void MediaPlayer::timerEvent( QTimerEvent * ) {
201// qDebug("timer");
188 if ( volumeDirection == +1 ) 202 if ( volumeDirection == +1 )
189 AudioDevice::increaseVolume(); 203 AudioDevice::increaseVolume();
190 else if ( volumeDirection == -1 ) 204 else if ( volumeDirection == -1 )
191 AudioDevice::decreaseVolume(); 205 AudioDevice::decreaseVolume();
206
207 // Display an on-screen display volume
208 unsigned int l, r, v; bool m;
209 AudioDevice::getVolume( l, r, m );
210 v = ((l + r) * 11) / (2*0xFFFF);
211
212 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
213// qDebug("returning %d, %d, %d, %d", v, l, r, m);
214 return;
215 }
216
217 int w = audioUI->width();
218 int h = audioUI->height();
219
220 if ( drawnOnScreenDisplay ) {
221 if ( onScreenDisplayVolume > v )
222 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40,
223 (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
224 }
225
226 drawnOnScreenDisplay = TRUE;
227 onScreenDisplayVolume = v;
228
229 QPainter p( audioUI );
230 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
231 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
232
233 QFont f;
234 f.setPixelSize( 20 );
235 f.setBold( TRUE );
236 p.setFont( f );
237 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
238
239 for ( unsigned int i = 0; i < 10; i++ ) {
240 if ( v > i )
241 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
242 else
243 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
244 }
192} 245}
193 246
194void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 247void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
195 switch ( e->key() ) { 248 switch ( e->key() ) {
196////////////////////////////// Zaurus keys 249////////////////////////////// Zaurus keys
197 case Key_Home: 250 case Key_Home: