author | llornkcor <llornkcor> | 2002-08-15 16:32:17 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-15 16:32:17 (UTC) |
commit | 07ea5f165a2f17f818147b2e8afb02af2c269b55 (patch) (unidiff) | |
tree | 94059e0b4910f5a681be601f554c5c3a6c26de4b | |
parent | 747a98bb3b2a92b6f3577fa383fc44a8644a7ce2 (diff) | |
download | opie-07ea5f165a2f17f818147b2e8afb02af2c269b55.zip opie-07ea5f165a2f17f818147b2e8afb02af2c269b55.tar.gz opie-07ea5f165a2f17f818147b2e8afb02af2c269b55.tar.bz2 |
added useAudio() and useVideo()
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 106 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 5 |
3 files changed, 85 insertions, 32 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index a3238f0..51fbb8b 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,239 +1,283 @@ | |||
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 | #include "videowidget.h" | ||
14 | #include "volumecontrol.h" | 15 | #include "volumecontrol.h" |
15 | 16 | ||
16 | #include "mediaplayerstate.h" | 17 | #include "mediaplayerstate.h" |
17 | 18 | ||
18 | 19 | ||
19 | 20 | ||
20 | extern AudioWidget *audioUI; | 21 | extern AudioWidget *audioUI; |
22 | extern VideoWidget *videoUI; | ||
21 | extern PlayListWidget *playList; | 23 | extern PlayListWidget *playList; |
22 | extern MediaPlayerState *mediaPlayerState; | 24 | extern MediaPlayerState *mediaPlayerState; |
23 | 25 | ||
24 | 26 | ||
25 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 27 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
26 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 28 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
27 | 29 | ||
28 | 30 | ||
29 | xineControl = new XineControl(); | 31 | xineControl = new XineControl(); |
30 | // QPEApplication::grabKeyboard(); // EVIL | 32 | // QPEApplication::grabKeyboard(); // EVIL |
31 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 33 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
32 | 34 | ||
33 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 35 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
34 | 36 | ||
35 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 37 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
36 | 38 | ||
37 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 39 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
38 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 40 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
39 | 41 | ||
40 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 42 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
41 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 43 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
42 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 44 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
43 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 45 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
44 | 46 | ||
47 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | ||
48 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | ||
49 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | ||
50 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | ||
51 | |||
45 | volControl = new VolumeControl; | 52 | volControl = new VolumeControl; |
46 | 53 | ||
47 | } | 54 | } |
48 | 55 | ||
49 | MediaPlayer::~MediaPlayer() { | 56 | MediaPlayer::~MediaPlayer() { |
50 | delete xineControl; | 57 | delete xineControl; |
51 | delete volControl; | 58 | delete volControl; |
52 | } | 59 | } |
53 | 60 | ||
54 | void MediaPlayer::pauseCheck( bool b ) { | 61 | void MediaPlayer::pauseCheck( bool b ) { |
55 | if ( b && !mediaPlayerState->playing() ) { | 62 | if ( b && !mediaPlayerState->playing() ) { |
56 | mediaPlayerState->setPaused( FALSE ); | 63 | mediaPlayerState->setPaused( FALSE ); |
57 | } | 64 | } |
58 | } | 65 | } |
59 | 66 | ||
60 | void MediaPlayer::play() { | 67 | void MediaPlayer::play() { |
61 | mediaPlayerState->setPlaying( FALSE ); | 68 | mediaPlayerState->setPlaying( FALSE ); |
62 | mediaPlayerState->setPlaying( TRUE ); | 69 | mediaPlayerState->setPlaying( TRUE ); |
63 | } | 70 | } |
64 | 71 | ||
65 | void MediaPlayer::setPlaying( bool play ) { | 72 | void MediaPlayer::setPlaying( bool play ) { |
66 | if ( !play ) { | 73 | if ( !play ) { |
67 | mediaPlayerState->setPaused( FALSE ); | 74 | mediaPlayerState->setPaused( FALSE ); |
68 | return; | 75 | return; |
69 | } | 76 | } |
70 | 77 | ||
71 | if ( mediaPlayerState->paused() ) { | 78 | if ( mediaPlayerState->paused() ) { |
72 | mediaPlayerState->setPaused( FALSE ); | 79 | mediaPlayerState->setPaused( FALSE ); |
73 | return; | 80 | return; |
74 | } | 81 | } |
75 | 82 | ||
76 | const DocLnk *playListCurrent = playList->current(); | 83 | const DocLnk *playListCurrent = playList->current(); |
77 | if ( playListCurrent != NULL ) { | 84 | if ( playListCurrent != NULL ) { |
78 | currentFile = playListCurrent; | 85 | currentFile = playListCurrent; |
79 | } | 86 | } |
80 | 87 | ||
81 | xineControl->play( currentFile->file() ); | 88 | xineControl->play( currentFile->file() ); |
82 | 89 | ||
83 | xineControl->length(); | 90 | xineControl->length(); |
84 | long seconds = mediaPlayerState->length();// | 91 | long seconds = mediaPlayerState->length();// |
85 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 92 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
86 | qDebug(time); | 93 | qDebug(time); |
87 | 94 | ||
88 | QString tickerText; | 95 | QString tickerText; |
89 | if( currentFile->file().left(4) == "http" ) | 96 | if( currentFile->file().left(4) == "http" ) |
90 | tickerText= tr( " File: " ) + currentFile->name(); | 97 | tickerText= tr( " File: " ) + currentFile->name(); |
91 | else | 98 | else |
92 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 99 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
93 | 100 | ||
94 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | 101 | // QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); |
95 | 102 | ||
96 | // if ( !fileInfo.isEmpty() ) | 103 | // if ( !fileInfo.isEmpty() ) |
97 | // tickerText += ", " + fileInfo; | 104 | // tickerText += ", " + fileInfo; |
98 | // audioUI->setTickerText( tickerText + "." ); | 105 | // audioUI->setTickerText( tickerText + "." ); |
99 | 106 | ||
100 | audioUI->setTickerText( currentFile->file( ) ); | 107 | audioUI->setTickerText( currentFile->file( ) ); |
101 | 108 | ||
102 | } | 109 | } |
103 | 110 | ||
104 | 111 | ||
105 | void MediaPlayer::prev() { | 112 | void MediaPlayer::prev() { |
106 | if ( playList->prev() ) { | 113 | if ( playList->prev() ) { |
107 | play(); | 114 | play(); |
108 | } else if ( mediaPlayerState->looping() ) { | 115 | } else if ( mediaPlayerState->looping() ) { |
109 | if ( playList->last() ) { | 116 | if ( playList->last() ) { |
110 | play(); | 117 | play(); |
111 | } | 118 | } |
112 | } else { | 119 | } else { |
113 | mediaPlayerState->setList(); | 120 | mediaPlayerState->setList(); |
114 | } | 121 | } |
115 | } | 122 | } |
116 | 123 | ||
117 | 124 | ||
118 | void MediaPlayer::next() { | 125 | void MediaPlayer::next() { |
119 | if ( playList->next() ) { | 126 | if ( playList->next() ) { |
120 | play(); | 127 | play(); |
121 | } else if ( mediaPlayerState->looping() ) { | 128 | } else if ( mediaPlayerState->looping() ) { |
122 | if ( playList->first() ) { | 129 | if ( playList->first() ) { |
123 | play(); | 130 | play(); |
124 | } | 131 | } |
125 | } else { | 132 | } else { |
126 | mediaPlayerState->setList(); | 133 | mediaPlayerState->setList(); |
127 | } | 134 | } |
128 | } | 135 | } |
129 | 136 | ||
130 | 137 | ||
131 | void MediaPlayer::startDecreasingVolume() { | 138 | void MediaPlayer::startDecreasingVolume() { |
132 | volumeDirection = -1; | 139 | volumeDirection = -1; |
133 | startTimer( 100 ); | 140 | startTimer( 100 ); |
134 | volControl->decVol(2); | 141 | volControl->decVol(2); |
135 | } | 142 | } |
136 | 143 | ||
137 | 144 | ||
138 | void MediaPlayer::startIncreasingVolume() { | 145 | void MediaPlayer::startIncreasingVolume() { |
139 | volumeDirection = +1; | 146 | volumeDirection = +1; |
140 | startTimer( 100 ); | 147 | startTimer( 100 ); |
141 | volControl->incVol(2); | 148 | volControl->incVol(2); |
142 | } | 149 | } |
143 | 150 | ||
144 | 151 | ||
145 | bool drawnOnScreenDisplay = FALSE; | 152 | bool drawnOnScreenDisplay = FALSE; |
146 | unsigned int onScreenDisplayVolume = 0; | 153 | unsigned int onScreenDisplayVolume = 0; |
147 | const int yoff = 110; | 154 | const int yoff = 110; |
148 | 155 | ||
149 | void MediaPlayer::stopChangingVolume() { | 156 | void MediaPlayer::stopChangingVolume() { |
150 | killTimers(); | 157 | killTimers(); |
151 | // Get rid of the on-screen display stuff | 158 | // Get rid of the on-screen display stuff |
152 | drawnOnScreenDisplay = FALSE; | 159 | drawnOnScreenDisplay = FALSE; |
153 | onScreenDisplayVolume = 0; | 160 | onScreenDisplayVolume = 0; |
154 | int w = audioUI->width(); | 161 | int w=0; |
155 | int h = audioUI->height(); | 162 | int h=0; |
156 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 163 | if( !xineControl->hasVideo()) { |
164 | w = audioUI->width(); | ||
165 | h = audioUI->height(); | ||
166 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | ||
167 | } else { | ||
168 | w = videoUI->width(); | ||
169 | h = videoUI->height(); | ||
170 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | ||
171 | } | ||
157 | } | 172 | } |
158 | 173 | ||
159 | 174 | ||
160 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 175 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
161 | if ( volumeDirection == +1 ) { | 176 | if ( volumeDirection == +1 ) { |
162 | volControl->incVol(2); | 177 | volControl->incVol(2); |
163 | } else if ( volumeDirection == -1 ) { | 178 | } else if ( volumeDirection == -1 ) { |
164 | volControl->decVol(2); | 179 | volControl->decVol(2); |
165 | } | 180 | } |
166 | 181 | ||
167 | 182 | ||
168 | // TODO FIXME | 183 | // TODO FIXME |
169 | int v; | 184 | int v; |
170 | v = volControl->getVolume(); | 185 | v = volControl->getVolume(); |
171 | v = v / 10; | 186 | v = v / 10; |
172 | 187 | ||
173 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 188 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
174 | return; | 189 | return; |
175 | } | ||
176 | |||
177 | int w = audioUI->width(); | ||
178 | int h = audioUI->height(); | ||
179 | |||
180 | if ( drawnOnScreenDisplay ) { | ||
181 | if ( onScreenDisplayVolume > v ) { | ||
182 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | ||
183 | } | ||
184 | } | 190 | } |
185 | 191 | ||
186 | drawnOnScreenDisplay = TRUE; | 192 | int w=0; int h=0; |
187 | onScreenDisplayVolume = v; | 193 | if( !xineControl->hasVideo()) { |
194 | w = audioUI->width(); | ||
195 | h = audioUI->height(); | ||
188 | 196 | ||
189 | QPainter p( audioUI ); | 197 | if ( drawnOnScreenDisplay ) { |
190 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 198 | if ( onScreenDisplayVolume > v ) { |
191 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 199 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
192 | 200 | } | |
193 | QFont f; | 201 | } |
194 | f.setPixelSize( 20 ); | 202 | drawnOnScreenDisplay = TRUE; |
195 | f.setBold( TRUE ); | 203 | onScreenDisplayVolume = v; |
196 | p.setFont( f ); | 204 | QPainter p( audioUI ); |
197 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 205 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
206 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | ||
207 | |||
208 | QFont f; | ||
209 | f.setPixelSize( 20 ); | ||
210 | f.setBold( TRUE ); | ||
211 | p.setFont( f ); | ||
212 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | ||
213 | |||
214 | for ( unsigned int i = 0; i < 10; i++ ) { | ||
215 | if ( v > i ) { | ||
216 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | ||
217 | } else { | ||
218 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | ||
219 | } | ||
220 | } | ||
221 | } else { | ||
222 | w = videoUI->width(); | ||
223 | h = videoUI->height(); | ||
198 | 224 | ||
199 | for ( unsigned int i = 0; i < 10; i++ ) { | 225 | if ( drawnOnScreenDisplay ) { |
200 | if ( v > i ) { | 226 | if ( onScreenDisplayVolume > v ) { |
201 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 227 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); |
202 | } else { | 228 | } |
203 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 229 | } |
230 | drawnOnScreenDisplay = TRUE; | ||
231 | onScreenDisplayVolume = v; | ||
232 | QPainter p( videoUI ); | ||
233 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | ||
234 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | ||
235 | |||
236 | QFont f; | ||
237 | f.setPixelSize( 20 ); | ||
238 | f.setBold( TRUE ); | ||
239 | p.setFont( f ); | ||
240 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | ||
241 | |||
242 | for ( unsigned int i = 0; i < 10; i++ ) { | ||
243 | if ( v > i ) { | ||
244 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | ||
245 | } else { | ||
246 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | ||
247 | } | ||
204 | } | 248 | } |
205 | } | 249 | } |
206 | } | 250 | } |
207 | 251 | ||
208 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 252 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
209 | switch ( e->key() ) { | 253 | switch ( e->key() ) { |
210 | ////////////////////////////// Zaurus keys | 254 | ////////////////////////////// Zaurus keys |
211 | case Key_Home: | 255 | case Key_Home: |
212 | break; | 256 | break; |
213 | case Key_F9: //activity | 257 | case Key_F9: //activity |
214 | break; | 258 | break; |
215 | case Key_F10: //contacts | 259 | case Key_F10: //contacts |
216 | break; | 260 | break; |
217 | case Key_F11: //menu | 261 | case Key_F11: //menu |
218 | break; | 262 | break; |
219 | case Key_F12: //home | 263 | case Key_F12: //home |
220 | qDebug("Blank here"); | 264 | qDebug("Blank here"); |
221 | break; | 265 | break; |
222 | case Key_F13: //mail | 266 | case Key_F13: //mail |
223 | break; | 267 | break; |
224 | } | 268 | } |
225 | } | 269 | } |
226 | 270 | ||
227 | void MediaPlayer::doBlank() { | 271 | void MediaPlayer::doBlank() { |
228 | 272 | ||
229 | } | 273 | } |
230 | 274 | ||
231 | void MediaPlayer::doUnblank() { | 275 | void MediaPlayer::doUnblank() { |
232 | 276 | ||
233 | } | 277 | } |
234 | 278 | ||
235 | void MediaPlayer::cleanUp() { | 279 | void MediaPlayer::cleanUp() { |
236 | // QPEApplication::grabKeyboard(); | 280 | // QPEApplication::grabKeyboard(); |
237 | // QPEApplication::ungrabKeyboard(); | 281 | // QPEApplication::ungrabKeyboard(); |
238 | 282 | ||
239 | } | 283 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 84ef3f3..17112a2 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -7,190 +7,194 @@ | |||
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include "xinecontrol.h" | 38 | #include "xinecontrol.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | #include "videowidget.h" | 40 | #include "videowidget.h" |
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
44 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( QObject *parent, const char *name ) |
45 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
46 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 46 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
47 | 47 | ||
48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
55 | 55 | ||
56 | disabledSuspendScreenSaver = FALSE; | 56 | disabledSuspendScreenSaver = FALSE; |
57 | } | 57 | } |
58 | 58 | ||
59 | XineControl::~XineControl() { | 59 | XineControl::~XineControl() { |
60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
61 | if ( disabledSuspendScreenSaver ) { | 61 | if ( disabledSuspendScreenSaver ) { |
62 | disabledSuspendScreenSaver = FALSE; | 62 | disabledSuspendScreenSaver = FALSE; |
63 | // Re-enable the suspend mode | 63 | // Re-enable the suspend mode |
64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
65 | } | 65 | } |
66 | #endif | 66 | #endif |
67 | delete libXine; | 67 | delete libXine; |
68 | } | 68 | } |
69 | 69 | ||
70 | void XineControl::play( const QString& fileName ) { | 70 | void XineControl::play( const QString& fileName ) { |
71 | hasVideoChannel=FALSE; | ||
72 | hasAudioChannel=FALSE; | ||
71 | m_fileName = fileName; | 73 | m_fileName = fileName; |
72 | libXine->play( fileName ); | 74 | libXine->play( fileName ); |
73 | mediaPlayerState->setPlaying( true ); | 75 | mediaPlayerState->setPlaying( true ); |
74 | // default to audio view until we know how to handle video | 76 | // default to audio view until we know how to handle video |
75 | // MediaDetect mdetect; | 77 | // MediaDetect mdetect; |
76 | char whichGui = mdetect.videoOrAudio( fileName ); | 78 | char whichGui = mdetect.videoOrAudio( fileName ); |
77 | if (whichGui == 'f') { | 79 | if (whichGui == 'f') { |
78 | qDebug("Nicht erkannter Dateityp"); | 80 | qDebug("Nicht erkannter Dateityp"); |
79 | return; | 81 | return; |
80 | } | 82 | } |
81 | 83 | ||
82 | if (whichGui == 'a') { | 84 | if (whichGui == 'a') { |
83 | libXine->setShowVideo( false ); | 85 | libXine->setShowVideo( false ); |
86 | hasAudioChannel=TRUE; | ||
84 | } else { | 87 | } else { |
85 | libXine->setShowVideo( true ); | 88 | libXine->setShowVideo( true ); |
89 | hasVideoChannel=TRUE; | ||
86 | } | 90 | } |
87 | 91 | ||
88 | // determine if slider is shown | 92 | // determine if slider is shown |
89 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | 93 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); |
90 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 94 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
91 | // which gui (video / audio) | 95 | // which gui (video / audio) |
92 | mediaPlayerState->setView( whichGui ); | 96 | mediaPlayerState->setView( whichGui ); |
93 | 97 | ||
94 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 98 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
95 | if ( !disabledSuspendScreenSaver ) { | 99 | if ( !disabledSuspendScreenSaver ) { |
96 | disabledSuspendScreenSaver = TRUE; | 100 | disabledSuspendScreenSaver = TRUE; |
97 | // Stop the screen from blanking and power saving state | 101 | // Stop the screen from blanking and power saving state |
98 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 102 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
99 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 103 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
100 | } | 104 | } |
101 | #endif | 105 | #endif |
102 | 106 | ||
103 | length(); | 107 | length(); |
104 | position(); | 108 | position(); |
105 | } | 109 | } |
106 | 110 | ||
107 | void XineControl::nextMedia() { | 111 | void XineControl::nextMedia() { |
108 | mediaPlayerState->setNext(); | 112 | mediaPlayerState->setNext(); |
109 | } | 113 | } |
110 | 114 | ||
111 | void XineControl::stop( bool isSet ) { | 115 | void XineControl::stop( bool isSet ) { |
112 | if ( !isSet) { | 116 | if ( !isSet) { |
113 | libXine->stop( ); | 117 | libXine->stop( ); |
114 | mediaPlayerState->setList(); | 118 | mediaPlayerState->setList(); |
115 | //mediaPlayerState->setPlaying( false ); | 119 | //mediaPlayerState->setPlaying( false ); |
116 | 120 | ||
117 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 121 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
118 | if ( disabledSuspendScreenSaver ) { | 122 | if ( disabledSuspendScreenSaver ) { |
119 | disabledSuspendScreenSaver = FALSE; | 123 | disabledSuspendScreenSaver = FALSE; |
120 | // Re-enable the suspend mode | 124 | // Re-enable the suspend mode |
121 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 125 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
122 | } | 126 | } |
123 | #endif | 127 | #endif |
124 | 128 | ||
125 | } else { | 129 | } else { |
126 | // play again | 130 | // play again |
127 | } | 131 | } |
128 | } | 132 | } |
129 | 133 | ||
130 | /** | 134 | /** |
131 | * Pause playback | 135 | * Pause playback |
132 | * @isSet | 136 | * @isSet |
133 | */ | 137 | */ |
134 | void XineControl::pause( bool isSet) { | 138 | void XineControl::pause( bool isSet) { |
135 | if (isSet) { | 139 | if (isSet) { |
136 | libXine->pause(); | 140 | libXine->pause(); |
137 | } else { | 141 | } else { |
138 | libXine->play( m_fileName, 0, m_currentTime); | 142 | libXine->play( m_fileName, 0, m_currentTime); |
139 | } | 143 | } |
140 | } | 144 | } |
141 | 145 | ||
142 | 146 | ||
143 | /** | 147 | /** |
144 | * get current time in playback | 148 | * get current time in playback |
145 | */ | 149 | */ |
146 | long XineControl::currentTime() { | 150 | long XineControl::currentTime() { |
147 | // todo: jede sekunde überprüfen | 151 | // todo: jede sekunde überprüfen |
148 | m_currentTime = libXine->currentTime(); | 152 | m_currentTime = libXine->currentTime(); |
149 | return m_currentTime; | 153 | return m_currentTime; |
150 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 154 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
151 | } | 155 | } |
152 | 156 | ||
153 | /** | 157 | /** |
154 | * Set the length of the media file | 158 | * Set the length of the media file |
155 | */ | 159 | */ |
156 | void XineControl::length() { | 160 | void XineControl::length() { |
157 | m_length = libXine->length(); | 161 | m_length = libXine->length(); |
158 | mediaPlayerState->setLength( m_length ); | 162 | mediaPlayerState->setLength( m_length ); |
159 | } | 163 | } |
160 | 164 | ||
161 | 165 | ||
162 | /** | 166 | /** |
163 | * Reports the position the xine backend is at right now | 167 | * Reports the position the xine backend is at right now |
164 | * @return long the postion in seconds | 168 | * @return long the postion in seconds |
165 | */ | 169 | */ |
166 | long XineControl::position() { | 170 | long XineControl::position() { |
167 | m_position = ( currentTime() ); | 171 | m_position = ( currentTime() ); |
168 | mediaPlayerState->updatePosition( m_position ); | 172 | mediaPlayerState->updatePosition( m_position ); |
169 | long emitPos = (long)m_position; | 173 | long emitPos = (long)m_position; |
170 | emit positionChanged( emitPos ); | 174 | emit positionChanged( emitPos ); |
171 | if(mediaPlayerState->isPlaying) | 175 | if(mediaPlayerState->isPlaying) |
172 | // needs to be stopped the media is stopped | 176 | // needs to be stopped the media is stopped |
173 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 177 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
174 | // qDebug("POSITION : %d", m_position); | 178 | // qDebug("POSITION : %d", m_position); |
175 | return m_position; | 179 | return m_position; |
176 | } | 180 | } |
177 | 181 | ||
178 | /** | 182 | /** |
179 | * Set videoplayback to fullscreen | 183 | * Set videoplayback to fullscreen |
180 | * @param isSet | 184 | * @param isSet |
181 | */ | 185 | */ |
182 | void XineControl::setFullscreen( bool isSet ) { | 186 | void XineControl::setFullscreen( bool isSet ) { |
183 | libXine->showVideoFullScreen( isSet); | 187 | libXine->showVideoFullScreen( isSet); |
184 | } | 188 | } |
185 | 189 | ||
186 | /** | 190 | /** |
187 | * Seek to a position in the track | 191 | * Seek to a position in the track |
188 | * @param second the second to jump to | 192 | * @param second the second to jump to |
189 | */ | 193 | */ |
190 | void XineControl::seekTo( long second ) { | 194 | void XineControl::seekTo( long second ) { |
191 | libXine->play( m_fileName , 0, (int)second ); | 195 | libXine->play( m_fileName , 0, (int)second ); |
192 | } | 196 | } |
193 | 197 | ||
194 | void XineControl::videoResized ( const QSize &s ) { | 198 | void XineControl::videoResized ( const QSize &s ) { |
195 | libXine-> resize ( s ); | 199 | libXine-> resize ( s ); |
196 | } | 200 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 9ad221e..88458be 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,74 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include "mediadetect.h" | 38 | #include "mediadetect.h" |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | class XineControl : public QObject { | 41 | class XineControl : public QObject { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | XineControl( QObject *parent = 0, const char *name =0 ); | 44 | XineControl( QObject *parent = 0, const char *name =0 ); |
45 | ~XineControl(); | 45 | ~XineControl(); |
46 | int m_length; | 46 | int m_length; |
47 | 47 | ||
48 | bool hasVideo() const { return hasVideoChannel; } | ||
49 | bool hasAudio() const { return hasAudioChannel; } | ||
50 | |||
48 | public slots: | 51 | public slots: |
49 | void play( const QString& fileName ); | 52 | void play( const QString& fileName ); |
50 | void stop( bool ); | 53 | void stop( bool ); |
51 | void pause( bool ); | 54 | void pause( bool ); |
52 | void setFullscreen( bool ); | 55 | void setFullscreen( bool ); |
53 | long currentTime(); | 56 | long currentTime(); |
54 | void seekTo( long ); | 57 | void seekTo( long ); |
55 | // get length of media file and set it | 58 | // get length of media file and set it |
56 | void length(); | 59 | void length(); |
57 | long position(); | 60 | long position(); |
58 | void nextMedia(); | 61 | void nextMedia(); |
59 | void videoResized ( const QSize &s ); | 62 | void videoResized ( const QSize &s ); |
60 | 63 | ||
61 | private: | 64 | private: |
62 | XINE::Lib *libXine; | 65 | XINE::Lib *libXine; |
63 | MediaDetect mdetect; | 66 | MediaDetect mdetect; |
64 | long m_currentTime; | 67 | long m_currentTime; |
65 | long m_position; | 68 | long m_position; |
66 | QString m_fileName; | 69 | QString m_fileName; |
67 | bool disabledSuspendScreenSaver; | 70 | bool disabledSuspendScreenSaver; |
71 | bool hasVideoChannel; | ||
72 | bool hasAudioChannel; | ||
68 | signals: | 73 | signals: |
69 | void positionChanged( long ); | 74 | void positionChanged( long ); |
70 | 75 | ||
71 | }; | 76 | }; |
72 | 77 | ||
73 | 78 | ||
74 | #endif | 79 | #endif |