author | harlekin <harlekin> | 2002-08-07 19:30:13 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-07 19:30:13 (UTC) |
commit | c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300 (patch) (unidiff) | |
tree | 558e8528408f0ab27d644554279f646723c6dad9 /noncore/multimedia/opieplayer2/mediaplayer.cpp | |
parent | 7effde67fd121736ec658e690858c6c54bd6d125 (diff) | |
download | opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.zip opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.tar.gz opie-c80f0885bf402b6dd4ea637ad1b7d8b3ebd69300.tar.bz2 |
added volume handling for audio gui and other small fixes
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5411a64..8d8e4e5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -10,8 +10,9 @@ | |||
10 | 10 | ||
11 | #include "mediaplayer.h" | 11 | #include "mediaplayer.h" |
12 | #include "playlistwidget.h" | 12 | #include "playlistwidget.h" |
13 | #include "audiowidget.h" | 13 | #include "audiowidget.h" |
14 | #include "volumecontrol.h" | ||
14 | 15 | ||
15 | #include "mediaplayerstate.h" | 16 | #include "mediaplayerstate.h" |
16 | 17 | ||
17 | 18 | ||
@@ -38,11 +39,15 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | |||
38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 39 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 40 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 41 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
41 | 42 | ||
43 | volControl = new VolumeControl; | ||
44 | |||
42 | } | 45 | } |
43 | 46 | ||
44 | MediaPlayer::~MediaPlayer() { | 47 | MediaPlayer::~MediaPlayer() { |
48 | delete xineControl; | ||
49 | delete volControl; | ||
45 | } | 50 | } |
46 | 51 | ||
47 | void MediaPlayer::pauseCheck( bool b ) { | 52 | void MediaPlayer::pauseCheck( bool b ) { |
48 | // Only pause if playing | 53 | // Only pause if playing |
@@ -70,9 +75,9 @@ void MediaPlayer::setPlaying( bool play ) { | |||
70 | const DocLnk *playListCurrent = playList->current(); | 75 | const DocLnk *playListCurrent = playList->current(); |
71 | if ( playListCurrent != NULL ) { | 76 | if ( playListCurrent != NULL ) { |
72 | currentFile = playListCurrent; | 77 | currentFile = playListCurrent; |
73 | } | 78 | } |
74 | 79 | ||
75 | xineControl->play( currentFile->file() ); | 80 | xineControl->play( currentFile->file() ); |
76 | 81 | ||
77 | xineControl->length(); | 82 | xineControl->length(); |
78 | long seconds = mediaPlayerState->length();// | 83 | long seconds = mediaPlayerState->length();// |
@@ -91,9 +96,9 @@ void MediaPlayer::setPlaying( bool play ) { | |||
91 | // tickerText += ", " + fileInfo; | 96 | // tickerText += ", " + fileInfo; |
92 | // audioUI->setTickerText( tickerText + "." ); | 97 | // audioUI->setTickerText( tickerText + "." ); |
93 | 98 | ||
94 | audioUI->setTickerText( currentFile->file( ) ); | 99 | audioUI->setTickerText( currentFile->file( ) ); |
95 | 100 | ||
96 | } | 101 | } |
97 | 102 | ||
98 | 103 | ||
99 | void MediaPlayer::prev() { | 104 | void MediaPlayer::prev() { |
@@ -124,18 +129,16 @@ void MediaPlayer::next() { | |||
124 | 129 | ||
125 | void MediaPlayer::startDecreasingVolume() { | 130 | void MediaPlayer::startDecreasingVolume() { |
126 | volumeDirection = -1; | 131 | volumeDirection = -1; |
127 | startTimer( 100 ); | 132 | startTimer( 100 ); |
128 | // da kommt demnächst osound denk ich mal | 133 | volControl->decVol(2); |
129 | /////////////////////////// lets just move those change volume here | ||
130 | // AudioDevice::decreaseVolume(); | ||
131 | } | 134 | } |
132 | 135 | ||
133 | 136 | ||
134 | void MediaPlayer::startIncreasingVolume() { | 137 | void MediaPlayer::startIncreasingVolume() { |
135 | volumeDirection = +1; | 138 | volumeDirection = +1; |
136 | startTimer( 100 ); | 139 | startTimer( 100 ); |
137 | // AudioDevice::increaseVolume(); | 140 | volControl->incVol(2); |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 | ||
141 | bool drawnOnScreenDisplay = FALSE; | 144 | bool drawnOnScreenDisplay = FALSE; |
@@ -153,29 +156,31 @@ void MediaPlayer::stopChangingVolume() { | |||
153 | } | 156 | } |
154 | 157 | ||
155 | 158 | ||
156 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 159 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
157 | // if ( volumeDirection == +1 ) | 160 | if ( volumeDirection == +1 ) { |
158 | // AudioDevice::increaseVolume(); | 161 | volControl->incVol(2); |
159 | // else if ( volumeDirection == -1 ) | 162 | } else if ( volumeDirection == -1 ) { |
160 | // AudioDevice::decreaseVolume(); | 163 | volControl->decVol(2); |
164 | } | ||
161 | 165 | ||
162 | // Display an on-screen display volume | ||
163 | unsigned int l, r, v; bool m; | ||
164 | 166 | ||
165 | // TODO FIXME | 167 | // TODO FIXME |
166 | // AudioDevice::getVolume( l, r, m ); | 168 | int v; |
167 | // v = ((l + r) * 11) / (2*0xFFFF); | 169 | v = volControl->getVolume(); |
170 | v = v / 10; | ||
168 | 171 | ||
169 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) | 172 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
170 | return; | 173 | return; |
174 | } | ||
171 | 175 | ||
172 | int w = audioUI->width(); | 176 | int w = audioUI->width(); |
173 | int h = audioUI->height(); | 177 | int h = audioUI->height(); |
174 | 178 | ||
175 | if ( drawnOnScreenDisplay ) { | 179 | if ( drawnOnScreenDisplay ) { |
176 | if ( onScreenDisplayVolume > v ) | 180 | if ( onScreenDisplayVolume > v ) { |
177 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 181 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
182 | } | ||
178 | } | 183 | } |
179 | 184 | ||
180 | drawnOnScreenDisplay = TRUE; | 185 | drawnOnScreenDisplay = TRUE; |
181 | onScreenDisplayVolume = v; | 186 | onScreenDisplayVolume = v; |
@@ -190,12 +195,13 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
190 | p.setFont( f ); | 195 | p.setFont( f ); |
191 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 196 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
192 | 197 | ||
193 | for ( unsigned int i = 0; i < 10; i++ ) { | 198 | for ( unsigned int i = 0; i < 10; i++ ) { |
194 | if ( v > i ) | 199 | if ( v > i ) { |
195 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 200 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
196 | else | 201 | } else { |
197 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 202 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
203 | } | ||
198 | } | 204 | } |
199 | } | 205 | } |
200 | 206 | ||
201 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 207 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |