summaryrefslogtreecommitdiff
path: root/noncore/multimedia
Unidiff
Diffstat (limited to 'noncore/multimedia') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp39
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp50
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp15
8 files changed, 55 insertions, 130 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 248221b..8afb318 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -121,59 +121,49 @@ void Lib::initialize()
121 m_xine = xine_new( ); 121 m_xine = xine_new( );
122 122
123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; 123 QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf";
124 xine_config_load( m_xine, QFile::encodeName( configPath ) ); 124 xine_config_load( m_xine, QFile::encodeName( configPath ) );
125 125
126 xine_init( m_xine ); 126 xine_init( m_xine );
127 127
128 // allocate oss for sound 128 // allocate oss for sound
129 // and fb for framebuffer 129 // and fb for framebuffer
130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); 130 m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL );
131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); 131 m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this );
132 132
133
134//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL);
135
136
137// null_display_handler( m_videoOutput, xine_display_frame, this );
138
139 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); 133 m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
140 134
141 if (m_wid != 0 ) { 135 if (m_wid != 0 )
142 printf( "!0\n" );
143 setWidget( m_wid ); 136 setWidget( m_wid );
144 }
145 137
146 m_queue = xine_event_new_queue (m_stream);
147 138
139 m_queue = xine_event_new_queue (m_stream);
148 xine_event_create_listener_thread (m_queue, xine_event_handler, this); 140 xine_event_create_listener_thread (m_queue, xine_event_handler, this);
149 141
150 ::null_preload_decoders( m_stream ); 142 ::null_preload_decoders( m_stream );
151 143
152 m_duringInitialization = false; 144 m_duringInitialization = false;
153} 145}
154 146
155Lib::~Lib() { 147Lib::~Lib() {
156 assert( isRunning() == false ); 148 assert( isRunning() == false );
157 assert( m_initialized ); 149 assert( m_initialized );
158 150
159// free( m_config ); 151// free( m_config );
160 152
161 xine_close( m_stream ); 153 xine_close( m_stream );
162
163 xine_event_dispose_queue( m_queue ); 154 xine_event_dispose_queue( m_queue );
164
165 xine_dispose( m_stream ); 155 xine_dispose( m_stream );
166
167 xine_exit( m_xine ); 156 xine_exit( m_xine );
157
168 /* FIXME either free or delete but valgrind bitches against both */ 158 /* FIXME either free or delete but valgrind bitches against both */
169 //free( m_videoOutput ); 159 //free( m_videoOutput );
170 //delete m_audioOutput; 160 //delete m_audioOutput;
171} 161}
172 162
173void Lib::resize ( const QSize &s ) { 163void Lib::resize ( const QSize &s ) {
174 assert( m_initialized || m_duringInitialization ); 164 assert( m_initialized || m_duringInitialization );
175 165
176 if ( s. width ( ) && s. height ( ) ) { 166 if ( s. width ( ) && s. height ( ) ) {
177 ::null_set_gui_width( m_videoOutput, s. width() ); 167 ::null_set_gui_width( m_videoOutput, s. width() );
178 ::null_set_gui_height( m_videoOutput, s. height() ); 168 ::null_set_gui_height( m_videoOutput, s. height() );
179 } 169 }
@@ -190,44 +180,36 @@ int Lib::minorVersion() {
190 xine_get_version ( &major, &minor, &sub ); 180 xine_get_version ( &major, &minor, &sub );
191 return minor; 181 return minor;
192} 182}
193 183
194int Lib::subVersion() { 184int Lib::subVersion() {
195 int major, minor, sub; 185 int major, minor, sub;
196 xine_get_version ( &major, &minor, &sub ); 186 xine_get_version ( &major, &minor, &sub );
197 return sub; 187 return sub;
198} 188}
199 189
200int Lib::play( const QString& fileName, int startPos, int start_time ) { 190int Lib::play( const QString& fileName, int startPos, int start_time ) {
201 assert( m_initialized ); 191 assert( m_initialized );
202 // FIXME actually a hack imho. Should not be needed to dispose the whole stream
203 // but without we get wrong media length reads from libxine for the second media
204 //xine_dispose ( m_stream );
205 192
206 QString str = fileName.stripWhiteSpace(); 193 QString str = fileName.stripWhiteSpace();
207 194
208 //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput );
209 //m_queue = xine_event_new_queue (m_stream);
210 //xine_event_create_listener_thread (m_queue, xine_event_handler, this);
211 195
212 if ( !xine_open( m_stream, str.utf8().data() ) ) { 196 if ( !xine_open( m_stream, str.utf8().data() ) ) {
213 return 0; 197 return 0;
214 } 198 }
215 return xine_play( m_stream, startPos, start_time); 199 return xine_play( m_stream, startPos, start_time);
216} 200}
217 201
218void Lib::stop() { 202void Lib::stop() {
219 assert( m_initialized ); 203 assert( m_initialized );
220
221 odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl;
222 xine_stop( m_stream ); 204 xine_stop( m_stream );
223} 205}
224 206
225void Lib::pause( bool toggle ) { 207void Lib::pause( bool toggle ) {
226 assert( m_initialized ); 208 assert( m_initialized );
227 209
228 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); 210 xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL );
229} 211}
230 212
231int Lib::speed() const { 213int Lib::speed() const {
232 assert( m_initialized ); 214 assert( m_initialized );
233 215
@@ -249,30 +231,30 @@ int Lib::status() const {
249int Lib::currentPosition() const { 231int Lib::currentPosition() const {
250 assert( m_initialized ); 232 assert( m_initialized );
251 233
252 int pos, time, length; 234 int pos, time, length;
253 xine_get_pos_length( m_stream, &pos, &time, &length ); 235 xine_get_pos_length( m_stream, &pos, &time, &length );
254 return pos; 236 return pos;
255} 237}
256 238
257int Lib::currentTime() const { 239int Lib::currentTime() const {
258 assert( m_initialized ); 240 assert( m_initialized );
259 241
260 int pos, time, length; 242 int pos, time, length;
261 xine_get_pos_length( m_stream, &pos, &time, &length ); 243 pos = time = length = 0;
262 if ( time > 0 ) { 244
245 if ( xine_get_pos_length( m_stream, &pos, &time, &length ) )
263 return time/1000; 246 return time/1000;
264 } else { 247 else
265 return 0; 248 return 0;
266 }
267} 249}
268 250
269int Lib::length() const { 251int Lib::length() const {
270 assert( m_initialized ); 252 assert( m_initialized );
271 253
272 int pos, time, length; 254 int pos, time, length;
273/* dilb: patch to solve the wrong stream length reported to the GUI*/ 255/* dilb: patch to solve the wrong stream length reported to the GUI*/
274 int iRetVal=0, iTestLoop=0; 256 int iRetVal=0, iTestLoop=0;
275 257
276 do 258 do
277 { 259 {
278 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); 260 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
@@ -291,26 +273,24 @@ unseekable, but it should never occur!! Mr. Murphy ? :) ) */
291 return -1; 273 return -1;
292} 274}
293 275
294bool Lib::isSeekable() const { 276bool Lib::isSeekable() const {
295 assert( m_initialized ); 277 assert( m_initialized );
296 278
297 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); 279 return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE );
298} 280}
299 281
300void Lib::seekTo( int time ) { 282void Lib::seekTo( int time ) {
301 assert( m_initialized ); 283 assert( m_initialized );
302 284
303 //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
304 // since its now milliseconds we need *1000
305 xine_play( m_stream, 0, time*1000 ); 285 xine_play( m_stream, 0, time*1000 );
306} 286}
307 287
308 288
309Frame Lib::currentFrame() const { 289Frame Lib::currentFrame() const {
310 assert( m_initialized ); 290 assert( m_initialized );
311 291
312 Frame frame; 292 Frame frame;
313 return frame; 293 return frame;
314}; 294};
315 295
316QString Lib::metaInfo( int number) const { 296QString Lib::metaInfo( int number) const {
@@ -416,20 +396,19 @@ void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) {
416 ( (Lib*)user_data)->handleXineEvent( t ); 396 ( (Lib*)user_data)->handleXineEvent( t );
417} 397}
418 398
419void Lib::xine_display_frame( void* user_data, uint8_t *frame, 399void Lib::xine_display_frame( void* user_data, uint8_t *frame,
420 int width, int height, int bytes ) { 400 int width, int height, int bytes ) {
421 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); 401 ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
422} 402}
423 403
424void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 404void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
425 assert( m_initialized ); 405 assert( m_initialized );
426 406
427 if ( !m_video ) { 407 if ( !m_video ) {
428 owarn << "not showing video now" << oendl;
429 return; 408 return;
430 } 409 }
431 410
432 assert( m_wid ); 411 assert( m_wid );
433 412
434 m_wid-> setVideoFrame ( frame, width, height, bytes ); 413 m_wid-> setVideoFrame ( frame, width, height, bytes );
435} 414}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e6afbd8..b8023ca 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,19 +1,20 @@
1#include "mediaplayer.h" 1#include "mediaplayer.h"
2#include "audiowidget.h" 2#include "audiowidget.h"
3#include "videowidget.h" 3#include "videowidget.h"
4#include "volumecontrol.h" 4#include "volumecontrol.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <opie2/odevice.h>
8#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
9#include <qpe/config.h> 10#include <qpe/config.h>
10 11
11/* QT */ 12/* QT */
12#include <qfileinfo.h> 13#include <qfileinfo.h>
13 14
14/* STD */ 15/* STD */
15#include <linux/fb.h> 16#include <linux/fb.h>
16#include <sys/file.h> 17#include <sys/file.h>
17#include <sys/ioctl.h> 18#include <sys/ioctl.h>
18 19
19#define FBIOBLANK 0x4611 20#define FBIOBLANK 0x4611
@@ -25,28 +26,24 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla
25 m_videoUI = 0; 26 m_videoUI = 0;
26 m_xineControl = 0; 27 m_xineControl = 0;
27 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 28 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
28 29
29 fd=-1;fl=-1; 30 fd=-1;fl=-1;
30 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 31 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
31 32
32 qApp->processEvents(); 33 qApp->processEvents();
33 // QPEApplication::grabKeyboard(); // EVIL 34 // QPEApplication::grabKeyboard(); // EVIL
34 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 35 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
35 36
36 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 37 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
37
38// What is pauseCheck good for? (Simon)
39// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) );
40
41 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 38 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
42 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 39 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
43 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); 40 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
44 41
45 volControl = new VolumeControl; 42 volControl = new VolumeControl;
46 Config cfg( "OpiePlayer" ); 43 Config cfg( "OpiePlayer" );
47 cfg.setGroup("PlayList"); 44 cfg.setGroup("PlayList");
48 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 45 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
49 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 46 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
50 47
51 m_skinLoader = new SkinLoader; 48 m_skinLoader = new SkinLoader;
52 m_skinLoader->schedule( AudioWidget::guiInfo() ); 49 m_skinLoader->schedule( AudioWidget::guiInfo() );
@@ -145,25 +142,25 @@ void MediaPlayer::next() {
145 142
146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 143 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
147 if ( playList.next() ) { 144 if ( playList.next() ) {
148 play(); 145 play();
149 } else if ( mediaPlayerState.isLooping() ) { 146 } else if ( mediaPlayerState.isLooping() ) {
150 if ( playList.first() ) { 147 if ( playList.first() ) {
151 play(); 148 play();
152 } 149 }
153 } else { 150 } else {
154 mediaPlayerState.setList(); 151 mediaPlayerState.setList();
155 } 152 }
156 } else { //if playing from file list, let's just stop 153 } else { //if playing from file list, let's just stop
157 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; 154 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl;
158 mediaPlayerState.setPlaying(false); 155 mediaPlayerState.setPlaying(false);
159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 156 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
160 if(l) mediaPlayerState.setLooping(l); 157 if(l) mediaPlayerState.setLooping(l);
161 if(r) mediaPlayerState.setShuffled(r); 158 if(r) mediaPlayerState.setShuffled(r);
162 } 159 }
163 qApp->processEvents(); 160 qApp->processEvents();
164} 161}
165 162
166 163
167void MediaPlayer::startDecreasingVolume() { 164void MediaPlayer::startDecreasingVolume() {
168 volumeDirection = -1; 165 volumeDirection = -1;
169 startTimer( 100 ); 166 startTimer( 100 );
@@ -272,91 +269,54 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
272 for ( unsigned int i = 0; i < 10; i++ ) { 269 for ( unsigned int i = 0; i < 10; i++ ) {
273 if ( v > i ) { 270 if ( v > i ) {
274 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 271 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
275 } else { 272 } else {
276 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 273 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
277 } 274 }
278 } 275 }
279 } 276 }
280} 277}
281 278
282 279
283void MediaPlayer::blank( bool b ) { 280void MediaPlayer::blank( bool b ) {
284#ifdef QT_QWS_DEVFS 281 Opie::Core::ODevice::inst()->setDisplayStatus( b );
285 fd=open("/dev/fb/0",O_RDWR);
286#else
287 fd=open("/dev/fb0",O_RDWR);
288#endif
289#ifdef QT_QWS_SL5XXX
290 fl= open( "/dev/fl", O_RDWR );
291#endif
292 if (fd != -1) {
293 if ( b ) {
294 odebug << "do blanking" << oendl;
295#ifdef QT_QWS_SL5XXX
296 ioctl( fd, FBIOBLANK, 1 );
297 if(fl !=-1) {
298 ioctl( fl, 2 );
299 ::close(fl);
300 }
301#else
302 ioctl( fd, FBIOBLANK, 3 );
303#endif
304 isBlanked = TRUE;
305 } else {
306 odebug << "do unblanking" << oendl;
307 ioctl( fd, FBIOBLANK, 0);
308#ifdef QT_QWS_SL5XXX
309 if(fl != -1) {
310 ioctl( fl, 1);
311 ::close(fl);
312 }
313#endif
314 isBlanked = FALSE;
315 }
316 close( fd );
317 } else {
318 odebug << "<< /dev/fb0 could not be opened >>" << oendl;
319 }
320} 282}
321 283
322void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 284void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
323 switch ( e->key() ) { 285 switch ( e->key() ) {
324////////////////////////////// Zaurus keys 286////////////////////////////// Zaurus keys
325 case Key_Home: 287 case Key_Home:
326 break; 288 break;
327 case Key_F9: //activity 289 case Key_F9: //activity
328 break; 290 break;
329 case Key_F10: //contacts 291 case Key_F10: //contacts
330 break; 292 break;
331 case Key_F11: //menu 293 case Key_F11: //menu
332 break; 294 break;
333 case Key_F12: //home 295 case Key_F12: //home
334 odebug << "Blank here" << oendl; 296 odebug << "Blank here" << oendl;
335// mediaPlayerState->toggleBlank(); 297// mediaPlayerState->toggleBlank();
336 break; 298 break;
337 case Key_F13: //mail 299 case Key_F13: //mail
338 odebug << "Blank here" << oendl; 300 odebug << "Blank here" << oendl;
339 // mediaPlayerState->toggleBlank(); 301 // mediaPlayerState->toggleBlank();
340 break; 302 break;
341 } 303 }
342} 304}
343 305
344void MediaPlayer::cleanUp() {// this happens on closing 306void MediaPlayer::cleanUp() {// this happens on closing
345 Config cfg( "OpiePlayer" ); 307 Config cfg( "OpiePlayer" );
346 mediaPlayerState.writeConfig( cfg ); 308 mediaPlayerState.writeConfig( cfg );
347 playList.writeDefaultPlaylist( ); 309 playList.writeDefaultPlaylist( );
348 310
349// QPEApplication::grabKeyboard();
350// QPEApplication::ungrabKeyboard();
351} 311}
352 312
353void MediaPlayer::recreateAudioAndVideoWidgets() const 313void MediaPlayer::recreateAudioAndVideoWidgets() const
354{ 314{
355 delete m_skinLoader; 315 delete m_skinLoader;
356 316
357 delete m_xineControl; 317 delete m_xineControl;
358 delete m_audioUI; 318 delete m_audioUI;
359 delete m_videoUI; 319 delete m_videoUI;
360 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 320 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
361 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 321 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
362 322
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 563ccf5..880b295 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -39,29 +39,28 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla
39} 39}
40 40
41MediaWidget::~MediaWidget() 41MediaWidget::~MediaWidget()
42{ 42{
43} 43}
44 44
45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
46 const Skin &skin ) 46 const Skin &skin )
47{ 47{
48 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 48 buttonMask = skin.buttonMask( skinInfo, buttonCount );
49 49
50 buttons.clear(); 50 buttons.clear();
51 buttons.reserve( buttonCount );
52 51
53 for ( uint i = 0; i < buttonCount; ++i ) { 52 for ( uint i = 0; i < buttonCount; ++i ) {
54 Button button = setupButton( skinInfo[ i ], skin ); 53 Button button = setupButton( skinInfo[ i ], skin );
55 buttons.push_back( button ); 54 buttons.append( button );
56 } 55 }
57} 56}
58 57
59MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 58MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
60{ 59{
61 Button button; 60 Button button;
62 button.command = buttonInfo.command; 61 button.command = buttonInfo.command;
63 button.type = buttonInfo.type; 62 button.type = buttonInfo.type;
64 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 63 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
65 64
66 return button; 65 return button;
67} 66}
@@ -78,68 +77,62 @@ void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, co
78 backgroundPixmap = skin.backgroundPixmap(); 77 backgroundPixmap = skin.backgroundPixmap();
79 buttonUpImage = skin.buttonUpImage(); 78 buttonUpImage = skin.buttonUpImage();
80 buttonDownImage = skin.buttonDownImage(); 79 buttonDownImage = skin.buttonDownImage();
81 80
82 setupButtons( skinInfo, buttonCount, skin ); 81 setupButtons( skinInfo, buttonCount, skin );
83} 82}
84 83
85void MediaWidget::closeEvent( QCloseEvent * ) 84void MediaWidget::closeEvent( QCloseEvent * )
86{ 85{
87 mediaPlayerState.setList(); 86 mediaPlayerState.setList();
88} 87}
89 88
90void MediaWidget::paintEvent( QPaintEvent *pe ) 89void MediaWidget::paintEvent( QPaintEvent * )
91{ 90{
92 QPainter p( this ); 91 QPainter p( this );
93 92
94 if ( mediaPlayerState.isFullscreen() ) {
95 // Clear the background
96 p.setBrush( QBrush( Qt::black ) );
97 return;
98 }
99
100 QPixmap buffer( size() ); 93 QPixmap buffer( size() );
101 QPainter bufferedPainter( &buffer ); 94 QPainter bufferedPainter( &buffer );
102 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); 95 bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
103 paintAllButtons( bufferedPainter ); 96 paintAllButtons( bufferedPainter );
104 p.drawPixmap( 0, 0, buffer ); 97 p.drawPixmap( 0, 0, buffer );
105} 98}
106 99
107void MediaWidget::resizeEvent( QResizeEvent *e ) 100void MediaWidget::resizeEvent( QResizeEvent *e )
108{ 101{
109 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 102 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
110 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 103 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
111 104
112 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 105 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it ) {
113 Button &button = *it; 106 Button &button = *it;
114 107
115 if ( button.mask.isNull() ) 108 if ( button.mask.isNull() )
116 continue; 109 continue;
117 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 110 button.pixUp = addMaskToPixmap( pixUp, button.mask );
118 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 111 button.pixDown = addMaskToPixmap( pixDn, button.mask );
119 } 112 }
120 113
121 QWidget::resizeEvent( e ); 114 QWidget::resizeEvent( e );
122} 115}
123 116
124MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 117MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
125{ 118{
126 if ( position.x() <= 0 || position.y() <= 0 || 119 if ( position.x() <= 0 || position.y() <= 0 ||
127 position.x() >= buttonMask.width() || 120 position.x() >= buttonMask.width() ||
128 position.y() >= buttonMask.height() ) 121 position.y() >= buttonMask.height() )
129 return 0; 122 return 0;
130 123
131 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 124 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
132 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 125 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it )
133 if ( it->command + 1 == pixelIdx ) 126 if ( (*it).command + 1 == pixelIdx )
134 return &( *it ); 127 return &( *it );
135 128
136 return 0; 129 return 0;
137} 130}
138 131
139void MediaWidget::mousePressEvent( QMouseEvent *event ) 132void MediaWidget::mousePressEvent( QMouseEvent *event )
140{ 133{
141 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 134 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
142 135
143 if ( !button ) { 136 if ( !button ) {
144 QWidget::mousePressEvent( event ); 137 QWidget::mousePressEvent( event );
145 return; 138 return;
@@ -184,55 +177,55 @@ void MediaWidget::handleCommand( Command command, bool buttonDown )
184 case VolumeUp: emit moreReleased(); return; 177 case VolumeUp: emit moreReleased(); return;
185 case VolumeDown: emit lessReleased(); return; 178 case VolumeDown: emit lessReleased(); return;
186 case PlayList: mediaPlayerState.setList(); return; 179 case PlayList: mediaPlayerState.setList(); return;
187 case Forward: emit forwardReleased(); return; 180 case Forward: emit forwardReleased(); return;
188 case Back: emit backReleased(); return; 181 case Back: emit backReleased(); return;
189 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 182 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
190 default: assert( false ); 183 default: assert( false );
191 } 184 }
192} 185}
193 186
194bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 187bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
195{ 188{
196 return ( position.x() > 0 && position.y() > 0 && 189 return ( position.x() > 0 && position.y() > 0 &&
197 position.x() < buttonMask.width() && 190 position.x() < buttonMask.width() &&
198 position.y() < buttonMask.height() && 191 position.y() < buttonMask.height() &&
199 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 192 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
200} 193}
201 194
202void MediaWidget::paintAllButtons( QPainter &p ) 195void MediaWidget::paintAllButtons( QPainter &p )
203{ 196{
204 for ( ButtonVector::const_iterator it = buttons.begin(); 197 for ( ButtonVector::ConstIterator it = buttons.begin();
205 it != buttons.end(); ++it ) 198 it != buttons.end(); ++it )
206 paintButton( p, *it ); 199 paintButton( p, *it );
207} 200}
208 201
209void MediaWidget::paintButton( const Button &button ) 202void MediaWidget::paintButton( const Button &button )
210{ 203{
211 QPainter p( this ); 204 QPainter p( this );
212 paintButton( p, button ); 205 paintButton( p, button );
213} 206}
214 207
215void MediaWidget::paintButton( QPainter &p, const Button &button ) 208void MediaWidget::paintButton( QPainter &p, const Button &button )
216{ 209{
217 if ( button.isDown ) 210 if ( button.isDown )
218 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 211 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
219 else 212 else
220 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 213 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
221} 214}
222 215
223void MediaWidget::setToggleButton( Command command, bool down ) 216void MediaWidget::setToggleButton( Command command, bool down )
224{ 217{
225 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 218 for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it )
226 if ( it->command == command ) { 219 if ( (*it).command == command ) {
227 setToggleButton( *it, down ); 220 setToggleButton( *it, down );
228 return; 221 return;
229 } 222 }
230} 223}
231 224
232void MediaWidget::setToggleButton( Button &button, bool down ) 225void MediaWidget::setToggleButton( Button &button, bool down )
233{ 226{
234 if ( down != button.isDown ) 227 if ( down != button.isDown )
235 toggleButton( button ); 228 toggleButton( button );
236} 229}
237 230
238void MediaWidget::toggleButton( Button &button ) 231void MediaWidget::toggleButton( Button &button )
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 8c3a467..d885150 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -20,50 +20,47 @@
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector>
33#include <memory>
34
35class Skin; 32class Skin;
36 33
37class MediaWidget : public QWidget 34class MediaWidget : public QWidget
38{ 35{
39 Q_OBJECT 36 Q_OBJECT
40public: 37public:
41 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
42 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
43 40
44 struct Button 41 struct Button
45 { 42 {
46 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
47 44
48 Command command; 45 Command command;
49 46
50 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
51 bool isDown : 1; 48 bool isDown : 1;
52 49
53 QBitmap mask; 50 QBitmap mask;
54 QPixmap pixUp; 51 QPixmap pixUp;
55 QPixmap pixDown; 52 QPixmap pixDown;
56 }; 53 };
57 typedef std::vector<Button> ButtonVector; 54 typedef QValueList<Button> ButtonVector;
58 55
59 struct SkinButtonInfo 56 struct SkinButtonInfo
60 { 57 {
61 Command command; 58 Command command;
62 const char *fileName; 59 const char *fileName;
63 ButtonType type; 60 ButtonType type;
64 }; 61 };
65 62
66 struct GUIInfo 63 struct GUIInfo
67 { 64 {
68 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {} 65 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {}
69 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount ) 66 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount )
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 36f77be..d73f0cd 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -175,49 +175,46 @@ void PlayListWidget::initializeStates() {
175 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 175 d->tbLoop->setOn( mediaPlayerState->isLooping() );
176 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 176 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
177 d->playListFrame->show(); 177 d->playListFrame->show();
178} 178}
179 179
180void PlayListWidget::writeDefaultPlaylist() { 180void PlayListWidget::writeDefaultPlaylist() {
181 181
182 Config config( "OpiePlayer" ); 182 Config config( "OpiePlayer" );
183 config.setGroup( "PlayList" ); 183 config.setGroup( "PlayList" );
184 QString filename=QPEApplication::documentDir() + "/default.m3u"; 184 QString filename=QPEApplication::documentDir() + "/default.m3u";
185 QString currentString = config.readEntry( "CurrentPlaylist", filename); 185 QString currentString = config.readEntry( "CurrentPlaylist", filename);
186 if( currentString == filename) { 186 if( currentString == filename) {
187 Om3u *m3uList; 187 Om3u *m3uList;
188 // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl;
189 if( d->selectedFiles->first() ) { 188 if( d->selectedFiles->first() ) {
190 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 189 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
191 do { 190 do {
192 // odebug << d->selectedFiles->current()->file() << oendl;
193 m3uList->add( d->selectedFiles->current()->file() ); 191 m3uList->add( d->selectedFiles->current()->file() );
194 } 192 }
195 while ( d->selectedFiles->next() ); 193 while ( d->selectedFiles->next() );
196 194
197 m3uList->write(); 195 m3uList->write();
198 m3uList->close(); 196 m3uList->close();
199 delete m3uList; 197 delete m3uList;
200 198
201 } 199 }
202 } 200 }
203} 201}
204 202
205void PlayListWidget::addToSelection( const DocLnk& lnk ) { 203void PlayListWidget::addToSelection( const DocLnk& lnk ) {
206 d->setDocumentUsed = FALSE; 204 d->setDocumentUsed = FALSE;
207 if( QFileInfo( lnk.file() ).exists() || 205 if( QFileInfo( lnk.file() ).exists() ||
208 lnk.file().left(4) == "http" ) { 206 lnk.file().left(4) == "http" ) {
209 d->selectedFiles->addToSelection( lnk ); 207 d->selectedFiles->addToSelection( lnk );
210 } 208 }
211// writeCurrentM3u();
212} 209}
213 210
214 211
215void PlayListWidget::clearList() { 212void PlayListWidget::clearList() {
216 while ( first() ) { 213 while ( first() ) {
217 d->selectedFiles->removeSelected(); 214 d->selectedFiles->removeSelected();
218 } 215 }
219 Config cfg( "OpiePlayer" ); 216 Config cfg( "OpiePlayer" );
220 cfg.setGroup("PlayList"); 217 cfg.setGroup("PlayList");
221 cfg.writeEntry("CurrentPlaylist","default"); 218 cfg.writeEntry("CurrentPlaylist","default");
222 setCaption("OpiePlayer"); 219 setCaption("OpiePlayer");
223} 220}
@@ -319,32 +316,32 @@ void PlayListWidget::addAllVideoToList() {
319 filename = videoIt.current()->text(3); 316 filename = videoIt.current()->text(3);
320 lnk.setName( QFileInfo(filename).baseName() ); //sets name 317 lnk.setName( QFileInfo(filename).baseName() ); //sets name
321 lnk.setFile( filename ); //sets file name 318 lnk.setFile( filename ); //sets file name
322 d->selectedFiles->addToSelection( lnk); 319 d->selectedFiles->addToSelection( lnk);
323 } 320 }
324 tabWidget->setCurrentPage(0); 321 tabWidget->setCurrentPage(0);
325 writeCurrentM3u(); 322 writeCurrentM3u();
326 d->selectedFiles->first(); 323 d->selectedFiles->first();
327} 324}
328 325
329 326
330void PlayListWidget::setDocument( const QString& _fileref ) { 327void PlayListWidget::setDocument( const QString& _fileref ) {
331 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; 328 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl;
332 QString fileref = _fileref; 329 QString fileref = _fileref;
333 fromSetDocument = TRUE; 330 fromSetDocument = TRUE;
334 331
335 DocLnk lnk(_fileref); 332 DocLnk lnk(_fileref);
336 if(lnk.isValid()) 333 if(lnk.isValid())
337 fileref = lnk.file(); 334 fileref = lnk.file();
338 335
339 QFileInfo fileInfo(fileref); 336 QFileInfo fileInfo(fileref);
340 337
341 if ( !fileInfo.exists() ) { 338 if ( !fileInfo.exists() ) {
342 QMessageBox::warning( this, tr( "Invalid File" ), 339 QMessageBox::warning( this, tr( "Invalid File" ),
343 tr( "There was a problem in getting the file." ) ); 340 tr( "There was a problem in getting the file." ) );
344 return; 341 return;
345 } 342 }
346 343
347 clearList(); 344 clearList();
348 QString extension = fileInfo.extension(false); 345 QString extension = fileInfo.extension(false);
349 346
350 if( extension.find( "m3u", 0, false) != -1 347 if( extension.find( "m3u", 0, false) != -1
@@ -401,25 +398,25 @@ bool PlayListWidget::prev() {
401 if ( mediaPlayerState->isLooping() ) { 398 if ( mediaPlayerState->isLooping() ) {
402 return d->selectedFiles->last(); 399 return d->selectedFiles->last();
403 } else { 400 } else {
404 return FALSE; 401 return FALSE;
405 } 402 }
406 } 403 }
407 return TRUE; 404 return TRUE;
408 } 405 }
409} 406}
410 407
411 408
412bool PlayListWidget::next() { 409bool PlayListWidget::next() {
413//odebug << "<<<<<<<<<<<<next()" << oendl; 410//odebug << "<<<<<<<<<<<<next()" << oendl;
414 if ( mediaPlayerState->isShuffled() ) { 411 if ( mediaPlayerState->isShuffled() ) {
415 return prev(); 412 return prev();
416 } else { 413 } else {
417 if ( !d->selectedFiles->next() ) { 414 if ( !d->selectedFiles->next() ) {
418 if ( mediaPlayerState->isLooping() ) { 415 if ( mediaPlayerState->isLooping() ) {
419 return d->selectedFiles->first(); 416 return d->selectedFiles->first();
420 } else { 417 } else {
421 return FALSE; 418 return FALSE;
422 } 419 }
423 } 420 }
424 return TRUE; 421 return TRUE;
425 } 422 }
@@ -612,25 +609,25 @@ bool PlayListWidget::inFileListMode() const
612 return tab == AudioFiles || tab == VideoFiles; 609 return tab == AudioFiles || tab == VideoFiles;
613} 610}
614 611
615void PlayListWidget::openURL() { 612void PlayListWidget::openURL() {
616 // http://66.28.164.33:2080 613 // http://66.28.164.33:2080
617 // http://somafm.com/star0242.m3u 614 // http://somafm.com/star0242.m3u
618 QString filename, name; 615 QString filename, name;
619 InputDialog *fileDlg; 616 InputDialog *fileDlg;
620 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 617 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
621 fileDlg->exec(); 618 fileDlg->exec();
622 if( fileDlg->result() == 1 ) { 619 if( fileDlg->result() == 1 ) {
623 filename = fileDlg->text(); 620 filename = fileDlg->text();
624 odebug << "Selected filename is " + filename << oendl; 621 odebug << "Selected filename is " + filename << oendl;
625 // Om3u *m3uList; 622 // Om3u *m3uList;
626 DocLnk lnk; 623 DocLnk lnk;
627 Config cfg( "OpiePlayer" ); 624 Config cfg( "OpiePlayer" );
628 cfg.setGroup("PlayList"); 625 cfg.setGroup("PlayList");
629 626
630 if(filename.left(4) == "http") { 627 if(filename.left(4) == "http") {
631 QString m3uFile, m3uFilePath; 628 QString m3uFile, m3uFilePath;
632 if(filename.find(":",8,TRUE) != -1) { //found a port 629 if(filename.find(":",8,TRUE) != -1) { //found a port
633 m3uFile = filename.left( filename.find( ":",8,TRUE)); 630 m3uFile = filename.left( filename.find( ":",8,TRUE));
634 m3uFile = m3uFile.right( 7); 631 m3uFile = m3uFile.right( 7);
635 } else if(filename.left(4) == "http"){ 632 } else if(filename.left(4) == "http"){
636 m3uFile=filename; 633 m3uFile=filename;
@@ -688,56 +685,56 @@ void PlayListWidget::openFile() {
688 685
689 QString str = OFileDialog::getOpenFileName( 1, 686 QString str = OFileDialog::getOpenFileName( 1,
690 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 687 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
691 types, 0 ); 688 types, 0 );
692 689
693 if(str.left(2) == "//") { 690 if(str.left(2) == "//") {
694 str=str.right(str.length()-1); 691 str=str.right(str.length()-1);
695 } 692 }
696 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); 693 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() );
697 694
698 if( !str.isEmpty() ) { 695 if( !str.isEmpty() ) {
699 696
700 odebug << "Selected filename is " + str << oendl; 697 odebug << "Selected filename is " + str << oendl;
701 filename = str; 698 filename = str;
702 DocLnk lnk; 699 DocLnk lnk;
703 700
704 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 701 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
705 readListFromFile( filename ); 702 readListFromFile( filename );
706 } else { 703 } else {
707 lnk.setName( QFileInfo(filename).baseName() ); //sets name 704 lnk.setName( QFileInfo(filename).baseName() ); //sets name
708 lnk.setFile( filename ); //sets file name 705 lnk.setFile( filename ); //sets file name
709 d->selectedFiles->addToSelection( lnk ); 706 d->selectedFiles->addToSelection( lnk );
710 writeCurrentM3u(); 707 writeCurrentM3u();
711 d->selectedFiles->setSelectedItem( lnk.name() ); 708 d->selectedFiles->setSelectedItem( lnk.name() );
712 } 709 }
713 } 710 }
714} 711}
715 712
716 713
717void PlayListWidget::readListFromFile( const QString &filename ) { 714void PlayListWidget::readListFromFile( const QString &filename ) {
718 odebug << "read list filename " + filename << oendl; 715 odebug << "read list filename " + filename << oendl;
719 QFileInfo fi(filename); 716 QFileInfo fi(filename);
720 Om3u *m3uList; 717 Om3u *m3uList;
721 QString s, name; 718 QString s, name;
722 m3uList = new Om3u( filename, IO_ReadOnly ); 719 m3uList = new Om3u( filename, IO_ReadOnly );
723 if(fi.extension(false).find("m3u",0,false) != -1 ) 720 if(fi.extension(false).find("m3u",0,false) != -1 )
724 m3uList->readM3u(); 721 m3uList->readM3u();
725 else if(fi.extension(false).find("pls",0,false) != -1 ) 722 else if(fi.extension(false).find("pls",0,false) != -1 )
726 m3uList->readPls(); 723 m3uList->readPls();
727 724
728 DocLnk lnk; 725 DocLnk lnk;
729 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 726 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
730 s = *it; 727 s = *it;
731 // odebug << s << oendl; 728 // odebug << s << oendl;
732 if(s.left(4)=="http") { 729 if(s.left(4)=="http") {
733 lnk.setName( s ); //sets file name 730 lnk.setName( s ); //sets file name
734 lnk.setIcon("opieplayer2/musicfile"); 731 lnk.setIcon("opieplayer2/musicfile");
735 lnk.setFile( s ); //sets file name 732 lnk.setFile( s ); //sets file name
736 733
737 } else { //is file 734 } else { //is file
738 lnk.setName( QFileInfo(s).baseName()); 735 lnk.setName( QFileInfo(s).baseName());
739 if(s.left(1) != "/") { 736 if(s.left(1) != "/") {
740 737
741 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 738 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
742 } else { 739 } else {
743 lnk.setFile( s); 740 lnk.setFile( s);
@@ -753,39 +750,39 @@ void PlayListWidget::readListFromFile( const QString &filename ) {
753 currentPlayList=filename; 750 currentPlayList=filename;
754 751
755 m3uList->close(); 752 m3uList->close();
756 delete m3uList; 753 delete m3uList;
757 754
758 d->selectedFiles->setSelectedItem( s); 755 d->selectedFiles->setSelectedItem( s);
759 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 756 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
760 757
761} 758}
762 759
763// writes current playlist to current m3u file */ 760// writes current playlist to current m3u file */
764 void PlayListWidget::writeCurrentM3u() { 761 void PlayListWidget::writeCurrentM3u() {
765 odebug << "writing to current m3u" << oendl; 762 odebug << "writing to current m3u" << oendl;
766 Config cfg( "OpiePlayer" ); 763 Config cfg( "OpiePlayer" );
767 cfg.setGroup("PlayList"); 764 cfg.setGroup("PlayList");
768 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 765 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
769 766
770 Om3u *m3uList; 767 Om3u *m3uList;
771 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 768 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
772 if( d->selectedFiles->first()) { 769 if( d->selectedFiles->first()) {
773 770
774 do { 771 do {
775 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 772 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
776 m3uList->add( d->selectedFiles->current()->file() ); 773 m3uList->add( d->selectedFiles->current()->file() );
777 } 774 }
778 while ( d->selectedFiles->next() ); 775 while ( d->selectedFiles->next() );
779 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 776 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
780 m3uList->write(); 777 m3uList->write();
781 m3uList->close(); 778 m3uList->close();
782 } 779 }
783 delete m3uList; 780 delete m3uList;
784 781
785 } 782 }
786 783
787 /* 784 /*
788 writes current playlist to m3u file */ 785 writes current playlist to m3u file */
789void PlayListWidget::writem3u() { 786void PlayListWidget::writem3u() {
790 //InputDilog *fileDlg; 787 //InputDilog *fileDlg;
791 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 788 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
@@ -812,63 +809,63 @@ void PlayListWidget::writem3u() {
812 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 809 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
813 types, 0 ); 810 types, 0 );
814 if(str.left(2) == "//") str=str.right(str.length()-1); 811 if(str.left(2) == "//") str=str.right(str.length()-1);
815 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); 812 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
816 813
817 814
818 QString name, filename, list; 815 QString name, filename, list;
819 Om3u *m3uList; 816 Om3u *m3uList;
820 817
821 if( !str.isEmpty() ) { 818 if( !str.isEmpty() ) {
822 name = str; 819 name = str;
823 // name = fileDlg->text(); 820 // name = fileDlg->text();
824// odebug << filename << oendl; 821// odebug << filename << oendl;
825 if( name.find("/",0,true) != -1) {// assume they specify a file path 822 if( name.find("/",0,true) != -1) {// assume they specify a file path
826 filename = name; 823 filename = name;
827 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 824 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
828 } 825 }
829 else //otherwise dump it somewhere noticable 826 else //otherwise dump it somewhere noticable
830 filename = QPEApplication::documentDir() + "/" + name; 827 filename = QPEApplication::documentDir() + "/" + name;
831 828
832 if( filename.right( 3 ) != "m3u" ) //needs filename extension 829 if( filename.right( 3 ) != "m3u" ) //needs filename extension
833 filename += ".m3u"; 830 filename += ".m3u";
834 831
835 if( d->selectedFiles->first()) { //ramble through playlist view 832 if( d->selectedFiles->first()) { //ramble through playlist view
836 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 833 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
837 834
838 do { 835 do {
839 m3uList->add( d->selectedFiles->current()->file()); 836 m3uList->add( d->selectedFiles->current()->file());
840 } 837 }
841 while ( d->selectedFiles->next() ); 838 while ( d->selectedFiles->next() );
842 // odebug << list << oendl; 839 // odebug << list << oendl;
843 m3uList->write(); 840 m3uList->write();
844 m3uList->close(); 841 m3uList->close();
845 delete m3uList; 842 delete m3uList;
846 843
847 //delete fileDlg; 844 //delete fileDlg;
848 845
849 DocLnk lnk; 846 DocLnk lnk;
850 lnk.setFile( filename); 847 lnk.setFile( filename);
851 lnk.setIcon("opieplayer2/playlist2"); 848 lnk.setIcon("opieplayer2/playlist2");
852 lnk.setName( name); //sets file name 849 lnk.setName( name); //sets file name
853 850
854 // odebug << filename << oendl; 851 // odebug << filename << oendl;
855 Config config( "OpiePlayer" ); 852 Config config( "OpiePlayer" );
856 config.setGroup( "PlayList" ); 853 config.setGroup( "PlayList" );
857 854
858 config.writeEntry("CurrentPlaylist",filename); 855 config.writeEntry("CurrentPlaylist",filename);
859 currentPlayList=filename; 856 currentPlayList=filename;
860 857
861 if(!lnk.writeLink()) { 858 if(!lnk.writeLink()) {
862 odebug << "Writing doclink did not work" << oendl; 859 odebug << "Writing doclink did not work" << oendl;
863 } 860 }
864 861
865 setCaption(tr("OpiePlayer: ") + name); 862 setCaption(tr("OpiePlayer: ") + name);
866 } 863 }
867 } 864 }
868} 865}
869 866
870void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 867void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
871 switch ( e->key() ) { 868 switch ( e->key() ) {
872 ////////////////////////////// Zaurus keys 869 ////////////////////////////// Zaurus keys
873 case Key_F9: //activity 870 case Key_F9: //activity
874 // if(audioUI->isHidden()) 871 // if(audioUI->isHidden())
@@ -884,25 +881,25 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
884 // doBlank(); 881 // doBlank();
885 break; 882 break;
886 case Key_F13: //mail 883 case Key_F13: //mail
887 // doUnblank(); 884 // doUnblank();
888 break; 885 break;
889 case Key_Q: //add to playlist 886 case Key_Q: //add to playlist
890 addSelected(); 887 addSelected();
891 break; 888 break;
892 case Key_R: //remove from playlist 889 case Key_R: //remove from playlist
893 removeSelected(); 890 removeSelected();
894 break; 891 break;
895 // case Key_P: //play 892 // case Key_P: //play
896 // odebug << "Play" << oendl; 893 // odebug << "Play" << oendl;
897 // playSelected(); 894 // playSelected();
898 // break; 895 // break;
899 case Key_Space: 896 case Key_Space:
900 // playSelected(); puh 897 // playSelected(); puh
901 break; 898 break;
902 case Key_1: 899 case Key_1:
903 tabWidget->setCurrentPage( 0 ); 900 tabWidget->setCurrentPage( 0 );
904 break; 901 break;
905 case Key_2: 902 case Key_2:
906 tabWidget->setCurrentPage( 1 ); 903 tabWidget->setCurrentPage( 1 );
907 break; 904 break;
908 case Key_3: 905 case Key_3:
@@ -914,25 +911,25 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
914 case Key_Down: 911 case Key_Down:
915 if ( !d->selectedFiles->next() ) 912 if ( !d->selectedFiles->next() )
916 d->selectedFiles->first(); 913 d->selectedFiles->first();
917 break; 914 break;
918 case Key_Up: 915 case Key_Up:
919 if ( !d->selectedFiles->prev() ) 916 if ( !d->selectedFiles->prev() )
920 // d->selectedFiles->last(); 917 // d->selectedFiles->last();
921 break; 918 break;
922 } 919 }
923} 920}
924 921
925void PlayListWidget::pmViewActivated(int index) { 922void PlayListWidget::pmViewActivated(int index) {
926// odebug << "" << index << "" << oendl; 923// odebug << "" << index << "" << oendl;
927 switch(index) { 924 switch(index) {
928 case -16: 925 case -16:
929 { 926 {
930 mediaPlayerState->toggleFullscreen(); 927 mediaPlayerState->toggleFullscreen();
931 bool b=mediaPlayerState->isFullscreen(); 928 bool b=mediaPlayerState->isFullscreen();
932 pmView->setItemChecked( index, b); 929 pmView->setItemChecked( index, b);
933 Config cfg( "OpiePlayer" ); 930 Config cfg( "OpiePlayer" );
934 cfg.writeEntry( "FullScreen", b ); 931 cfg.writeEntry( "FullScreen", b );
935 } 932 }
936 break; 933 break;
937 }; 934 };
938} 935}
@@ -944,25 +941,25 @@ void PlayListWidget::populateSkinsMenu() {
944 Config cfg( "OpiePlayer" ); 941 Config cfg( "OpiePlayer" );
945 cfg.setGroup("Options" ); 942 cfg.setGroup("Options" );
946 QString skin = cfg.readEntry( "Skin", "default" ); 943 QString skin = cfg.readEntry( "Skin", "default" );
947 944
948 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 945 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
949 skinsDir.setFilter( QDir::Dirs ); 946 skinsDir.setFilter( QDir::Dirs );
950 skinsDir.setSorting(QDir::Name ); 947 skinsDir.setSorting(QDir::Name );
951 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 948 const QFileInfoList *skinslist = skinsDir.entryInfoList();
952 QFileInfoListIterator it( *skinslist ); 949 QFileInfoListIterator it( *skinslist );
953 QFileInfo *fi; 950 QFileInfo *fi;
954 while ( ( fi = it.current() ) ) { 951 while ( ( fi = it.current() ) ) {
955 skinName = fi->fileName(); 952 skinName = fi->fileName();
956// odebug << fi->fileName() << oendl; 953// odebug << fi->fileName() << oendl;
957 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 954 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
958 item = skinsMenu->insertItem( fi->fileName() ) ; 955 item = skinsMenu->insertItem( fi->fileName() ) ;
959 } 956 }
960 if( skinName == "default" ) { 957 if( skinName == "default" ) {
961 defaultSkinIndex = item; 958 defaultSkinIndex = item;
962 } 959 }
963 if( skinName == skin ) { 960 if( skinName == skin ) {
964 skinsMenu->setItemChecked( item, TRUE ); 961 skinsMenu->setItemChecked( item, TRUE );
965 } 962 }
966 ++it; 963 ++it;
967 } 964 }
968} 965}
@@ -1000,25 +997,25 @@ PlayListWidget::Entry PlayListWidget::currentEntry() const
1000 return Entry( lnk->name(), lnk->file() ); 997 return Entry( lnk->name(), lnk->file() );
1001 } 998 }
1002 999
1003 return Entry( currentFileListPathName() ); 1000 return Entry( currentFileListPathName() );
1004} 1001}
1005 1002
1006QString PlayListWidget::currentFileListPathName() const { 1003QString PlayListWidget::currentFileListPathName() const {
1007 return currentFileListView->currentItem()->text( 3 ); 1004 return currentFileListView->currentItem()->text( 3 );
1008} 1005}
1009 1006
1010 1007
1011void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1008void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1012 odebug << "qcop message "+msg << oendl; 1009 odebug << "qcop message "+msg << oendl;
1013 QDataStream stream ( data, IO_ReadOnly ); 1010 QDataStream stream ( data, IO_ReadOnly );
1014 if ( msg == "play()" ) { //plays current selection 1011 if ( msg == "play()" ) { //plays current selection
1015 btnPlay( true); 1012 btnPlay( true);
1016 } else if ( msg == "stop()" ) { 1013 } else if ( msg == "stop()" ) {
1017 mediaPlayerState->setPlaying( false); 1014 mediaPlayerState->setPlaying( false);
1018 } else if ( msg == "togglePause()" ) { 1015 } else if ( msg == "togglePause()" ) {
1019 mediaPlayerState->togglePaused(); 1016 mediaPlayerState->togglePaused();
1020 } else if ( msg == "next()" ) { //select next in list 1017 } else if ( msg == "next()" ) { //select next in list
1021 mediaPlayerState->setNext(); 1018 mediaPlayerState->setNext();
1022 } else if ( msg == "prev()" ) { //select previous in list 1019 } else if ( msg == "prev()" ) { //select previous in list
1023 mediaPlayerState->setPrev(); 1020 mediaPlayerState->setPrev();
1024 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1021 } else if ( msg == "toggleLooping()" ) { //loop or not loop
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index 922f9d7..c3c1282 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -174,20 +174,19 @@ PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name )
174PlayListWidgetGui::~PlayListWidgetGui() { 174PlayListWidgetGui::~PlayListWidgetGui() {
175} 175}
176 176
177void PlayListWidgetGui::setView( char view ) { 177void PlayListWidgetGui::setView( char view ) {
178 if ( view == 'l' ) 178 if ( view == 'l' )
179 showMaximized(); 179 showMaximized();
180 else 180 else
181 hide(); 181 hide();
182} 182}
183 183
184 184
185void PlayListWidgetGui::setActiveWindow() { 185void PlayListWidgetGui::setActiveWindow() {
186 // odebug << "SETTING active window" << oendl;
187 // When we get raised we need to ensure that it switches views 186 // When we get raised we need to ensure that it switches views
188 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); 187 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType();
189 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate 188 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate
190 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back 189 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back
191} 190}
192 191
193 192
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 0625376..2b44701 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -136,24 +136,25 @@ void VideoWidget::setLength( long max ) {
136} 136}
137 137
138void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 138void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
139{ 139{
140 if ( displayType == MediaPlayerState::Video ) { 140 if ( displayType == MediaPlayerState::Video ) {
141 makeVisible(); 141 makeVisible();
142 return; 142 return;
143 } 143 }
144 144
145 // Effectively blank the view next time we show it so it looks nicer 145 // Effectively blank the view next time we show it so it looks nicer
146 scaledWidth = 0; 146 scaledWidth = 0;
147 scaledHeight = 0; 147 scaledHeight = 0;
148 videoFrame->hide();
148 hide(); 149 hide();
149} 150}
150 151
151void VideoWidget::loadSkin() 152void VideoWidget::loadSkin()
152{ 153{
153 loadDefaultSkin( guiInfo() ); 154 loadDefaultSkin( guiInfo() );
154 155
155 delete slider; 156 delete slider;
156 slider = new QSlider( Qt::Horizontal, this ); 157 slider = new QSlider( Qt::Horizontal, this );
157 slider->setMinValue( 0 ); 158 slider->setMinValue( 0 );
158 slider->setMaxValue( 1 ); 159 slider->setMaxValue( 1 );
159 slider->setBackgroundPixmap( backgroundPixmap ); 160 slider->setBackgroundPixmap( backgroundPixmap );
@@ -185,35 +186,35 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
185 makeVisible(); 186 makeVisible();
186 } 187 }
187 MediaWidget::mouseReleaseEvent( event ); 188 MediaWidget::mouseReleaseEvent( event );
188} 189}
189 190
190void VideoWidget::backToNormal() { 191void VideoWidget::backToNormal() {
191 mediaPlayerState.setFullscreen( FALSE ); 192 mediaPlayerState.setFullscreen( FALSE );
192 makeVisible(); 193 makeVisible();
193 setToggleButton( FullScreen, false ); 194 setToggleButton( FullScreen, false );
194} 195}
195 196
196void VideoWidget::makeVisible() { 197void VideoWidget::makeVisible() {
198 videoFrame->show();
197 if ( mediaPlayerState.isFullscreen() ) { 199 if ( mediaPlayerState.isFullscreen() ) {
198 showFullScreen(); 200 showFullScreen();
199 resize( qApp->desktop()->size() ); 201 resize( qApp->desktop()->size() );
200 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 202 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
201 203
202 slider->hide(); 204 slider->hide();
203 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 205 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
204 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 206 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
205 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 207 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
206 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 208 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
207
208 } else { 209 } else {
209 showNormal(); 210 showNormal();
210 showMaximized(); 211 showMaximized();
211 QWidget *d = QApplication::desktop(); 212 QWidget *d = QApplication::desktop();
212 int w = d->width(); 213 int w = d->width();
213 int h = d->height(); 214 int h = d->height();
214 215
215 if(w>h) { 216 if(w>h) {
216 int newW=(w/2)-(246/2); //this will only work with 320x240 217 int newW=(w/2)-(246/2); //this will only work with 320x240
217 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 218 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
218 } else { 219 } else {
219 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 220 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 9f944d7..e1816c8 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -72,59 +72,57 @@ void XineControl::init()
72 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); 72 connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) );
73 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); 73 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) );
74 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); 74 connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) );
75 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); 75 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) );
76 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); 76 connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) );
77 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 77 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
78 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); 78 connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) );
79 79
80 disabledSuspendScreenSaver = FALSE; 80 disabledSuspendScreenSaver = FALSE;
81} 81}
82 82
83XineControl::~XineControl() { 83XineControl::~XineControl() {
84#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 84#if !defined(QT_NO_COP)
85 if ( disabledSuspendScreenSaver ) { 85 if ( disabledSuspendScreenSaver ) {
86 disabledSuspendScreenSaver = FALSE; 86 disabledSuspendScreenSaver = FALSE;
87 // Re-enable the suspend mode 87 // Re-enable the suspend mode
88 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 88 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
89 } 89 }
90#endif 90#endif
91 delete libXine; 91 delete libXine;
92} 92}
93 93
94void XineControl::play( const QString& fileName ) { 94void XineControl::play( const QString& fileName ) {
95 95
96 hasVideoChannel = FALSE; 96 hasVideoChannel = FALSE;
97 hasAudioChannel = FALSE; 97 hasAudioChannel = FALSE;
98 m_fileName = fileName; 98 m_fileName = fileName;
99 99
100 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; 100 odebug << "<<FILENAME: " + fileName + ">>>>" << oendl;
101 101
102 if ( !libXine->play( fileName, 0, 0 ) ) { 102 if ( !libXine->play( fileName, 0, 0 ) ) {
103 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 103 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
104 // toggle stop so the the play button is reset 104 // toggle stop so the the play button is reset
105 mediaPlayerState.setPlaying( false ); 105 mediaPlayerState.setPlaying( false );
106 return; 106 return;
107 } 107 }
108 mediaPlayerState.setPlaying( true ); 108 mediaPlayerState.setPlaying( true );
109 109
110 MediaPlayerState::DisplayType displayType; 110 MediaPlayerState::DisplayType displayType;
111 if ( !libXine->hasVideo() ) { 111 if ( !libXine->hasVideo() ) {
112 displayType = MediaPlayerState::Audio; 112 displayType = MediaPlayerState::Audio;
113 odebug << "HAS AUDIO" << oendl;
114 libXine->setShowVideo( false ); 113 libXine->setShowVideo( false );
115 hasAudioChannel = TRUE; 114 hasAudioChannel = TRUE;
116 } else { 115 } else {
117 displayType = MediaPlayerState::Video; 116 displayType = MediaPlayerState::Video;
118 odebug << "HAS VIDEO" << oendl;
119 libXine->setShowVideo( true ); 117 libXine->setShowVideo( true );
120 hasVideoChannel = TRUE; 118 hasVideoChannel = TRUE;
121 } 119 }
122 // determine if slider is shown 120 // determine if slider is shown
123 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 121 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
124 122
125 // which gui (video / audio) 123 // which gui (video / audio)
126 mediaPlayerState.setDisplayType( displayType ); 124 mediaPlayerState.setDisplayType( displayType );
127 125
128#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 126#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
129 if ( !disabledSuspendScreenSaver ) { 127 if ( !disabledSuspendScreenSaver ) {
130 disabledSuspendScreenSaver = TRUE; 128 disabledSuspendScreenSaver = TRUE;
@@ -141,25 +139,25 @@ void XineControl::play( const QString& fileName ) {
141void XineControl::nextMedia() { 139void XineControl::nextMedia() {
142 mediaPlayerState.setNext(); 140 mediaPlayerState.setNext();
143} 141}
144 142
145void XineControl::setGamma( int value ) { 143void XineControl::setGamma( int value ) {
146 libXine->setGamma( value ); 144 libXine->setGamma( value );
147} 145}
148 146
149void XineControl::stop( bool isSet ) { 147void XineControl::stop( bool isSet ) {
150 if ( !isSet ) { 148 if ( !isSet ) {
151 libXine->stop(); 149 libXine->stop();
152 150
153#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 151#if !defined(QT_NO_COP)
154 if ( disabledSuspendScreenSaver ) { 152 if ( disabledSuspendScreenSaver ) {
155 disabledSuspendScreenSaver = FALSE; 153 disabledSuspendScreenSaver = FALSE;
156 // Re-enable the suspend mode 154 // Re-enable the suspend mode
157 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 155 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
158 } 156 }
159#endif 157#endif
160 } 158 }
161} 159}
162 160
163/** 161/**
164 * Pause playback 162 * Pause playback
165 * @isSet 163 * @isSet
@@ -167,25 +165,24 @@ void XineControl::stop( bool isSet ) {
167void XineControl::pause( bool isSet) { 165void XineControl::pause( bool isSet) {
168 libXine->pause( isSet ); 166 libXine->pause( isSet );
169} 167}
170 168
171 169
172/** 170/**
173 * get current time in playback 171 * get current time in playback
174 */ 172 */
175long XineControl::currentTime() { 173long XineControl::currentTime() {
176 // todo: jede sekunde überprüfen 174 // todo: jede sekunde überprüfen
177 m_currentTime = libXine->currentTime(); 175 m_currentTime = libXine->currentTime();
178 return m_currentTime; 176 return m_currentTime;
179 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
180} 177}
181 178
182/** 179/**
183 * Set the length of the media file 180 * Set the length of the media file
184 */ 181 */
185void XineControl::length() { 182void XineControl::length() {
186 m_length = libXine->length(); 183 m_length = libXine->length();
187 mediaPlayerState.setLength( m_length ); 184 mediaPlayerState.setLength( m_length );
188} 185}
189 186
190 187
191/** 188/**
@@ -238,34 +235,36 @@ QString XineControl::getMetaInfo() {
238 } 235 }
239 236
240 if ( !libXine->metaInfo( 5 ).isEmpty() ) { 237 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
241 returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); 238 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
242 } 239 }
243 return returnString; 240 return returnString;
244} 241}
245 242
246QString XineControl::getErrorCode() { 243QString XineControl::getErrorCode() {
247 244
248 int errorCode = libXine->error(); 245 int errorCode = libXine->error();
249 246
250 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; 247 odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl;
251 248
252 if ( errorCode == 1 ) { 249 if ( errorCode == 1 ) {
253 return tr( "No input plugin found for this media type" ); 250 return tr( "No input plugin found for this media type" );
254 } else if ( errorCode == 2 ) { 251 } else if ( errorCode == 2 ) {
255 return tr( "No demux plugin found for this media type" ); 252 return tr( "No demux plugin found for this media type" );
256 } else if ( errorCode == 3 ) { 253 } else if ( errorCode == 3 ) {
257 return tr( "Demuxing failed for this media type" ); 254 return tr( "Demuxing failed for this media type" );
258 } else if ( errorCode == 4 ) { 255 } else if ( errorCode == 4 ) {
259 return tr( "Malformed MRL" ); 256 return tr( "Malformed MRL" );
257 } else if ( errorCode == 5 ) {
258 return tr( "Input failed" );
260 } else { 259 } else {
261 return tr( "Some other error" ); 260 return tr( "Some other error" );
262 } 261 }
263} 262}
264 263
265/** 264/**
266 * Seek to a position in the track 265 * Seek to a position in the track
267 * @param second the second to jump to 266 * @param second the second to jump to
268 */ 267 */
269void XineControl::seekTo( long second ) { 268void XineControl::seekTo( long second ) {
270 libXine->seekTo( (int)second ); 269 libXine->seekTo( (int)second );
271} 270}