summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-13 23:15:53 (UTC)
committer simon <simon>2002-12-13 23:15:53 (UTC)
commit1830ae3069a3ca35df678ce6d1700bf31d968a5c (patch) (unidiff)
tree45b5b64e3370f491c701e0f9e6128edccc6c0496
parent5e7ea7ebd8175993f951731e371b4e3609df654b (diff)
downloadopie-1830ae3069a3ca35df678ce6d1700bf31d968a5c.zip
opie-1830ae3069a3ca35df678ce6d1700bf31d968a5c.tar.gz
opie-1830ae3069a3ca35df678ce6d1700bf31d968a5c.tar.bz2
- allow delayed assignment of the widget on the XINE::Lib object
- make use of that API in XineControl and MediaPlayer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/lib.h2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp2
4 files changed, 19 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 84194b7..299239b 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,385 +1,393 @@
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 LJP <> 5 Copyright (c) 2002 LJP <>
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#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qdir.h> 41#include <qdir.h>
42 42
43#include <qgfx_qws.h> 43#include <qgfx_qws.h>
44#include <qdirectpainter_qws.h> 44#include <qdirectpainter_qws.h>
45 45
46#include <assert.h> 46#include <assert.h>
47 47
48#include "xinevideowidget.h" 48#include "xinevideowidget.h"
49#include "frame.h" 49#include "frame.h"
50#include "lib.h" 50#include "lib.h"
51 51
52 52
53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 53typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
54 int width, int height,int bytes ); 54 int width, int height,int bytes );
55 55
56extern "C" { 56extern "C" {
57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 57 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
58 int null_is_showing_video( const xine_vo_driver_t* self ); 58 int null_is_showing_video( const xine_vo_driver_t* self );
59 void null_set_show_video( const xine_vo_driver_t* self, int show ); 59 void null_set_show_video( const xine_vo_driver_t* self, int show );
60 int null_is_fullscreen( const xine_vo_driver_t* self ); 60 int null_is_fullscreen( const xine_vo_driver_t* self );
61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 61 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
62 int null_is_scaling( const xine_vo_driver_t* self ); 62 int null_is_scaling( const xine_vo_driver_t* self );
63 void null_set_scaling( const xine_vo_driver_t* self, int scale ); 63 void null_set_scaling( const xine_vo_driver_t* self, int scale );
64 void null_set_gui_width( const xine_vo_driver_t* self, int width ); 64 void null_set_gui_width( const xine_vo_driver_t* self, int width );
65 void null_set_gui_height( const xine_vo_driver_t* self, int height ); 65 void null_set_gui_height( const xine_vo_driver_t* self, int height );
66 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); 66 void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb );
67 void null_set_videoGamma( const xine_vo_driver_t* self , int value ); 67 void null_set_videoGamma( const xine_vo_driver_t* self , int value );
68 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); 68 void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data );
69} 69}
70 70
71using namespace XINE; 71using namespace XINE;
72 72
73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 73Lib::Lib( InitializationMode initMode, XineVideoWidget* widget )
74{ 74{
75 m_initialized = false; 75 m_initialized = false;
76 m_duringInitialization = false; 76 m_duringInitialization = false;
77 m_video = false; 77 m_video = false;
78 m_wid = widget; 78 m_wid = widget;
79 printf("Lib"); 79 printf("Lib");
80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 80 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
81 // get the configuration 81 // get the configuration
82 82
83 // not really OO, should be an extra class, later 83 // not really OO, should be an extra class, later
84 if ( !QFile::exists(configPath) ) { 84 if ( !QFile::exists(configPath) ) {
85 QFile f(configPath); 85 QFile f(configPath);
86 f.open(IO_WriteOnly); 86 f.open(IO_WriteOnly);
87 QTextStream ts( &f ); 87 QTextStream ts( &f );
88 ts << "misc.memcpy_method:glibc\n"; 88 ts << "misc.memcpy_method:glibc\n";
89 f.close(); 89 f.close();
90 } 90 }
91 91
92 if ( initMode == InitializeImmediately ) { 92 if ( initMode == InitializeImmediately ) {
93 initialize(); 93 initialize();
94 m_initialized = true; 94 m_initialized = true;
95 } 95 }
96 else 96 else
97 assert( false ); 97 assert( false );
98} 98}
99 99
100void Lib::run() 100void Lib::run()
101{ 101{
102 initialize(); 102 initialize();
103 m_initialized = true; 103 m_initialized = true;
104} 104}
105 105
106void Lib::initialize() 106void Lib::initialize()
107{ 107{
108 m_duringInitialization = true; 108 m_duringInitialization = true;
109 m_xine = xine_new( ); 109 m_xine = xine_new( );
110 110
111 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 111 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
112 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 112 xine_config_load( m_xine, QFile::encodeName( configPath ) );
113 113
114 xine_init( m_xine ); 114 xine_init( m_xine );
115 115
116 // allocate oss for sound 116 // allocate oss for sound
117 // and fb for framebuffer 117 // and fb for framebuffer
118 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 118 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
119 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 119 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
120 120
121 121
122//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); 122//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
123 123
124 124
125// null_display_handler( m_videoOutput, xine_display_frame, this ); 125// null_display_handler( m_videoOutput, xine_display_frame, this );
126 126
127 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 127 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
128 128
129 if (m_wid != 0 ) { 129 if (m_wid != 0 ) {
130 printf( "!0\n" ); 130 printf( "!0\n" );
131 resize ( m_wid-> size ( ) ); 131 setWidget( m_wid );
132 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
133
134// m_wid->repaint();
135 } 132 }
136 133
137 m_queue = xine_event_new_queue (m_stream); 134 m_queue = xine_event_new_queue (m_stream);
138 135
139 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 136 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
140 m_duringInitialization = false; 137 m_duringInitialization = false;
141} 138}
142 139
143Lib::~Lib() { 140Lib::~Lib() {
144 assert( isRunning() == false ); 141 assert( isRunning() == false );
145 assert( m_initialized ); 142 assert( m_initialized );
146 143
147// free( m_config ); 144// free( m_config );
148 145
149 xine_close( m_stream ); 146 xine_close( m_stream );
150 147
151 xine_event_dispose_queue( m_queue ); 148 xine_event_dispose_queue( m_queue );
152 149
153 xine_dispose( m_stream ); 150 xine_dispose( m_stream );
154 151
155 xine_exit( m_xine ); 152 xine_exit( m_xine );
156 /* FIXME either free or delete but valgrind bitches against both */ 153 /* FIXME either free or delete but valgrind bitches against both */
157 //free( m_videoOutput ); 154 //free( m_videoOutput );
158 //delete m_audioOutput; 155 //delete m_audioOutput;
159} 156}
160 157
161void Lib::resize ( const QSize &s ) { 158void Lib::resize ( const QSize &s ) {
162 assert( m_initialized || m_duringInitialization ); 159 assert( m_initialized || m_duringInitialization );
163 160
164 if ( s. width ( ) && s. height ( ) ) { 161 if ( s. width ( ) && s. height ( ) ) {
165 ::null_set_gui_width( m_videoOutput, s. width() ); 162 ::null_set_gui_width( m_videoOutput, s. width() );
166 ::null_set_gui_height( m_videoOutput, s. height() ); 163 ::null_set_gui_height( m_videoOutput, s. height() );
167 } 164 }
168} 165}
169 166
170int Lib::majorVersion() { 167int Lib::majorVersion() {
171 int major, minor, sub; 168 int major, minor, sub;
172 xine_get_version ( &major, &minor, &sub ); 169 xine_get_version ( &major, &minor, &sub );
173 return major; 170 return major;
174} 171}
175 172
176int Lib::minorVersion() { 173int Lib::minorVersion() {
177 int major, minor, sub; 174 int major, minor, sub;
178 xine_get_version ( &major, &minor, &sub ); 175 xine_get_version ( &major, &minor, &sub );
179 return minor; 176 return minor;
180} 177}
181 178
182int Lib::subVersion() { 179int Lib::subVersion() {
183 int major, minor, sub; 180 int major, minor, sub;
184 xine_get_version ( &major, &minor, &sub ); 181 xine_get_version ( &major, &minor, &sub );
185 return sub; 182 return sub;
186} 183}
187 184
188int Lib::play( const QString& fileName, int startPos, int start_time ) { 185int Lib::play( const QString& fileName, int startPos, int start_time ) {
189 assert( m_initialized ); 186 assert( m_initialized );
190 187
191 QString str = fileName.stripWhiteSpace(); 188 QString str = fileName.stripWhiteSpace();
192 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { 189 if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) {
193 return 0; 190 return 0;
194 } 191 }
195 return xine_play( m_stream, startPos, start_time); 192 return xine_play( m_stream, startPos, start_time);
196} 193}
197 194
198void Lib::stop() { 195void Lib::stop() {
199 assert( m_initialized ); 196 assert( m_initialized );
200 197
201 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); 198 qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
202 xine_stop( m_stream ); 199 xine_stop( m_stream );
203} 200}
204 201
205void Lib::pause( bool toggle ) { 202void Lib::pause( bool toggle ) {
206 assert( m_initialized ); 203 assert( m_initialized );
207 204
208 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 205 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
209} 206}
210 207
211int Lib::speed() const { 208int Lib::speed() const {
212 assert( m_initialized ); 209 assert( m_initialized );
213 210
214 return xine_get_param ( m_stream, XINE_PARAM_SPEED ); 211 return xine_get_param ( m_stream, XINE_PARAM_SPEED );
215} 212}
216 213
217void Lib::setSpeed( int speed ) { 214void Lib::setSpeed( int speed ) {
218 assert( m_initialized ); 215 assert( m_initialized );
219 216
220 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); 217 xine_set_param ( m_stream, XINE_PARAM_SPEED, speed );
221} 218}
222 219
223int Lib::status() const { 220int Lib::status() const {
224 assert( m_initialized ); 221 assert( m_initialized );
225 222
226 return xine_get_status( m_stream ); 223 return xine_get_status( m_stream );
227} 224}
228 225
229int Lib::currentPosition() const { 226int Lib::currentPosition() const {
230 assert( m_initialized ); 227 assert( m_initialized );
231 228
232 int pos, time, length; 229 int pos, time, length;
233 xine_get_pos_length( m_stream, &pos, &time, &length ); 230 xine_get_pos_length( m_stream, &pos, &time, &length );
234 return pos; 231 return pos;
235} 232}
236 233
237int Lib::currentTime() const { 234int Lib::currentTime() const {
238 assert( m_initialized ); 235 assert( m_initialized );
239 236
240 int pos, time, length; 237 int pos, time, length;
241 xine_get_pos_length( m_stream, &pos, &time, &length ); 238 xine_get_pos_length( m_stream, &pos, &time, &length );
242 return time/1000; 239 return time/1000;
243} 240}
244 241
245int Lib::length() const { 242int Lib::length() const {
246 assert( m_initialized ); 243 assert( m_initialized );
247 244
248 int pos, time, length; 245 int pos, time, length;
249 xine_get_pos_length( m_stream, &pos, &time, &length ); 246 xine_get_pos_length( m_stream, &pos, &time, &length );
250 return length/1000; 247 return length/1000;
251} 248}
252 249
253bool Lib::isSeekable() const { 250bool Lib::isSeekable() const {
254 assert( m_initialized ); 251 assert( m_initialized );
255 252
256 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 253 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
257} 254}
258 255
259void Lib::seekTo( int time ) { 256void Lib::seekTo( int time ) {
260 assert( m_initialized ); 257 assert( m_initialized );
261 258
262 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( 259 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
263 // since its now milliseconds we need *1000 260 // since its now milliseconds we need *1000
264 xine_play( m_stream, 0, time*1000 ); 261 xine_play( m_stream, 0, time*1000 );
265} 262}
266 263
267 264
268Frame Lib::currentFrame() const { 265Frame Lib::currentFrame() const {
269 assert( m_initialized ); 266 assert( m_initialized );
270 267
271 Frame frame; 268 Frame frame;
272 return frame; 269 return frame;
273}; 270};
274 271
275QString Lib::metaInfo( int number) const { 272QString Lib::metaInfo( int number) const {
276 assert( m_initialized ); 273 assert( m_initialized );
277 274
278 return xine_get_meta_info( m_stream, number ); 275 return xine_get_meta_info( m_stream, number );
279} 276}
280 277
281int Lib::error() const { 278int Lib::error() const {
282 assert( m_initialized ); 279 assert( m_initialized );
283 280
284 return xine_get_error( m_stream ); 281 return xine_get_error( m_stream );
285}; 282};
286 283
287void Lib::ensureInitialized() 284void Lib::ensureInitialized()
288{ 285{
289 if ( m_initialized ) 286 if ( m_initialized )
290 return; 287 return;
291 288
292 qDebug( "waiting for initialization thread to finish" ); 289 qDebug( "waiting for initialization thread to finish" );
293 wait(); 290 wait();
294 qDebug( "initialization thread finished!" ); 291 qDebug( "initialization thread finished!" );
295} 292}
296 293
294void Lib::setWidget( XineVideoWidget *widget )
295{
296 m_wid = widget;
297 resize ( m_wid-> size ( ) );
298 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
299 m_wid->repaint();
300}
301
297void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 302void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
298{ 303{
299 assert( sendType == ThreadUtil::Channel::OneWay ); 304 assert( sendType == ThreadUtil::Channel::OneWay );
300 handleXineEvent( msg->type() ); 305 handleXineEvent( msg->type() );
301 delete msg; 306 delete msg;
302} 307}
303 308
304void Lib::handleXineEvent( const xine_event_t* t ) { 309void Lib::handleXineEvent( const xine_event_t* t ) {
305 send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); 310 send( new ThreadUtil::ChannelMessage( t->type ), OneWay );
306} 311}
307 312
308void Lib::handleXineEvent( int type ) { 313void Lib::handleXineEvent( int type ) {
309 assert( m_initialized ); 314 assert( m_initialized );
310 315
311 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { 316 if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) {
312 emit stopped(); 317 emit stopped();
313 } 318 }
314} 319}
315 320
316 321
317void Lib::setShowVideo( bool video ) { 322void Lib::setShowVideo( bool video ) {
318 assert( m_initialized ); 323 assert( m_initialized );
319 324
320 m_video = video; 325 m_video = video;
321 ::null_set_show_video( m_videoOutput, video ); 326 ::null_set_show_video( m_videoOutput, video );
322} 327}
323 328
324bool Lib::isShowingVideo() const { 329bool Lib::isShowingVideo() const {
325 assert( m_initialized ); 330 assert( m_initialized );
326 331
327 return ::null_is_showing_video( m_videoOutput ); 332 return ::null_is_showing_video( m_videoOutput );
328} 333}
329 334
330bool Lib::hasVideo() const { 335bool Lib::hasVideo() const {
331 assert( m_initialized ); 336 assert( m_initialized );
332 337
333 return xine_get_stream_info( m_stream, 18 ); 338 return xine_get_stream_info( m_stream, 18 );
334} 339}
335 340
336void Lib::showVideoFullScreen( bool fullScreen ) { 341void Lib::showVideoFullScreen( bool fullScreen ) {
337 assert( m_initialized ); 342 assert( m_initialized );
338 343
339 ::null_set_fullscreen( m_videoOutput, fullScreen ); 344 ::null_set_fullscreen( m_videoOutput, fullScreen );
340} 345}
341 346
342bool Lib::isVideoFullScreen() const { 347bool Lib::isVideoFullScreen() const {
343 assert( m_initialized ); 348 assert( m_initialized );
344 349
345 return ::null_is_fullscreen( m_videoOutput ); 350 return ::null_is_fullscreen( m_videoOutput );
346} 351}
347 352
348void Lib::setScaling( bool scale ) { 353void Lib::setScaling( bool scale ) {
349 assert( m_initialized ); 354 assert( m_initialized );
350 355
351 ::null_set_scaling( m_videoOutput, scale ); 356 ::null_set_scaling( m_videoOutput, scale );
352} 357}
353 358
354void Lib::setGamma( int value ) { 359void Lib::setGamma( int value ) {
355 assert( m_initialized ); 360 assert( m_initialized );
356 361
357 //qDebug( QString( "%1").arg(value) ); 362 //qDebug( QString( "%1").arg(value) );
358 /* int gammaValue = ( 100 + value ); */ 363 /* int gammaValue = ( 100 + value ); */
359 ::null_set_videoGamma( m_videoOutput, value ); 364 ::null_set_videoGamma( m_videoOutput, value );
360} 365}
361 366
362bool Lib::isScaling() const { 367bool Lib::isScaling() const {
363 assert( m_initialized ); 368 assert( m_initialized );
364 369
365 return ::null_is_scaling( m_videoOutput ); 370 return ::null_is_scaling( m_videoOutput );
366} 371}
367 372
368void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 373void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
369 ( (Lib*)user_data)->handleXineEvent( t ); 374 ( (Lib*)user_data)->handleXineEvent( t );
370} 375}
371 376
372void Lib::xine_display_frame( void* user_data, uint8_t *frame, 377void Lib::xine_display_frame( void* user_data, uint8_t *frame,
373 int width, int height, int bytes ) { 378 int width, int height, int bytes ) {
374 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 379 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
375} 380}
376 381
377void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 382void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
378 assert( m_initialized ); 383 assert( m_initialized );
379 384
380 if ( !m_video ) { 385 if ( !m_video ) {
381 qWarning("not showing video now"); 386 qWarning("not showing video now");
382 return; 387 return;
383 } 388 }
389
390 assert( m_wid );
391
384 m_wid-> setVideoFrame ( frame, width, height, bytes ); 392 m_wid-> setVideoFrame ( frame, width, height, bytes );
385} 393}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 6b67f67..181735c 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,219 +1,221 @@
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 LJP <> 5 Copyright (c) 2002 LJP <>
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 ZECKEXINELIB_H 34#ifndef ZECKEXINELIB_H
35#define ZECKEXINELIB_H 35#define ZECKEXINELIB_H
36 36
37#include <qcstring.h> 37#include <qcstring.h>
38#include <qstring.h> 38#include <qstring.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <xine.h> 41#include <xine.h>
42//#include "xine.h" 42//#include "xine.h"
43 43
44#include "threadutil.h" 44#include "threadutil.h"
45 45
46class XineVideoWidget; 46class XineVideoWidget;
47 47
48namespace XINE { 48namespace XINE {
49 49
50 /** 50 /**
51 * Lib wrapps the simple interface 51 * Lib wrapps the simple interface
52 * of libxine for easy every day use 52 * of libxine for easy every day use
53 * This will become a full C++ Wrapper 53 * This will become a full C++ Wrapper
54 * It supports playing, pausing, info, 54 * It supports playing, pausing, info,
55 * stooping, seeking. 55 * stooping, seeking.
56 */ 56 */
57 class Frame; 57 class Frame;
58 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread 58 class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread
59 { 59 {
60 Q_OBJECT 60 Q_OBJECT
61 public: 61 public:
62 enum InitializationMode { InitializeImmediately, InitializeInThread }; 62 enum InitializationMode { InitializeImmediately, InitializeInThread };
63 63
64 Lib( InitializationMode initMode, XineVideoWidget* = 0); 64 Lib( InitializationMode initMode, XineVideoWidget* = 0);
65 65
66 ~Lib(); 66 ~Lib();
67 static int majorVersion(); 67 static int majorVersion();
68 static int minorVersion(); 68 static int minorVersion();
69 static int subVersion(); 69 static int subVersion();
70 70
71 71
72 void resize ( const QSize &s ); 72 void resize ( const QSize &s );
73 73
74 int play( const QString& fileName, 74 int play( const QString& fileName,
75 int startPos = 0, 75 int startPos = 0,
76 int start_time = 0 ); 76 int start_time = 0 );
77 void stop(); 77 void stop();
78 void pause( bool toggle ); 78 void pause( bool toggle );
79 79
80 int speed() const; 80 int speed() const;
81 81
82 /** 82 /**
83 * Set the speed of the stream, if codec supports it 83 * Set the speed of the stream, if codec supports it
84 * XINE_SPEED_PAUSE 0 84 * XINE_SPEED_PAUSE 0
85 * XINE_SPEED_SLOW_4 1 85 * XINE_SPEED_SLOW_4 1
86 * XINE_SPEED_SLOW_2 2 86 * XINE_SPEED_SLOW_2 2
87 * XINE_SPEED_NORMAL 4 87 * XINE_SPEED_NORMAL 4
88 * XINE_SPEED_FAST_2 8 88 * XINE_SPEED_FAST_2 8
89 *XINE_SPEED_FAST_4 16 89 *XINE_SPEED_FAST_4 16
90 */ 90 */
91 void setSpeed( int speed = XINE_SPEED_PAUSE ); 91 void setSpeed( int speed = XINE_SPEED_PAUSE );
92 92
93 int status() const; 93 int status() const;
94 94
95 int currentPosition()const; 95 int currentPosition()const;
96 //in seconds 96 //in seconds
97 int currentTime()const; 97 int currentTime()const;
98 98
99 int length() const; 99 int length() const;
100 100
101 bool isSeekable()const; 101 bool isSeekable()const;
102 102
103 /** 103 /**
104 * Whether or not to show video output 104 * Whether or not to show video output
105 */ 105 */
106 void setShowVideo(bool video); 106 void setShowVideo(bool video);
107 107
108 /** 108 /**
109 * is we show video 109 * is we show video
110 */ 110 */
111 bool isShowingVideo() const; 111 bool isShowingVideo() const;
112 112
113 /** 113 /**
114 * 114 *
115 */ 115 */
116 void showVideoFullScreen( bool fullScreen ); 116 void showVideoFullScreen( bool fullScreen );
117 117
118 /** 118 /**
119 * 119 *
120 */ 120 */
121 bool isVideoFullScreen() const; 121 bool isVideoFullScreen() const;
122 122
123 123
124 /** 124 /**
125 * Get the meta info (like author etc) from the stream 125 * Get the meta info (like author etc) from the stream
126 * XINE_META_INFO_TITLE 0 126 * XINE_META_INFO_TITLE 0
127 * XINE_META_INFO_COMMENT 1 127 * XINE_META_INFO_COMMENT 1
128 * XINE_META_INFO_ARTIST 2 128 * XINE_META_INFO_ARTIST 2
129 * XINE_META_INFO_GENRE 3 129 * XINE_META_INFO_GENRE 3
130 * XINE_META_INFO_ALBUM 4 130 * XINE_META_INFO_ALBUM 4
131 * XINE_META_INFO_YEAR 5 131 * XINE_META_INFO_YEAR 5
132 * XINE_META_INFO_VIDEOCODEC 6 132 * XINE_META_INFO_VIDEOCODEC 6
133 * XINE_META_INFO_AUDIOCODEC 7 133 * XINE_META_INFO_AUDIOCODEC 7
134 * XINE_META_INFO_SYSTEMLAYER 8 134 * XINE_META_INFO_SYSTEMLAYER 8
135 * XINE_META_INFO_INPUT_PLUGIN 9 135 * XINE_META_INFO_INPUT_PLUGIN 9
136 */ 136 */
137 QString metaInfo( int number ) const; 137 QString metaInfo( int number ) const;
138 138
139 /** 139 /**
140 * 140 *
141 */ 141 */
142 bool isScaling() const; 142 bool isScaling() const;
143 143
144 /** 144 /**
145 * seek to a position 145 * seek to a position
146 */ 146 */
147 void seekTo( int time ); 147 void seekTo( int time );
148 148
149 /** 149 /**
150 * 150 *
151 * @return is media stream has video 151 * @return is media stream has video
152 */ 152 */
153 bool hasVideo() const; 153 bool hasVideo() const;
154 154
155 /** 155 /**
156 * 156 *
157 */ 157 */
158 void setScaling( bool ); 158 void setScaling( bool );
159 159
160 /** 160 /**
161 * Set the Gamma value for video output 161 * Set the Gamma value for video output
162 * @param int the value between -100 and 100, 0 is original 162 * @param int the value between -100 and 100, 0 is original
163 */ 163 */
164 void setGamma( int ); 164 void setGamma( int );
165 165
166 /** 166 /**
167 * test 167 * test
168 */ 168 */
169 Frame currentFrame() const; 169 Frame currentFrame() const;
170 170
171 /** 171 /**
172 * Returns the error code 172 * Returns the error code
173 * XINE_ERROR_NONE 0 173 * XINE_ERROR_NONE 0
174 * XINE_ERROR_NO_INPUT_PLUGIN 1 174 * XINE_ERROR_NO_INPUT_PLUGIN 1
175 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 175 * XINE_ERROR_NO_DEMUXER_PLUGIN 2
176 * XINE_ERROR_DEMUXER_FAILED 3 176 * XINE_ERROR_DEMUXER_FAILED 3
177 */ 177 */
178 int error() const; 178 int error() const;
179 179
180 void ensureInitialized(); 180 void ensureInitialized();
181 181
182 void setWidget( XineVideoWidget *widget );
183
182 signals: 184 signals:
183 185
184 void stopped(); 186 void stopped();
185 187
186 void initialized(); 188 void initialized();
187 189
188 protected: 190 protected:
189 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); 191 virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType );
190 192
191 virtual void run(); 193 virtual void run();
192 194
193 private: 195 private:
194 void initialize(); 196 void initialize();
195 197
196 int m_bytes_per_pixel; 198 int m_bytes_per_pixel;
197 bool m_initialized:1; 199 bool m_initialized:1;
198 bool m_duringInitialization:1; 200 bool m_duringInitialization:1;
199 bool m_video:1; 201 bool m_video:1;
200 XineVideoWidget *m_wid; 202 XineVideoWidget *m_wid;
201 xine_t *m_xine; 203 xine_t *m_xine;
202 xine_stream_t *m_stream; 204 xine_stream_t *m_stream;
203 xine_cfg_entry_t *m_config; 205 xine_cfg_entry_t *m_config;
204 xine_vo_driver_t *m_videoOutput; 206 xine_vo_driver_t *m_videoOutput;
205 xine_ao_driver_t* m_audioOutput; 207 xine_ao_driver_t* m_audioOutput;
206 xine_event_queue_t *m_queue; 208 xine_event_queue_t *m_queue;
207 209
208 void handleXineEvent( const xine_event_t* t ); 210 void handleXineEvent( const xine_event_t* t );
209 void handleXineEvent( int type ); 211 void handleXineEvent( int type );
210 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 212 void drawFrame( uint8_t* frame, int width, int height, int bytes );
211 // C -> C++ bridge for the event system 213 // C -> C++ bridge for the event system
212 static void xine_event_handler( void* user_data, const xine_event_t* t); 214 static void xine_event_handler( void* user_data, const xine_event_t* t);
213 static void xine_display_frame( void* user_data, uint8_t* frame , 215 static void xine_display_frame( void* user_data, uint8_t* frame ,
214 int width, int height, int bytes ); 216 int width, int height, int bytes );
215 }; 217 };
216}; 218};
217 219
218 220
219#endif 221#endif
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 963e783..d6fbb53 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,402 +1,404 @@
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#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18#include "lib.h"
18 19
19#include "mediaplayerstate.h" 20#include "mediaplayerstate.h"
20 21
21// for setBacklight() 22// for setBacklight()
22#include <linux/fb.h> 23#include <linux/fb.h>
23#include <sys/file.h> 24#include <sys/file.h>
24#include <sys/ioctl.h> 25#include <sys/ioctl.h>
25 26
26 27
27 28
28 29
29#define FBIOBLANK 0x4611 30#define FBIOBLANK 0x4611
30 31
31MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 32MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
32 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 33 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
33 34
34 m_audioUI = 0; 35 m_audioUI = 0;
35 m_videoUI = 0; 36 m_videoUI = 0;
36 m_xineControl = 0; 37 m_xineControl = 0;
37 38
38 fd=-1;fl=-1; 39 fd=-1;fl=-1;
39 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 40 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
40 41
41 qApp->processEvents(); 42 qApp->processEvents();
42 // QPEApplication::grabKeyboard(); // EVIL 43 // QPEApplication::grabKeyboard(); // EVIL
43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
44 45
45 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 46 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
46 47
47// What is pauseCheck good for? (Simon) 48// What is pauseCheck good for? (Simon)
48// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 49// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
49 50
50 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 51 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
51 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 52 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
52 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 53 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
53 54
54 volControl = new VolumeControl; 55 volControl = new VolumeControl;
55 Config cfg( "OpiePlayer" ); 56 Config cfg( "OpiePlayer" );
56 cfg.setGroup("PlayList"); 57 cfg.setGroup("PlayList");
57 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 58 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
58 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 59 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
59 60
60 m_skinLoader = new SkinLoader; 61 m_skinLoader = new SkinLoader;
61 m_skinLoader->schedule( AudioWidget::guiInfo() ); 62 m_skinLoader->schedule( AudioWidget::guiInfo() );
62 m_skinLoader->schedule( VideoWidget::guiInfo() ); 63 m_skinLoader->schedule( VideoWidget::guiInfo() );
63 m_skinLoader->start(); 64 m_skinLoader->start();
64} 65}
65 66
66MediaPlayer::~MediaPlayer() { 67MediaPlayer::~MediaPlayer() {
67 delete m_xineControl; 68 delete m_xineControl;
68 delete m_audioUI; 69 delete m_audioUI;
69 delete m_videoUI; 70 delete m_videoUI;
70 delete volControl; 71 delete volControl;
71} 72}
72 73
73void MediaPlayer::pauseCheck( bool b ) { 74void MediaPlayer::pauseCheck( bool b ) {
74 if ( b && !mediaPlayerState.isPlaying() ) { 75 if ( b && !mediaPlayerState.isPlaying() ) {
75 mediaPlayerState.setPaused( FALSE ); 76 mediaPlayerState.setPaused( FALSE );
76 } 77 }
77} 78}
78 79
79void MediaPlayer::play() { 80void MediaPlayer::play() {
80 mediaPlayerState.setPlaying( FALSE ); 81 mediaPlayerState.setPlaying( FALSE );
81 mediaPlayerState.setPlaying( TRUE ); 82 mediaPlayerState.setPlaying( TRUE );
82} 83}
83 84
84void MediaPlayer::setPlaying( bool play ) { 85void MediaPlayer::setPlaying( bool play ) {
85 if ( !play ) { 86 if ( !play ) {
86 return; 87 return;
87 } 88 }
88 89
89 if ( mediaPlayerState.isPaused() ) { 90 if ( mediaPlayerState.isPaused() ) {
90 mediaPlayerState.setPaused( FALSE ); 91 mediaPlayerState.setPaused( FALSE );
91 return; 92 return;
92 } 93 }
93 94
94 QString tickerText, time, fileName; 95 QString tickerText, time, fileName;
95 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 96 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
96 //if playing in file list.. play in a different way 97 //if playing in file list.. play in a different way
97 // random and looping settings enabled causes problems here, 98 // random and looping settings enabled causes problems here,
98 // since there is no selected file in the playlist, but a selected file in the file list, 99 // since there is no selected file in the playlist, but a selected file in the file list,
99 // so we remember and shutoff 100 // so we remember and shutoff
100 l = mediaPlayerState.isLooping(); 101 l = mediaPlayerState.isLooping();
101 if(l) { 102 if(l) {
102 mediaPlayerState.setLooping( false ); 103 mediaPlayerState.setLooping( false );
103 } 104 }
104 r = mediaPlayerState.isShuffled(); 105 r = mediaPlayerState.isShuffled();
105 mediaPlayerState.setShuffled( false ); 106 mediaPlayerState.setShuffled( false );
106 } 107 }
107 108
108 PlayListWidget::Entry playListEntry = playList.currentEntry(); 109 PlayListWidget::Entry playListEntry = playList.currentEntry();
109 fileName = playListEntry.name; 110 fileName = playListEntry.name;
110 xineControl()->play( playListEntry.file ); 111 xineControl()->play( playListEntry.file );
111 112
112 long seconds = mediaPlayerState.length(); 113 long seconds = mediaPlayerState.length();
113 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 114 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
114 115
115 if( fileName.left(4) == "http" ) { 116 if( fileName.left(4) == "http" ) {
116 fileName = QFileInfo( fileName ).baseName(); 117 fileName = QFileInfo( fileName ).baseName();
117 if ( xineControl()->getMetaInfo().isEmpty() ) { 118 if ( xineControl()->getMetaInfo().isEmpty() ) {
118 tickerText = tr( " File: " ) + fileName; 119 tickerText = tr( " File: " ) + fileName;
119 } else { 120 } else {
120 tickerText = xineControl()->getMetaInfo(); 121 tickerText = xineControl()->getMetaInfo();
121 } 122 }
122 } else { 123 } else {
123 if ( xineControl()->getMetaInfo().isEmpty() ) { 124 if ( xineControl()->getMetaInfo().isEmpty() ) {
124 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 125 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
125 } else { 126 } else {
126 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 127 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
127 } 128 }
128 } 129 }
129 audioUI()->setTickerText( tickerText ); 130 audioUI()->setTickerText( tickerText );
130} 131}
131 132
132 133
133void MediaPlayer::prev() { 134void MediaPlayer::prev() {
134 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 135 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
135 if ( playList.prev() ) { 136 if ( playList.prev() ) {
136 play(); 137 play();
137 } else if ( mediaPlayerState.isLooping() ) { 138 } else if ( mediaPlayerState.isLooping() ) {
138 if ( playList.last() ) { 139 if ( playList.last() ) {
139 play(); 140 play();
140 } 141 }
141 } else { 142 } else {
142 mediaPlayerState.setList(); 143 mediaPlayerState.setList();
143 } 144 }
144 } 145 }
145} 146}
146 147
147 148
148void MediaPlayer::next() { 149void MediaPlayer::next() {
149 150
150 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 151 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
151 if ( playList.next() ) { 152 if ( playList.next() ) {
152 play(); 153 play();
153 } else if ( mediaPlayerState.isLooping() ) { 154 } else if ( mediaPlayerState.isLooping() ) {
154 if ( playList.first() ) { 155 if ( playList.first() ) {
155 play(); 156 play();
156 } 157 }
157 } else { 158 } else {
158 mediaPlayerState.setList(); 159 mediaPlayerState.setList();
159 } 160 }
160 } else { //if playing from file list, let's just stop 161 } else { //if playing from file list, let's just stop
161 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 162 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
162 mediaPlayerState.setPlaying(false); 163 mediaPlayerState.setPlaying(false);
163 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 164 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
164 if(l) mediaPlayerState.setLooping(l); 165 if(l) mediaPlayerState.setLooping(l);
165 if(r) mediaPlayerState.setShuffled(r); 166 if(r) mediaPlayerState.setShuffled(r);
166 } 167 }
167 qApp->processEvents(); 168 qApp->processEvents();
168} 169}
169 170
170 171
171void MediaPlayer::startDecreasingVolume() { 172void MediaPlayer::startDecreasingVolume() {
172 volumeDirection = -1; 173 volumeDirection = -1;
173 startTimer( 100 ); 174 startTimer( 100 );
174 volControl->decVol(2); 175 volControl->decVol(2);
175} 176}
176 177
177 178
178void MediaPlayer::startIncreasingVolume() { 179void MediaPlayer::startIncreasingVolume() {
179 volumeDirection = +1; 180 volumeDirection = +1;
180 startTimer( 100 ); 181 startTimer( 100 );
181 volControl->incVol(2); 182 volControl->incVol(2);
182} 183}
183 184
184 185
185bool drawnOnScreenDisplay = FALSE; 186bool drawnOnScreenDisplay = FALSE;
186unsigned int onScreenDisplayVolume = 0; 187unsigned int onScreenDisplayVolume = 0;
187const int yoff = 110; 188const int yoff = 110;
188 189
189void MediaPlayer::stopChangingVolume() { 190void MediaPlayer::stopChangingVolume() {
190 killTimers(); 191 killTimers();
191 // Get rid of the on-screen display stuff 192 // Get rid of the on-screen display stuff
192 drawnOnScreenDisplay = FALSE; 193 drawnOnScreenDisplay = FALSE;
193 onScreenDisplayVolume = 0; 194 onScreenDisplayVolume = 0;
194 int w=0; 195 int w=0;
195 int h=0; 196 int h=0;
196 if( !xineControl()->hasVideo() ) { 197 if( !xineControl()->hasVideo() ) {
197 w = audioUI()->width(); 198 w = audioUI()->width();
198 h = audioUI()->height(); 199 h = audioUI()->height();
199 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 200 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
200 } else { 201 } else {
201 w = videoUI()->width(); 202 w = videoUI()->width();
202 h = videoUI()->height(); 203 h = videoUI()->height();
203 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 204 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
204 } 205 }
205} 206}
206 207
207 208
208void MediaPlayer::timerEvent( QTimerEvent * ) { 209void MediaPlayer::timerEvent( QTimerEvent * ) {
209 if ( volumeDirection == +1 ) { 210 if ( volumeDirection == +1 ) {
210 volControl->incVol( 2 ); 211 volControl->incVol( 2 );
211 } else if ( volumeDirection == -1 ) { 212 } else if ( volumeDirection == -1 ) {
212 volControl->decVol( 2 ); 213 volControl->decVol( 2 );
213 } 214 }
214 215
215 216
216 // TODO FIXME 217 // TODO FIXME
217 // huh?? 218 // huh??
218 unsigned int v= 0; 219 unsigned int v= 0;
219 v = volControl->volume(); 220 v = volControl->volume();
220 v = v / 10; 221 v = v / 10;
221 222
222 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 223 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
223 return; 224 return;
224 } 225 }
225 226
226 int w=0; int h=0; 227 int w=0; int h=0;
227 if( !xineControl()->hasVideo() ) { 228 if( !xineControl()->hasVideo() ) {
228 w = audioUI()->width(); 229 w = audioUI()->width();
229 h = audioUI()->height(); 230 h = audioUI()->height();
230 231
231 if ( drawnOnScreenDisplay ) { 232 if ( drawnOnScreenDisplay ) {
232 if ( onScreenDisplayVolume > v ) { 233 if ( onScreenDisplayVolume > v ) {
233 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 234 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
234 } 235 }
235 } 236 }
236 drawnOnScreenDisplay = TRUE; 237 drawnOnScreenDisplay = TRUE;
237 onScreenDisplayVolume = v; 238 onScreenDisplayVolume = v;
238 QPainter p( audioUI() ); 239 QPainter p( audioUI() );
239 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 240 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
240 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 241 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
241 242
242 QFont f; 243 QFont f;
243 f.setPixelSize( 20 ); 244 f.setPixelSize( 20 );
244 f.setBold( TRUE ); 245 f.setBold( TRUE );
245 p.setFont( f ); 246 p.setFont( f );
246 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 247 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
247 248
248 for ( unsigned int i = 0; i < 10; i++ ) { 249 for ( unsigned int i = 0; i < 10; i++ ) {
249 if ( v > i ) { 250 if ( v > i ) {
250 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 251 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
251 } else { 252 } else {
252 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 253 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
253 } 254 }
254 } 255 }
255 } else { 256 } else {
256 w = videoUI()->width(); 257 w = videoUI()->width();
257 h = videoUI()->height(); 258 h = videoUI()->height();
258 259
259 if ( drawnOnScreenDisplay ) { 260 if ( drawnOnScreenDisplay ) {
260 if ( onScreenDisplayVolume > v ) { 261 if ( onScreenDisplayVolume > v ) {
261 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 262 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
262 } 263 }
263 } 264 }
264 drawnOnScreenDisplay = TRUE; 265 drawnOnScreenDisplay = TRUE;
265 onScreenDisplayVolume = v; 266 onScreenDisplayVolume = v;
266 QPainter p( videoUI() ); 267 QPainter p( videoUI() );
267 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 268 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
268 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 269 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
269 270
270 QFont f; 271 QFont f;
271 f.setPixelSize( 20 ); 272 f.setPixelSize( 20 );
272 f.setBold( TRUE ); 273 f.setBold( TRUE );
273 p.setFont( f ); 274 p.setFont( f );
274 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 275 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
275 276
276 for ( unsigned int i = 0; i < 10; i++ ) { 277 for ( unsigned int i = 0; i < 10; i++ ) {
277 if ( v > i ) { 278 if ( v > i ) {
278 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 279 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
279 } else { 280 } else {
280 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 281 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
281 } 282 }
282 } 283 }
283 } 284 }
284} 285}
285 286
286 287
287void MediaPlayer::blank( bool b ) { 288void MediaPlayer::blank( bool b ) {
288 fd=open("/dev/fb0",O_RDWR); 289 fd=open("/dev/fb0",O_RDWR);
289#ifdef QT_QWS_EBX 290#ifdef QT_QWS_EBX
290 fl= open( "/dev/fl", O_RDWR ); 291 fl= open( "/dev/fl", O_RDWR );
291#endif 292#endif
292 if (fd != -1) { 293 if (fd != -1) {
293 if ( b ) { 294 if ( b ) {
294 qDebug("do blanking"); 295 qDebug("do blanking");
295#ifdef QT_QWS_EBX 296#ifdef QT_QWS_EBX
296 ioctl( fd, FBIOBLANK, 1 ); 297 ioctl( fd, FBIOBLANK, 1 );
297 if(fl !=-1) { 298 if(fl !=-1) {
298 ioctl( fl, 2 ); 299 ioctl( fl, 2 );
299 ::close(fl); 300 ::close(fl);
300 } 301 }
301#else 302#else
302 ioctl( fd, FBIOBLANK, 3 ); 303 ioctl( fd, FBIOBLANK, 3 );
303#endif 304#endif
304 isBlanked = TRUE; 305 isBlanked = TRUE;
305 } else { 306 } else {
306 qDebug("do unblanking"); 307 qDebug("do unblanking");
307 ioctl( fd, FBIOBLANK, 0); 308 ioctl( fd, FBIOBLANK, 0);
308#ifdef QT_QWS_EBX 309#ifdef QT_QWS_EBX
309 if(fl != -1) { 310 if(fl != -1) {
310 ioctl( fl, 1); 311 ioctl( fl, 1);
311 ::close(fl); 312 ::close(fl);
312 } 313 }
313#endif 314#endif
314 isBlanked = FALSE; 315 isBlanked = FALSE;
315 } 316 }
316 close( fd ); 317 close( fd );
317 } else { 318 } else {
318 qDebug("<< /dev/fb0 could not be opened >>"); 319 qDebug("<< /dev/fb0 could not be opened >>");
319 } 320 }
320} 321}
321 322
322void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 323void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
323 switch ( e->key() ) { 324 switch ( e->key() ) {
324////////////////////////////// Zaurus keys 325////////////////////////////// Zaurus keys
325 case Key_Home: 326 case Key_Home:
326 break; 327 break;
327 case Key_F9: //activity 328 case Key_F9: //activity
328 break; 329 break;
329 case Key_F10: //contacts 330 case Key_F10: //contacts
330 break; 331 break;
331 case Key_F11: //menu 332 case Key_F11: //menu
332 break; 333 break;
333 case Key_F12: //home 334 case Key_F12: //home
334 qDebug("Blank here"); 335 qDebug("Blank here");
335// mediaPlayerState->toggleBlank(); 336// mediaPlayerState->toggleBlank();
336 break; 337 break;
337 case Key_F13: //mail 338 case Key_F13: //mail
338 qDebug("Blank here"); 339 qDebug("Blank here");
339 // mediaPlayerState->toggleBlank(); 340 // mediaPlayerState->toggleBlank();
340 break; 341 break;
341 } 342 }
342} 343}
343 344
344void MediaPlayer::cleanUp() {// this happens on closing 345void MediaPlayer::cleanUp() {// this happens on closing
345 Config cfg( "OpiePlayer" ); 346 Config cfg( "OpiePlayer" );
346 mediaPlayerState.writeConfig( cfg ); 347 mediaPlayerState.writeConfig( cfg );
347 playList.writeDefaultPlaylist( ); 348 playList.writeDefaultPlaylist( );
348 349
349// QPEApplication::grabKeyboard(); 350// QPEApplication::grabKeyboard();
350// QPEApplication::ungrabKeyboard(); 351// QPEApplication::ungrabKeyboard();
351} 352}
352 353
353void MediaPlayer::recreateAudioAndVideoWidgets() const 354void MediaPlayer::recreateAudioAndVideoWidgets() const
354{ 355{
355 delete m_skinLoader; 356 delete m_skinLoader;
356 357
357 delete m_xineControl; 358 delete m_xineControl;
358 delete m_audioUI; 359 delete m_audioUI;
359 delete m_videoUI; 360 delete m_videoUI;
360 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 361 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
361 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 362 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
362 363
363 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 364 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
364 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 365 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
365 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 366 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
366 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 367 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
367 368
368 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 369 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
369 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 370 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
370 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 371 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
371 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 372 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
372 373
373 m_xineControl = new XineControl( m_videoUI->vidWidget(), mediaPlayerState ); 374 XINE::Lib *xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
375 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
374} 376}
375 377
376AudioWidget *MediaPlayer::audioUI() const 378AudioWidget *MediaPlayer::audioUI() const
377{ 379{
378 if ( !m_audioUI ) 380 if ( !m_audioUI )
379 recreateAudioAndVideoWidgets(); 381 recreateAudioAndVideoWidgets();
380 return m_audioUI; 382 return m_audioUI;
381} 383}
382 384
383VideoWidget *MediaPlayer::videoUI() const 385VideoWidget *MediaPlayer::videoUI() const
384{ 386{
385 if ( !m_videoUI ) 387 if ( !m_videoUI )
386 recreateAudioAndVideoWidgets(); 388 recreateAudioAndVideoWidgets();
387 return m_videoUI; 389 return m_videoUI;
388} 390}
389 391
390XineControl *MediaPlayer::xineControl() const 392XineControl *MediaPlayer::xineControl() const
391{ 393{
392 if ( !m_xineControl ) 394 if ( !m_xineControl )
393 recreateAudioAndVideoWidgets(); 395 recreateAudioAndVideoWidgets();
394 return m_xineControl; 396 return m_xineControl;
395} 397}
396 398
397void MediaPlayer::reloadSkins() 399void MediaPlayer::reloadSkins()
398{ 400{
399 audioUI()->loadSkin(); 401 audioUI()->loadSkin();
400 videoUI()->loadSkin(); 402 videoUI()->loadSkin();
401} 403}
402 404
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 7c54499..1c489e3 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,251 +1,253 @@
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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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 <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include "xinecontrol.h" 39#include "xinecontrol.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41#include "xinevideowidget.h" 41#include "xinevideowidget.h"
42 42
43XineControl::XineControl( XineVideoWidget *xineWidget, 43XineControl::XineControl( XineVideoWidget *xineWidget,
44 MediaPlayerState &_mediaPlayerState, 44 MediaPlayerState &_mediaPlayerState,
45 QObject *parent, const char *name ) 45 QObject *parent, const char *name )
46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
47{ 47{
48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
49 49
50 init(); 50 init();
51} 51}
52 52
53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
54 MediaPlayerState &_mediaPlayerState, 54 MediaPlayerState &_mediaPlayerState,
55 QObject *parent, const char *name ) 55 QObject *parent, const char *name )
56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
57{ 57{
58 xine->ensureInitialized(); 58 xine->ensureInitialized();
59 59
60 xine->setWidget( xineWidget );
61
60 init(); 62 init();
61} 63}
62 64
63void XineControl::init() 65void XineControl::init()
64{ 66{
65 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 67 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
66 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); 68 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) );
67 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 69 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
68 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 70 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
69 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 71 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
70 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 72 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
71 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 73 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
72 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); 74 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) );
73 75
74 disabledSuspendScreenSaver = FALSE; 76 disabledSuspendScreenSaver = FALSE;
75} 77}
76 78
77XineControl::~XineControl() { 79XineControl::~XineControl() {
78#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 80#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
79 if ( disabledSuspendScreenSaver ) { 81 if ( disabledSuspendScreenSaver ) {
80 disabledSuspendScreenSaver = FALSE; 82 disabledSuspendScreenSaver = FALSE;
81 // Re-enable the suspend mode 83 // Re-enable the suspend mode
82 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 84 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
83 } 85 }
84#endif 86#endif
85 delete libXine; 87 delete libXine;
86} 88}
87 89
88void XineControl::play( const QString& fileName ) { 90void XineControl::play( const QString& fileName ) {
89 hasVideoChannel = FALSE; 91 hasVideoChannel = FALSE;
90 hasAudioChannel = FALSE; 92 hasAudioChannel = FALSE;
91 m_fileName = fileName; 93 m_fileName = fileName;
92 94
93 qDebug("<<FILENAME: " + fileName + ">>>>"); 95 qDebug("<<FILENAME: " + fileName + ">>>>");
94 96
95 if ( !libXine->play( fileName, 0, 0 ) ) { 97 if ( !libXine->play( fileName, 0, 0 ) ) {
96 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 98 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
97 // toggle stop so the the play button is reset 99 // toggle stop so the the play button is reset
98 mediaPlayerState.setPlaying( false ); 100 mediaPlayerState.setPlaying( false );
99 return; 101 return;
100 } 102 }
101 mediaPlayerState.setPlaying( true ); 103 mediaPlayerState.setPlaying( true );
102 104
103 MediaPlayerState::DisplayType displayType; 105 MediaPlayerState::DisplayType displayType;
104 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 106 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
105 if ( !libXine->hasVideo() ) { 107 if ( !libXine->hasVideo() ) {
106 displayType = MediaPlayerState::Audio; 108 displayType = MediaPlayerState::Audio;
107 qDebug("HAS AUDIO"); 109 qDebug("HAS AUDIO");
108 libXine->setShowVideo( false ); 110 libXine->setShowVideo( false );
109 hasAudioChannel = TRUE; 111 hasAudioChannel = TRUE;
110 } else { 112 } else {
111 displayType = MediaPlayerState::Video; 113 displayType = MediaPlayerState::Video;
112 qDebug("HAS VIDEO"); 114 qDebug("HAS VIDEO");
113 libXine->setShowVideo( true ); 115 libXine->setShowVideo( true );
114 hasVideoChannel = TRUE; 116 hasVideoChannel = TRUE;
115 } 117 }
116 // determine if slider is shown 118 // determine if slider is shown
117 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 119 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
118 120
119 // which gui (video / audio) 121 // which gui (video / audio)
120 mediaPlayerState.setDisplayType( displayType ); 122 mediaPlayerState.setDisplayType( displayType );
121 123
122#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 124#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
123 if ( !disabledSuspendScreenSaver ) { 125 if ( !disabledSuspendScreenSaver ) {
124 disabledSuspendScreenSaver = TRUE; 126 disabledSuspendScreenSaver = TRUE;
125 // Stop the screen from blanking and power saving state 127 // Stop the screen from blanking and power saving state
126 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 128 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
127 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 129 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
128 } 130 }
129#endif 131#endif
130 132
131 length(); 133 length();
132 position(); 134 position();
133} 135}
134 136
135void XineControl::nextMedia() { 137void XineControl::nextMedia() {
136 mediaPlayerState.setNext(); 138 mediaPlayerState.setNext();
137} 139}
138 140
139void XineControl::setGamma( int value ) { 141void XineControl::setGamma( int value ) {
140 libXine->setGamma( value ); 142 libXine->setGamma( value );
141} 143}
142 144
143void XineControl::stop( bool isSet ) { 145void XineControl::stop( bool isSet ) {
144 if ( !isSet ) { 146 if ( !isSet ) {
145 libXine->stop(); 147 libXine->stop();
146 148
147#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 149#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
148 if ( disabledSuspendScreenSaver ) { 150 if ( disabledSuspendScreenSaver ) {
149 disabledSuspendScreenSaver = FALSE; 151 disabledSuspendScreenSaver = FALSE;
150 // Re-enable the suspend mode 152 // Re-enable the suspend mode
151 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 153 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
152 } 154 }
153#endif 155#endif
154 } 156 }
155} 157}
156 158
157/** 159/**
158 * Pause playback 160 * Pause playback
159 * @isSet 161 * @isSet
160 */ 162 */
161void XineControl::pause( bool isSet) { 163void XineControl::pause( bool isSet) {
162 libXine->pause( isSet ); 164 libXine->pause( isSet );
163} 165}
164 166
165 167
166/** 168/**
167 * get current time in playback 169 * get current time in playback
168 */ 170 */
169long XineControl::currentTime() { 171long XineControl::currentTime() {
170 // todo: jede sekunde überprüfen 172 // todo: jede sekunde überprüfen
171 m_currentTime = libXine->currentTime(); 173 m_currentTime = libXine->currentTime();
172 return m_currentTime; 174 return m_currentTime;
173 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 175 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
174} 176}
175 177
176/** 178/**
177 * Set the length of the media file 179 * Set the length of the media file
178 */ 180 */
179void XineControl::length() { 181void XineControl::length() {
180 m_length = libXine->length(); 182 m_length = libXine->length();
181 mediaPlayerState.setLength( m_length ); 183 mediaPlayerState.setLength( m_length );
182} 184}
183 185
184 186
185/** 187/**
186 * Reports the position the xine backend is at right now 188 * Reports the position the xine backend is at right now
187 * @return long the postion in seconds 189 * @return long the postion in seconds
188 */ 190 */
189long XineControl::position() { 191long XineControl::position() {
190 m_position = ( currentTime() ); 192 m_position = ( currentTime() );
191 mediaPlayerState.updatePosition( m_position ); 193 mediaPlayerState.updatePosition( m_position );
192 long emitPos = (long)m_position; 194 long emitPos = (long)m_position;
193 emit positionChanged( emitPos ); 195 emit positionChanged( emitPos );
194 if( mediaPlayerState.isPlaying() ) { 196 if( mediaPlayerState.isPlaying() ) {
195 // needs to be stopped the media is stopped 197 // needs to be stopped the media is stopped
196 QTimer::singleShot( 1000, this, SLOT( position() ) ); 198 QTimer::singleShot( 1000, this, SLOT( position() ) );
197 } 199 }
198 // qDebug("POSITION : %d", m_position); 200 // qDebug("POSITION : %d", m_position);
199 return m_position; 201 return m_position;
200} 202}
201 203
202/** 204/**
203 * Set videoplayback to fullscreen 205 * Set videoplayback to fullscreen
204 * @param isSet 206 * @param isSet
205 */ 207 */
206void XineControl::setFullscreen( bool isSet ) { 208void XineControl::setFullscreen( bool isSet ) {
207 libXine->showVideoFullScreen( isSet ); 209 libXine->showVideoFullScreen( isSet );
208} 210}
209 211
210 212
211QString XineControl::getMetaInfo() { 213QString XineControl::getMetaInfo() {
212 214
213 QString returnString; 215 QString returnString;
214 216
215 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 217 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
216 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
217 } 219 }
218 220
219 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 221 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
220 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
221 } 223 }
222 224
223 if ( !libXine->metaInfo( 2 ).isEmpty() ) { 225 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
224 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); 226 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
225 } 227 }
226 228
227 if ( !libXine->metaInfo( 3 ).isEmpty() ) { 229 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
228 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); 230 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
229 } 231 }
230 232
231 if ( !libXine->metaInfo( 4 ).isEmpty() ) { 233 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
232 returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); 234 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
233 } 235 }
234 236
235 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 237 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
236 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 238 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
237 } 239 }
238 return returnString; 240 return returnString;
239} 241}
240 242
241QString XineControl::getErrorCode() { 243QString XineControl::getErrorCode() {
242 244
243 int errorCode = libXine->error(); 245 int errorCode = libXine->error();
244 246
245 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); 247 qDebug( QString("ERRORCODE: %1 ").arg(errorCode) );
246 248
247 if ( errorCode == 1 ) { 249 if ( errorCode == 1 ) {
248 return tr( "No input plugin found for this media type" ); 250 return tr( "No input plugin found for this media type" );
249 } else if ( errorCode == 2 ) { 251 } else if ( errorCode == 2 ) {
250 return tr( "No demux plugin found for this media type" ); 252 return tr( "No demux plugin found for this media type" );
251 } else if ( errorCode == 3 ) { 253 } else if ( errorCode == 3 ) {