-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 43e3133..13cc4ed 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,212 +1,214 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
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 | 14 | ||
15 | #include "mediaplayerstate.h" | 15 | #include "mediaplayerstate.h" |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | extern AudioWidget *audioUI; | 19 | extern AudioWidget *audioUI; |
20 | extern PlayListWidget *playList; | 20 | extern PlayListWidget *playList; |
21 | extern MediaPlayerState *mediaPlayerState; | 21 | extern MediaPlayerState *mediaPlayerState; |
22 | 22 | ||
23 | 23 | ||
24 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 24 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
25 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 25 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
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 | 74 | ||
75 | audioUI->setTickerText( currentFile->file( ) ); | 75 | audioUI->setTickerText( currentFile->file( ) ); |
76 | 76 | ||
77 | xineControl->play( currentFile->file() ); | 77 | xineControl->play( currentFile->file() ); |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | void MediaPlayer::prev() { | 81 | void MediaPlayer::prev() { |
82 | if ( playList->prev() ) { | 82 | if ( playList->prev() ) { |
83 | play(); | 83 | play(); |
84 | } else if ( mediaPlayerState->looping() ) { | 84 | } else if ( mediaPlayerState->looping() ) { |
85 | if ( playList->last() ) { | 85 | if ( playList->last() ) { |
86 | play(); | 86 | play(); |
87 | } | 87 | } |
88 | } else { | 88 | } else { |
89 | mediaPlayerState->setList(); | 89 | mediaPlayerState->setList(); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | void MediaPlayer::next() { | 94 | void MediaPlayer::next() { |
95 | if ( playList->next() ) { | 95 | if ( playList->next() ) { |
96 | play(); | 96 | play(); |
97 | } else if ( mediaPlayerState->looping() ) { | 97 | } else if ( mediaPlayerState->looping() ) { |
98 | if ( playList->first() ) { | 98 | if ( playList->first() ) { |
99 | play(); | 99 | play(); |
100 | } | 100 | } |
101 | } else { | 101 | } else { |
102 | mediaPlayerState->setList(); | 102 | mediaPlayerState->setList(); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void MediaPlayer::startDecreasingVolume() { | 107 | void MediaPlayer::startDecreasingVolume() { |
108 | volumeDirection = -1; | 108 | volumeDirection = -1; |
109 | startTimer( 100 ); | 109 | startTimer( 100 ); |
110 | // da kommt demnächst osound denk ich mal | 110 | // da kommt demnächst osound denk ich mal |
111 | /////////////////////////// lets just move those change volume here | 111 | /////////////////////////// lets just move those change volume here |
112 | // AudioDevice::decreaseVolume(); | 112 | // AudioDevice::decreaseVolume(); |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void MediaPlayer::startIncreasingVolume() { | 116 | void MediaPlayer::startIncreasingVolume() { |
117 | volumeDirection = +1; | 117 | volumeDirection = +1; |
118 | startTimer( 100 ); | 118 | startTimer( 100 ); |
119 | // AudioDevice::increaseVolume(); | 119 | // AudioDevice::increaseVolume(); |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | bool drawnOnScreenDisplay = FALSE; | 123 | bool drawnOnScreenDisplay = FALSE; |
124 | unsigned int onScreenDisplayVolume = 0; | 124 | unsigned int onScreenDisplayVolume = 0; |
125 | const int yoff = 110; | 125 | const int yoff = 110; |
126 | 126 | ||
127 | void MediaPlayer::stopChangingVolume() { | 127 | void MediaPlayer::stopChangingVolume() { |
128 | killTimers(); | 128 | killTimers(); |
129 | // Get rid of the on-screen display stuff | 129 | // Get rid of the on-screen display stuff |
130 | drawnOnScreenDisplay = FALSE; | 130 | drawnOnScreenDisplay = FALSE; |
131 | onScreenDisplayVolume = 0; | 131 | onScreenDisplayVolume = 0; |
132 | int w = audioUI->width(); | 132 | int w = audioUI->width(); |
133 | int h = audioUI->height(); | 133 | int h = audioUI->height(); |
134 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 134 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 138 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
139 | // if ( volumeDirection == +1 ) | 139 | // if ( volumeDirection == +1 ) |
140 | // AudioDevice::increaseVolume(); | 140 | // AudioDevice::increaseVolume(); |
141 | // else if ( volumeDirection == -1 ) | 141 | // else if ( volumeDirection == -1 ) |
142 | // AudioDevice::decreaseVolume(); | 142 | // AudioDevice::decreaseVolume(); |
143 | 143 | ||
144 | // Display an on-screen display volume | 144 | // Display an on-screen display volume |
145 | unsigned int l, r, v; bool m; | 145 | unsigned int l, r, v; bool m; |
146 | AudioDevice::getVolume( l, r, m ); | 146 | |
147 | v = ((l + r) * 11) / (2*0xFFFF); | 147 | // TODO FIXME |
148 | // AudioDevice::getVolume( l, r, m ); | ||
149 | // v = ((l + r) * 11) / (2*0xFFFF); | ||
148 | 150 | ||
149 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) | 151 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) |
150 | return; | 152 | return; |
151 | 153 | ||
152 | int w = audioUI->width(); | 154 | int w = audioUI->width(); |
153 | int h = audioUI->height(); | 155 | int h = audioUI->height(); |
154 | 156 | ||
155 | if ( drawnOnScreenDisplay ) { | 157 | if ( drawnOnScreenDisplay ) { |
156 | if ( onScreenDisplayVolume > v ) | 158 | if ( onScreenDisplayVolume > v ) |
157 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 159 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
158 | } | 160 | } |
159 | 161 | ||
160 | drawnOnScreenDisplay = TRUE; | 162 | drawnOnScreenDisplay = TRUE; |
161 | onScreenDisplayVolume = v; | 163 | onScreenDisplayVolume = v; |
162 | 164 | ||
163 | QPainter p( audioUI ); | 165 | QPainter p( audioUI ); |
164 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 166 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
165 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 167 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
166 | 168 | ||
167 | QFont f; | 169 | QFont f; |
168 | f.setPixelSize( 20 ); | 170 | f.setPixelSize( 20 ); |
169 | f.setBold( TRUE ); | 171 | f.setBold( TRUE ); |
170 | p.setFont( f ); | 172 | p.setFont( f ); |
171 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 173 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
172 | 174 | ||
173 | for ( unsigned int i = 0; i < 10; i++ ) { | 175 | for ( unsigned int i = 0; i < 10; i++ ) { |
174 | if ( v > i ) | 176 | if ( v > i ) |
175 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 177 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
176 | else | 178 | else |
177 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 179 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
178 | } | 180 | } |
179 | } | 181 | } |
180 | 182 | ||
181 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 183 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
182 | switch ( e->key() ) { | 184 | switch ( e->key() ) { |
183 | ////////////////////////////// Zaurus keys | 185 | ////////////////////////////// Zaurus keys |
184 | case Key_Home: | 186 | case Key_Home: |
185 | break; | 187 | break; |
186 | case Key_F9: //activity | 188 | case Key_F9: //activity |
187 | break; | 189 | break; |
188 | case Key_F10: //contacts | 190 | case Key_F10: //contacts |
189 | break; | 191 | break; |
190 | case Key_F11: //menu | 192 | case Key_F11: //menu |
191 | break; | 193 | break; |
192 | case Key_F12: //home | 194 | case Key_F12: //home |
193 | qDebug("Blank here"); | 195 | qDebug("Blank here"); |
194 | break; | 196 | break; |
195 | case Key_F13: //mail | 197 | case Key_F13: //mail |
196 | break; | 198 | break; |
197 | } | 199 | } |
198 | } | 200 | } |
199 | 201 | ||
200 | void MediaPlayer::doBlank() { | 202 | void MediaPlayer::doBlank() { |
201 | 203 | ||
202 | } | 204 | } |
203 | 205 | ||
204 | void MediaPlayer::doUnblank() { | 206 | void MediaPlayer::doUnblank() { |
205 | 207 | ||
206 | } | 208 | } |
207 | 209 | ||
208 | void MediaPlayer::cleanUp() { | 210 | void MediaPlayer::cleanUp() { |
209 | // QPEApplication::grabKeyboard(); | 211 | // QPEApplication::grabKeyboard(); |
210 | // QPEApplication::ungrabKeyboard(); | 212 | // QPEApplication::ungrabKeyboard(); |
211 | 213 | ||
212 | } | 214 | } |