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 | |||
@@ -6,23 +6,25 @@ | |||
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 | ||
@@ -37,16 +39,21 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | |||
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 | } |
@@ -146,66 +153,103 @@ 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: |
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 | |||
@@ -63,31 +63,35 @@ XineControl::~XineControl() { | |||
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 | ||
@@ -187,10 +191,10 @@ void XineControl::setFullscreen( bool isSet ) { | |||
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 | |||
@@ -40,16 +40,19 @@ | |||
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 |
@@ -60,15 +63,17 @@ public slots: | |||
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 |