summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp38
1 files changed, 22 insertions, 16 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
@@ -2,24 +2,25 @@
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qwidgetstack.h> 8#include <qwidgetstack.h>
9#include <qfile.h> 9#include <qfile.h>
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
18 19
19extern AudioWidget *audioUI; 20extern AudioWidget *audioUI;
20extern PlayListWidget *playList; 21extern PlayListWidget *playList;
21extern MediaPlayerState *mediaPlayerState; 22extern MediaPlayerState *mediaPlayerState;
22 23
23 24
24MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 25MediaPlayer::MediaPlayer( QObject *parent, const char *name )
25 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 26 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
@@ -30,27 +31,31 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name )
30 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 31 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
31 32
32 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 33 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
33 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 34 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
34 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 35 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
35 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 36 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
36 37
37 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 38 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
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
44MediaPlayer::~MediaPlayer() { 47MediaPlayer::~MediaPlayer() {
48 delete xineControl;
49 delete volControl;
45} 50}
46 51
47void MediaPlayer::pauseCheck( bool b ) { 52void MediaPlayer::pauseCheck( bool b ) {
48 // Only pause if playing 53 // Only pause if playing
49 if ( b && !mediaPlayerState->playing() ) { 54 if ( b && !mediaPlayerState->playing() ) {
50 mediaPlayerState->setPaused( FALSE ); 55 mediaPlayerState->setPaused( FALSE );
51 } 56 }
52} 57}
53 58
54void MediaPlayer::play() { 59void MediaPlayer::play() {
55 mediaPlayerState->setPlaying( FALSE ); 60 mediaPlayerState->setPlaying( FALSE );
56 mediaPlayerState->setPlaying( TRUE ); 61 mediaPlayerState->setPlaying( TRUE );
@@ -116,96 +121,97 @@ void MediaPlayer::next() {
116 if ( playList->first() ) { 121 if ( playList->first() ) {
117 play(); 122 play();
118 } 123 }
119 } else { 124 } else {
120 mediaPlayerState->setList(); 125 mediaPlayerState->setList();
121 } 126 }
122} 127}
123 128
124 129
125void MediaPlayer::startDecreasingVolume() { 130void 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
134void MediaPlayer::startIncreasingVolume() { 137void 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
141bool drawnOnScreenDisplay = FALSE; 144bool drawnOnScreenDisplay = FALSE;
142unsigned int onScreenDisplayVolume = 0; 145unsigned int onScreenDisplayVolume = 0;
143const int yoff = 110; 146const int yoff = 110;
144 147
145void MediaPlayer::stopChangingVolume() { 148void MediaPlayer::stopChangingVolume() {
146 killTimers(); 149 killTimers();
147 // Get rid of the on-screen display stuff 150 // Get rid of the on-screen display stuff
148 drawnOnScreenDisplay = FALSE; 151 drawnOnScreenDisplay = FALSE;
149 onScreenDisplayVolume = 0; 152 onScreenDisplayVolume = 0;
150 int w = audioUI->width(); 153 int w = audioUI->width();
151 int h = audioUI->height(); 154 int h = audioUI->height();
152 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 155 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
153} 156}
154 157
155 158
156void MediaPlayer::timerEvent( QTimerEvent * ) { 159void 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 );
178 } 182 }
183 }
179 184
180 drawnOnScreenDisplay = TRUE; 185 drawnOnScreenDisplay = TRUE;
181 onScreenDisplayVolume = v; 186 onScreenDisplayVolume = v;
182 187
183 QPainter p( audioUI ); 188 QPainter p( audioUI );
184 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 189 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
185 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 190 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
186 191
187 QFont f; 192 QFont f;
188 f.setPixelSize( 20 ); 193 f.setPixelSize( 20 );
189 f.setBold( TRUE ); 194 f.setBold( TRUE );
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 );
198 } 203 }
199} 204}
205}
200 206
201void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 207void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
202 switch ( e->key() ) { 208 switch ( e->key() ) {
203////////////////////////////// Zaurus keys 209////////////////////////////// Zaurus keys
204 case Key_Home: 210 case Key_Home:
205 break; 211 break;
206 case Key_F9: //activity 212 case Key_F9: //activity
207 break; 213 break;
208 case Key_F10: //contacts 214 case Key_F10: //contacts
209 break; 215 break;
210 case Key_F11: //menu 216 case Key_F11: //menu
211 break; 217 break;