summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-15 16:32:17 (UTC)
committer llornkcor <llornkcor>2002-08-15 16:32:17 (UTC)
commit07ea5f165a2f17f818147b2e8afb02af2c269b55 (patch) (unidiff)
tree94059e0b4910f5a681be601f554c5c3a6c26de4b
parent747a98bb3b2a92b6f3577fa383fc44a8644a7ce2 (diff)
downloadopie-07ea5f165a2f17f818147b2e8afb02af2c269b55.zip
opie-07ea5f165a2f17f818147b2e8afb02af2c269b55.tar.gz
opie-07ea5f165a2f17f818147b2e8afb02af2c269b55.tar.bz2
added useAudio() and useVideo()
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp106
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h5
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
@@ -8,19 +8,21 @@
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
20extern AudioWidget *audioUI; 21extern AudioWidget *audioUI;
22extern VideoWidget *videoUI;
21extern PlayListWidget *playList; 23extern PlayListWidget *playList;
22extern MediaPlayerState *mediaPlayerState; 24extern MediaPlayerState *mediaPlayerState;
23 25
24 26
25MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 27MediaPlayer::MediaPlayer( QObject *parent, const char *name )
26 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 28 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
@@ -39,12 +41,17 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name )
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
49MediaPlayer::~MediaPlayer() { 56MediaPlayer::~MediaPlayer() {
50 delete xineControl; 57 delete xineControl;
@@ -148,62 +155,99 @@ const int yoff = 110;
148 155
149void MediaPlayer::stopChangingVolume() { 156void 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
160void MediaPlayer::timerEvent( QTimerEvent * ) { 175void 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
208void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 252void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
209 switch ( e->key() ) { 253 switch ( e->key() ) {
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
@@ -65,12 +65,14 @@ XineControl::~XineControl() {
65 } 65 }
66#endif 66#endif
67 delete libXine; 67 delete libXine;
68} 68}
69 69
70void XineControl::play( const QString& fileName ) { 70void 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 );
@@ -78,14 +80,16 @@ void XineControl::play( const QString& fileName ) {
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)
@@ -189,8 +193,8 @@ void XineControl::setFullscreen( bool isSet ) {
189 */ 193 */
190void XineControl::seekTo( long second ) { 194void XineControl::seekTo( long second ) {
191 libXine->play( m_fileName , 0, (int)second ); 195 libXine->play( m_fileName , 0, (int)second );
192} 196}
193 197
194void XineControl::videoResized ( const QSize &s ) { 198void 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
@@ -42,12 +42,15 @@ class XineControl : public QObject {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
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
48public slots: 51public 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();
@@ -62,12 +65,14 @@ 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;
68signals: 73signals:
69 void positionChanged( long ); 74 void positionChanged( long );
70 75
71}; 76};
72 77
73 78