-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 2 |
3 files changed, 16 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 23f4329..0e9e7ea 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,468 +1,468 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.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 <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qbutton.h> | 8 | #include <qbutton.h> |
9 | #include <qpainter.h> | 9 | #include <qpainter.h> |
10 | #include <qframe.h> | 10 | #include <qframe.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | 12 | ||
13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | 15 | ||
16 | #include "audiowidget.h" | 16 | #include "audiowidget.h" |
17 | #include "mediaplayerstate.h" | 17 | #include "mediaplayerstate.h" |
18 | 18 | ||
19 | extern MediaPlayerState *mediaPlayerState; | 19 | extern MediaPlayerState *mediaPlayerState; |
20 | 20 | ||
21 | static const int xo = -2; // movable x offset | 21 | static const int xo = -2; // movable x offset |
22 | static const int yo = 22; // movable y offset | 22 | static const int yo = 22; // movable y offset |
23 | 23 | ||
24 | 24 | ||
25 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 25 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
26 | setFrameStyle( WinPanel | Sunken ); | 26 | setFrameStyle( WinPanel | Sunken ); |
27 | setText( "No Song" ); | 27 | setText( "No Song" ); |
28 | } | 28 | } |
29 | 29 | ||
30 | Ticker::~Ticker() { | 30 | Ticker::~Ticker() { |
31 | } | 31 | } |
32 | 32 | ||
33 | void Ticker::setText( const QString& text ) { | 33 | void Ticker::setText( const QString& text ) { |
34 | pos = 0; // reset it everytime the text is changed | 34 | pos = 0; // reset it everytime the text is changed |
35 | scrollText = text; | 35 | scrollText = text; |
36 | pixelLen = fontMetrics().width( scrollText ); | 36 | pixelLen = fontMetrics().width( scrollText ); |
37 | killTimers(); | 37 | killTimers(); |
38 | if ( pixelLen > width() ) { | 38 | if ( pixelLen > width() ) { |
39 | startTimer( 50 ); | 39 | startTimer( 50 ); |
40 | } | 40 | } |
41 | update(); | 41 | update(); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | void Ticker::timerEvent( QTimerEvent * ) { | 45 | void Ticker::timerEvent( QTimerEvent * ) { |
46 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 46 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
47 | scroll( -1, 0, contentsRect() ); | 47 | scroll( -1, 0, contentsRect() ); |
48 | repaint( FALSE ); | 48 | repaint( FALSE ); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Ticker::drawContents( QPainter *p ) { | 51 | void Ticker::drawContents( QPainter *p ) { |
52 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 52 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 53 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
54 | QPixmap pm( width(), height() ); | 54 | QPixmap pm( width(), height() ); |
55 | pm.fill( colorGroup().base() ); | 55 | pm.fill( colorGroup().base() ); |
56 | QPainter pmp( &pm ); | 56 | QPainter pmp( &pm ); |
57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 57 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 58 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
59 | } | 59 | } |
60 | p->drawPixmap( 0, 0, pm ); | 60 | p->drawPixmap( 0, 0, pm ); |
61 | } | 61 | } |
62 | 62 | ||
63 | struct MediaButton { | 63 | struct MediaButton { |
64 | bool isToggle, isHeld, isDown; | 64 | bool isToggle, isHeld, isDown; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | //Layout information for the audioButtons (and if it is a toggle button or not) | 67 | //Layout information for the audioButtons (and if it is a toggle button or not) |
68 | MediaButton audioButtons[] = { | 68 | MediaButton audioButtons[] = { |
69 | { TRUE, FALSE, FALSE }, // play | 69 | { TRUE, FALSE, FALSE }, // play |
70 | { FALSE, FALSE, FALSE }, // stop | 70 | { FALSE, FALSE, FALSE }, // stop |
71 | { TRUE, FALSE, FALSE }, // pause | 71 | { TRUE, FALSE, FALSE }, // pause |
72 | { FALSE, FALSE, FALSE }, // next | 72 | { FALSE, FALSE, FALSE }, // next |
73 | { FALSE, FALSE, FALSE }, // previous | 73 | { FALSE, FALSE, FALSE }, // previous |
74 | { FALSE, FALSE, FALSE }, // volume up | 74 | { FALSE, FALSE, FALSE }, // volume up |
75 | { FALSE, FALSE, FALSE }, // volume down | 75 | { FALSE, FALSE, FALSE }, // volume down |
76 | { TRUE, FALSE, FALSE }, // repeat/loop | 76 | { TRUE, FALSE, FALSE }, // repeat/loop |
77 | { FALSE, FALSE, FALSE }, // playlist | 77 | { FALSE, FALSE, FALSE }, // playlist |
78 | { FALSE, FALSE, FALSE }, // forward | 78 | { FALSE, FALSE, FALSE }, // forward |
79 | { FALSE, FALSE, FALSE } // back | 79 | { FALSE, FALSE, FALSE } // back |
80 | }; | 80 | }; |
81 | 81 | ||
82 | const char *skin_mask_file_names[11] = { | 82 | const char *skin_mask_file_names[11] = { |
83 | "play", "stop", "pause", "next", "prev", "up", | 83 | "play", "stop", "pause", "next", "prev", "up", |
84 | "down", "loop", "playlist", "forward", "back" | 84 | "down", "loop", "playlist", "forward", "back" |
85 | }; | 85 | }; |
86 | 86 | ||
87 | 87 | ||
88 | static void changeTextColor( QWidget *w ) { | 88 | static void changeTextColor( QWidget *w ) { |
89 | QPalette p = w->palette(); | 89 | QPalette p = w->palette(); |
90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 90 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 91 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
92 | w->setPalette( p ); | 92 | w->setPalette( p ); |
93 | } | 93 | } |
94 | 94 | ||
95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
96 | 96 | ||
97 | 97 | ||
98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 98 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 99 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
100 | setCaption( tr("OpiePlayer") ); | 100 | setCaption( tr("OpiePlayer") ); |
101 | 101 | ||
102 | Config cfg("OpiePlayer"); | 102 | Config cfg("OpiePlayer"); |
103 | cfg.setGroup("AudioWidget"); | 103 | cfg.setGroup("AudioWidget"); |
104 | skin = cfg.readEntry("Skin","default"); | 104 | skin = cfg.readEntry("Skin","default"); |
105 | //skin = "scaleTest"; | 105 | //skin = "scaleTest"; |
106 | // color of background, frame, degree of transparency | 106 | // color of background, frame, degree of transparency |
107 | 107 | ||
108 | QString skinPath = "opieplayer/skins/" + skin; | 108 | QString skinPath = "opieplayer/skins/" + skin; |
109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 109 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 110 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 111 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
112 | 112 | ||
113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 113 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
114 | imgButtonMask->fill( 0 ); | 114 | imgButtonMask->fill( 0 ); |
115 | 115 | ||
116 | for ( int i = 0; i < 11; i++ ) { | 116 | for ( int i = 0; i < 11; i++ ) { |
117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; | 117 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; |
118 | masks[i] = new QBitmap( filename ); | 118 | masks[i] = new QBitmap( filename ); |
119 | 119 | ||
120 | if ( !masks[i]->isNull() ) { | 120 | if ( !masks[i]->isNull() ) { |
121 | QImage imgMask = masks[i]->convertToImage(); | 121 | QImage imgMask = masks[i]->convertToImage(); |
122 | uchar **dest = imgButtonMask->jumpTable(); | 122 | uchar **dest = imgButtonMask->jumpTable(); |
123 | for ( int y = 0; y < imgUp->height(); y++ ) { | 123 | for ( int y = 0; y < imgUp->height(); y++ ) { |
124 | uchar *line = dest[y]; | 124 | uchar *line = dest[y]; |
125 | for ( int x = 0; x < imgUp->width(); x++ ) | 125 | for ( int x = 0; x < imgUp->width(); x++ ) |
126 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 126 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
127 | line[x] = i + 1; | 127 | line[x] = i + 1; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | for ( int i = 0; i < 11; i++ ) { | 133 | for ( int i = 0; i < 11; i++ ) { |
134 | buttonPixUp[i] = NULL; | 134 | buttonPixUp[i] = NULL; |
135 | buttonPixDown[i] = NULL; | 135 | buttonPixDown[i] = NULL; |
136 | } | 136 | } |
137 | 137 | ||
138 | setBackgroundPixmap( *pixBg ); | 138 | setBackgroundPixmap( *pixBg ); |
139 | 139 | ||
140 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 140 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
141 | changeTextColor( &songInfo ); | 141 | changeTextColor( &songInfo ); |
142 | 142 | ||
143 | slider.setFixedHeight( 20 ); | 143 | slider.setFixedHeight( 20 ); |
144 | slider.setMinValue( 0 ); | 144 | slider.setMinValue( 0 ); |
145 | slider.setMaxValue( 1 ); | 145 | slider.setMaxValue( 1 ); |
146 | slider.setFocusPolicy( QWidget::NoFocus ); | 146 | slider.setFocusPolicy( QWidget::NoFocus ); |
147 | slider.setBackgroundPixmap( *pixBg ); | 147 | slider.setBackgroundPixmap( *pixBg ); |
148 | 148 | ||
149 | time.setFocusPolicy( QWidget::NoFocus ); | 149 | time.setFocusPolicy( QWidget::NoFocus ); |
150 | time.setAlignment( Qt::AlignCenter ); | 150 | time.setAlignment( Qt::AlignCenter ); |
151 | time.setFrame(FALSE); | 151 | time.setFrame(FALSE); |
152 | changeTextColor( &time ); | 152 | changeTextColor( &time ); |
153 | 153 | ||
154 | resizeEvent( NULL ); | 154 | resizeEvent( NULL ); |
155 | 155 | ||
156 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 156 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
157 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 157 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
158 | 158 | ||
159 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 159 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
160 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 160 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
161 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 161 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
162 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 162 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
163 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 163 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
164 | 164 | ||
165 | // Intialise state | 165 | // Intialise state |
166 | setLength( mediaPlayerState->length() ); | 166 | setLength( mediaPlayerState->length() ); |
167 | setPosition( mediaPlayerState->position() ); | 167 | setPosition( mediaPlayerState->position() ); |
168 | setLooping( mediaPlayerState->fullscreen() ); | 168 | setLooping( mediaPlayerState->fullscreen() ); |
169 | setPaused( mediaPlayerState->paused() ); | 169 | setPaused( mediaPlayerState->paused() ); |
170 | setPlaying( mediaPlayerState->playing() ); | 170 | setPlaying( mediaPlayerState->playing() ); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | AudioWidget::~AudioWidget() { | 174 | AudioWidget::~AudioWidget() { |
175 | 175 | ||
176 | for ( int i = 0; i < 11; i++ ) { | 176 | for ( int i = 0; i < 11; i++ ) { |
177 | delete buttonPixUp[i]; | 177 | delete buttonPixUp[i]; |
178 | delete buttonPixDown[i]; | 178 | delete buttonPixDown[i]; |
179 | } | 179 | } |
180 | delete pixBg; | 180 | delete pixBg; |
181 | delete imgUp; | 181 | delete imgUp; |
182 | delete imgDn; | 182 | delete imgDn; |
183 | delete imgButtonMask; | 183 | delete imgButtonMask; |
184 | for ( int i = 0; i < 11; i++ ) { | 184 | for ( int i = 0; i < 11; i++ ) { |
185 | delete masks[i]; | 185 | delete masks[i]; |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 189 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
190 | QPixmap pix( img.width(), img.height() ); | 190 | QPixmap pix( img.width(), img.height() ); |
191 | QPainter p( &pix ); | 191 | QPainter p( &pix ); |
192 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 192 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
193 | p.drawImage( 0, 0, img ); | 193 | p.drawImage( 0, 0, img ); |
194 | return new QPixmap( pix ); | 194 | return new QPixmap( pix ); |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | 198 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) |
199 | { | 199 | { |
200 | QPixmap *pixmap = new QPixmap( pix ); | 200 | QPixmap *pixmap = new QPixmap( pix ); |
201 | pixmap->setMask( mask ); | 201 | pixmap->setMask( mask ); |
202 | return pixmap; | 202 | return pixmap; |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | 206 | ||
207 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 207 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
208 | int h = height(); | 208 | int h = height(); |
209 | int w = width(); | 209 | int w = width(); |
210 | 210 | ||
211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 211 | songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
212 | slider.setFixedWidth( w - 110 ); | 212 | slider.setFixedWidth( w - 110 ); |
213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 213 | slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
216 | 216 | ||
217 | xoff = ( w - imgUp->width() ) / 2; | 217 | xoff = ( w - imgUp->width() ) / 2; |
218 | yoff = (( h - imgUp->height() ) / 2) - 10; | 218 | yoff = (( h - imgUp->height() ) / 2) - 10; |
219 | QPoint p( xoff, yoff ); | 219 | QPoint p( xoff, yoff ); |
220 | 220 | ||
221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 221 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 222 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
223 | 223 | ||
224 | for ( int i = 0; i < 11; i++ ) { | 224 | for ( int i = 0; i < 11; i++ ) { |
225 | if ( !masks[i]->isNull() ) { | 225 | if ( !masks[i]->isNull() ) { |
226 | delete buttonPixUp[i]; | 226 | delete buttonPixUp[i]; |
227 | delete buttonPixDown[i]; | 227 | delete buttonPixDown[i]; |
228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 228 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 229 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | delete pixUp; | 233 | delete pixUp; |
234 | delete pixDn; | 234 | delete pixDn; |
235 | } | 235 | } |
236 | 236 | ||
237 | static bool audioSliderBeingMoved = FALSE; | 237 | static bool audioSliderBeingMoved = FALSE; |
238 | 238 | ||
239 | 239 | ||
240 | void AudioWidget::sliderPressed() { | 240 | void AudioWidget::sliderPressed() { |
241 | audioSliderBeingMoved = TRUE; | 241 | audioSliderBeingMoved = TRUE; |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | void AudioWidget::sliderReleased() { | 245 | void AudioWidget::sliderReleased() { |
246 | audioSliderBeingMoved = FALSE; | 246 | audioSliderBeingMoved = FALSE; |
247 | if ( slider.width() == 0 ) | 247 | if ( slider.width() == 0 ) |
248 | return; | 248 | return; |
249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 249 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
250 | mediaPlayerState->setPosition( val ); | 250 | mediaPlayerState->setPosition( val ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void AudioWidget::setPosition( long i ) { | 253 | void AudioWidget::setPosition( long i ) { |
254 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 254 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
255 | updateSlider( i, mediaPlayerState->length() ); | 255 | updateSlider( i, mediaPlayerState->length() ); |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AudioWidget::setLength( long max ) { | 259 | void AudioWidget::setLength( long max ) { |
260 | updateSlider( mediaPlayerState->position(), max ); | 260 | updateSlider( mediaPlayerState->position(), max ); |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | void AudioWidget::setView( char view ) { | 264 | void AudioWidget::setView( char view ) { |
265 | slider.show(); | 265 | slider.show(); |
266 | 266 | ||
267 | // this isnt working for some reason | 267 | // this isnt working for some reason |
268 | 268 | ||
269 | // if ( mediaPlayerState->streaming() ) { | 269 | // if ( mediaPlayerState->streaming() ) { |
270 | // qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 270 | // qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
271 | // if( !slider.isHidden()) slider.hide(); | 271 | // if( !slider.isHidden()) slider.hide(); |
272 | // disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 272 | // disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
273 | // disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 273 | // disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
274 | // } else { | 274 | // } else { |
275 | // this stops the slider from being moved, thus | 275 | // this stops the slider from being moved, thus |
276 | // does not stop stream when it reaches the end | 276 | // does not stop stream when it reaches the end |
277 | slider.show(); | 277 | // slider.show(); |
278 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 278 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
279 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 279 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
280 | // } | 280 | // } |
281 | 281 | ||
282 | if ( view == 'a' ) { | 282 | if ( view == 'a' ) { |
283 | startTimer( 150 ); | 283 | startTimer( 150 ); |
284 | showMaximized(); | 284 | showMaximized(); |
285 | } else { | 285 | } else { |
286 | killTimers(); | 286 | killTimers(); |
287 | hide(); | 287 | hide(); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | 291 | ||
292 | static QString timeAsString( long length ) { | 292 | static QString timeAsString( long length ) { |
293 | int minutes = length / 60; | 293 | int minutes = length / 60; |
294 | int seconds = length % 60; | 294 | int seconds = length % 60; |
295 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 295 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
296 | } | 296 | } |
297 | 297 | ||
298 | void AudioWidget::updateSlider( long i, long max ) { | 298 | void AudioWidget::updateSlider( long i, long max ) { |
299 | 299 | ||
300 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 300 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
301 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 301 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
302 | 302 | ||
303 | if ( max == 0 ) { | 303 | if ( max == 0 ) { |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | // Will flicker too much if we don't do this | 306 | // Will flicker too much if we don't do this |
307 | // Scale to something reasonable | 307 | // Scale to something reasonable |
308 | int width = slider.width(); | 308 | int width = slider.width(); |
309 | int val = int((double)i * width / max); | 309 | int val = int((double)i * width / max); |
310 | if ( !audioSliderBeingMoved ) { | 310 | if ( !audioSliderBeingMoved ) { |
311 | if ( slider.value() != val ) { | 311 | if ( slider.value() != val ) { |
312 | slider.setValue( val ); | 312 | slider.setValue( val ); |
313 | } | 313 | } |
314 | 314 | ||
315 | if ( slider.maxValue() != width ) { | 315 | if ( slider.maxValue() != width ) { |
316 | slider.setMaxValue( width ); | 316 | slider.setMaxValue( width ); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void AudioWidget::setToggleButton( int i, bool down ) { | 322 | void AudioWidget::setToggleButton( int i, bool down ) { |
323 | if ( down != audioButtons[i].isDown ) { | 323 | if ( down != audioButtons[i].isDown ) { |
324 | toggleButton( i ); | 324 | toggleButton( i ); |
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void AudioWidget::toggleButton( int i ) { | 329 | void AudioWidget::toggleButton( int i ) { |
330 | audioButtons[i].isDown = !audioButtons[i].isDown; | 330 | audioButtons[i].isDown = !audioButtons[i].isDown; |
331 | QPainter p(this); | 331 | QPainter p(this); |
332 | paintButton ( &p, i ); | 332 | paintButton ( &p, i ); |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | void AudioWidget::paintButton( QPainter *p, int i ) { | 336 | void AudioWidget::paintButton( QPainter *p, int i ) { |
337 | if ( audioButtons[i].isDown ) | 337 | if ( audioButtons[i].isDown ) |
338 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 338 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
339 | else | 339 | else |
340 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 340 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | void AudioWidget::timerEvent( QTimerEvent * ) { | 344 | void AudioWidget::timerEvent( QTimerEvent * ) { |
345 | // static int frame = 0; | 345 | // static int frame = 0; |
346 | // if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 346 | // if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
347 | // frame = frame >= 7 ? 0 : frame + 1; | 347 | // frame = frame >= 7 ? 0 : frame + 1; |
348 | // } | 348 | // } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 352 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
353 | for ( int i = 0; i < numButtons; i++ ) { | 353 | for ( int i = 0; i < numButtons; i++ ) { |
354 | if ( event->state() == QMouseEvent::LeftButton ) { | 354 | if ( event->state() == QMouseEvent::LeftButton ) { |
355 | 355 | ||
356 | // The test to see if the mouse click is inside the button or not | 356 | // The test to see if the mouse click is inside the button or not |
357 | int x = event->pos().x() - xoff; | 357 | int x = event->pos().x() - xoff; |
358 | int y = event->pos().y() - yoff; | 358 | int y = event->pos().y() - yoff; |
359 | 359 | ||
360 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 360 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
361 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 361 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
362 | 362 | ||
363 | if ( isOnButton && i == AudioVolumeUp ) | 363 | if ( isOnButton && i == AudioVolumeUp ) |
364 | qDebug("on up"); | 364 | qDebug("on up"); |
365 | 365 | ||
366 | if ( isOnButton && !audioButtons[i].isHeld ) { | 366 | if ( isOnButton && !audioButtons[i].isHeld ) { |
367 | audioButtons[i].isHeld = TRUE; | 367 | audioButtons[i].isHeld = TRUE; |
368 | toggleButton(i); | 368 | toggleButton(i); |
369 | switch (i) { | 369 | switch (i) { |
370 | case AudioVolumeUp: | 370 | case AudioVolumeUp: |
371 | qDebug("more clicked"); | 371 | qDebug("more clicked"); |
372 | emit moreClicked(); | 372 | emit moreClicked(); |
373 | return; | 373 | return; |
374 | case AudioVolumeDown: emit lessClicked(); return; | 374 | case AudioVolumeDown: emit lessClicked(); return; |
375 | } | 375 | } |
376 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 376 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
377 | audioButtons[i].isHeld = FALSE; | 377 | audioButtons[i].isHeld = FALSE; |
378 | toggleButton(i); | 378 | toggleButton(i); |
379 | } | 379 | } |
380 | } else { | 380 | } else { |
381 | if ( audioButtons[i].isHeld ) { | 381 | if ( audioButtons[i].isHeld ) { |
382 | audioButtons[i].isHeld = FALSE; | 382 | audioButtons[i].isHeld = FALSE; |
383 | if ( !audioButtons[i].isToggle ) | 383 | if ( !audioButtons[i].isToggle ) |
384 | setToggleButton( i, FALSE ); | 384 | setToggleButton( i, FALSE ); |
385 | switch (i) { | 385 | switch (i) { |
386 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 386 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
387 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 387 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
388 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 388 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
389 | case AudioNext: mediaPlayerState->setNext(); return; | 389 | case AudioNext: mediaPlayerState->setNext(); return; |
390 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 390 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
391 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 391 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
392 | case AudioVolumeUp: emit moreReleased(); return; | 392 | case AudioVolumeUp: emit moreReleased(); return; |
393 | case AudioVolumeDown: emit lessReleased(); return; | 393 | case AudioVolumeDown: emit lessReleased(); return; |
394 | case AudioPlayList: mediaPlayerState->setList(); return; | 394 | case AudioPlayList: mediaPlayerState->setList(); return; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 402 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
403 | mouseMoveEvent( event ); | 403 | mouseMoveEvent( event ); |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 407 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
408 | mouseMoveEvent( event ); | 408 | mouseMoveEvent( event ); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AudioWidget::showEvent( QShowEvent* ) { | 412 | void AudioWidget::showEvent( QShowEvent* ) { |
413 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 413 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
414 | mouseMoveEvent( &event ); | 414 | mouseMoveEvent( &event ); |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void AudioWidget::closeEvent( QCloseEvent* ) { | 418 | void AudioWidget::closeEvent( QCloseEvent* ) { |
419 | mediaPlayerState->setList(); | 419 | mediaPlayerState->setList(); |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 423 | void AudioWidget::paintEvent( QPaintEvent * pe) { |
424 | if ( !pe->erased() ) { | 424 | if ( !pe->erased() ) { |
425 | // Combine with background and double buffer | 425 | // Combine with background and double buffer |
426 | QPixmap pix( pe->rect().size() ); | 426 | QPixmap pix( pe->rect().size() ); |
427 | QPainter p( &pix ); | 427 | QPainter p( &pix ); |
428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
430 | for ( int i = 0; i < numButtons; i++ ) | 430 | for ( int i = 0; i < numButtons; i++ ) |
431 | paintButton( &p, i ); | 431 | paintButton( &p, i ); |
432 | QPainter p2( this ); | 432 | QPainter p2( this ); |
433 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
434 | } else { | 434 | } else { |
435 | QPainter p( this ); | 435 | QPainter p( this ); |
436 | for ( int i = 0; i < numButtons; i++ ) | 436 | for ( int i = 0; i < numButtons; i++ ) |
437 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 441 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
442 | { | 442 | { |
443 | switch ( e->key() ) { | 443 | switch ( e->key() ) { |
444 | ////////////////////////////// Zaurus keys | 444 | ////////////////////////////// Zaurus keys |
445 | case Key_Home: | 445 | case Key_Home: |
446 | break; | 446 | break; |
447 | case Key_F9: //activity | 447 | case Key_F9: //activity |
448 | hide(); | 448 | hide(); |
449 | // qDebug("Audio F9"); | 449 | // qDebug("Audio F9"); |
450 | break; | 450 | break; |
451 | case Key_F10: //contacts | 451 | case Key_F10: //contacts |
452 | break; | 452 | break; |
453 | case Key_F11: //menu | 453 | case Key_F11: //menu |
454 | break; | 454 | break; |
455 | case Key_F12: //home | 455 | case Key_F12: //home |
456 | break; | 456 | break; |
457 | case Key_F13: //mail | 457 | case Key_F13: //mail |
458 | break; | 458 | break; |
459 | case Key_Space: { | 459 | case Key_Space: { |
460 | if(mediaPlayerState->playing()) { | 460 | if(mediaPlayerState->playing()) { |
461 | // toggleButton(1); | 461 | // toggleButton(1); |
462 | mediaPlayerState->setPlaying(FALSE); | 462 | mediaPlayerState->setPlaying(FALSE); |
463 | // toggleButton(1); | 463 | // toggleButton(1); |
464 | } else { | 464 | } else { |
465 | // toggleButton(0); | 465 | // toggleButton(0); |
466 | mediaPlayerState->setPlaying(TRUE); | 466 | mediaPlayerState->setPlaying(TRUE); |
467 | // toggleButton(0); | 467 | // toggleButton(0); |
468 | } | 468 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 33889d0..d08ff04 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,136 +1,137 @@ | |||
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 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include "xinecontrol.h" | 36 | #include "xinecontrol.h" |
37 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
38 | #include "videowidget.h" | 38 | #include "videowidget.h" |
39 | 39 | ||
40 | extern MediaPlayerState *mediaPlayerState; | 40 | extern MediaPlayerState *mediaPlayerState; |
41 | extern VideoWidget *videoUI; | 41 | extern VideoWidget *videoUI; |
42 | XineControl::XineControl( QObject *parent, const char *name ) | 42 | XineControl::XineControl( QObject *parent, const char *name ) |
43 | : QObject( parent, name ) { | 43 | : QObject( parent, name ) { |
44 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 44 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
45 | 45 | ||
46 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 46 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
47 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 47 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
48 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 48 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
49 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( setPosition( long ) ) ); | ||
50 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
53 | 52 | ||
54 | } | 53 | } |
55 | 54 | ||
56 | XineControl::~XineControl() { | 55 | XineControl::~XineControl() { |
57 | delete libXine; | 56 | delete libXine; |
58 | } | 57 | } |
59 | 58 | ||
60 | void XineControl::play( const QString& fileName ) { | 59 | void XineControl::play( const QString& fileName ) { |
60 | m_fileName = fileName; | ||
61 | libXine->play( fileName ); | 61 | libXine->play( fileName ); |
62 | mediaPlayerState->setPlaying( true ); | 62 | mediaPlayerState->setPlaying( true ); |
63 | // default to audio view until we know how to handle video | 63 | // default to audio view until we know how to handle video |
64 | // MediaDetect mdetect; | 64 | // MediaDetect mdetect; |
65 | char whichGui = mdetect.videoOrAudio( fileName ); | 65 | char whichGui = mdetect.videoOrAudio( fileName ); |
66 | if (whichGui == 'f') { | 66 | if (whichGui == 'f') { |
67 | qDebug("Nicht erkannter Dateityp"); | 67 | qDebug("Nicht erkannter Dateityp"); |
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | 70 | ||
71 | if (whichGui == 'a') { | 71 | if (whichGui == 'a') { |
72 | libXine->setShowVideo( false ); | 72 | libXine->setShowVideo( false ); |
73 | } else { | 73 | } else { |
74 | libXine->setShowVideo( true ); | 74 | libXine->setShowVideo( true ); |
75 | } | 75 | } |
76 | 76 | ||
77 | // determine if slider is shown | 77 | // determine if slider is shown |
78 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | 78 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); |
79 | mediaPlayerState->setIsStreaming( libXine->isSeekable() ); | 79 | mediaPlayerState->setIsStreaming( libXine->isSeekable() ); |
80 | // which gui (video / audio) | 80 | // which gui (video / audio) |
81 | mediaPlayerState->setView( whichGui ); | 81 | mediaPlayerState->setView( whichGui ); |
82 | length(); | 82 | length(); |
83 | position(); | 83 | position(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void XineControl::stop( bool isSet ) { | 86 | void XineControl::stop( bool isSet ) { |
87 | if ( !isSet) { | 87 | if ( !isSet) { |
88 | libXine->stop(); | 88 | libXine->stop(); |
89 | mediaPlayerState->setList(); | 89 | mediaPlayerState->setList(); |
90 | //mediaPlayerState->setPlaying( false ); | 90 | //mediaPlayerState->setPlaying( false ); |
91 | } else { | 91 | } else { |
92 | // play again | 92 | // play again |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void XineControl::pause( bool isSet) { | 96 | void XineControl::pause( bool isSet) { |
97 | libXine->pause(); | 97 | libXine->pause(); |
98 | } | 98 | } |
99 | 99 | ||
100 | long XineControl::currentTime() { | 100 | long XineControl::currentTime() { |
101 | // todo: jede sekunde überprüfen | 101 | // todo: jede sekunde überprüfen |
102 | m_currentTime = libXine->currentTime(); | 102 | m_currentTime = libXine->currentTime(); |
103 | return m_currentTime; | 103 | return m_currentTime; |
104 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 104 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void XineControl::length() { | 107 | void XineControl::length() { |
108 | m_length = libXine->length(); | 108 | m_length = libXine->length(); |
109 | mediaPlayerState->setLength( m_length ); | 109 | mediaPlayerState->setLength( m_length ); |
110 | } | 110 | } |
111 | 111 | ||
112 | long XineControl::position() { | 112 | long XineControl::position() { |
113 | m_position = ( currentTime() ); | 113 | m_position = ( currentTime() ); |
114 | mediaPlayerState->setPosition( m_position ); | 114 | mediaPlayerState->updatePosition( m_position ); |
115 | long emitPos = (long)m_position; | 115 | long emitPos = (long)m_position; |
116 | emit positionChanged( emitPos ); | 116 | emit positionChanged( emitPos ); |
117 | if(mediaPlayerState->isPlaying) | 117 | if(mediaPlayerState->isPlaying) |
118 | // needs to be stopped the media is stopped | 118 | // needs to be stopped the media is stopped |
119 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 119 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
120 | // qDebug("POSITION : %d", m_position); | 120 | // qDebug("POSITION : %d", m_position); |
121 | return m_position; | 121 | return m_position; |
122 | } | 122 | } |
123 | 123 | ||
124 | void XineControl::setFullscreen( bool isSet ) { | 124 | void XineControl::setFullscreen( bool isSet ) { |
125 | libXine->showVideoFullScreen( isSet); | 125 | libXine->showVideoFullScreen( isSet); |
126 | } | 126 | } |
127 | 127 | ||
128 | void XineControl::seekTo( long second ) { | 128 | void XineControl::seekTo( long second ) { |
129 | // libXine-> | 129 | qDebug("seek triggered!!"); |
130 | libXine->play( m_fileName , 0, (int)second ); | ||
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | void XineControl::videoResized ( const QSize &s ) | 134 | void XineControl::videoResized ( const QSize &s ) |
134 | { | 135 | { |
135 | libXine-> resize ( s ); | 136 | libXine-> resize ( s ); |
136 | } | 137 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 4a61f32..c7aefd4 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,73 +1,73 @@ | |||
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 | public slots: | 48 | public slots: |
49 | void play( const QString& fileName ); | 49 | void play( const QString& fileName ); |
50 | void stop( bool ); | 50 | void stop( bool ); |
51 | void pause( bool ); | 51 | void pause( bool ); |
52 | void setFullscreen( bool ); | 52 | void setFullscreen( bool ); |
53 | long currentTime(); | 53 | long currentTime(); |
54 | void seekTo( long ); | 54 | void seekTo( long ); |
55 | // get length of media file and set it | 55 | // get length of media file and set it |
56 | void length(); | 56 | void length(); |
57 | long position(); | 57 | long position(); |
58 | 58 | ||
59 | void videoResized ( const QSize &s ); | 59 | void videoResized ( const QSize &s ); |
60 | 60 | ||
61 | private: | 61 | private: |
62 | XINE::Lib *libXine; | 62 | XINE::Lib *libXine; |
63 | MediaDetect mdetect; | 63 | MediaDetect mdetect; |
64 | long m_currentTime; | 64 | long m_currentTime; |
65 | long m_position; | 65 | long m_position; |
66 | 66 | QString m_fileName; | |
67 | signals: | 67 | signals: |
68 | void positionChanged( long ); | 68 | void positionChanged( long ); |
69 | 69 | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | 72 | ||
73 | #endif | 73 | #endif |