summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index eccb5d9..a9c74c4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -3,85 +3,78 @@
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 18
19#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
20 20
21// for setBacklight() 21// for setBacklight()
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <sys/ioctl.h> 24#include <sys/ioctl.h>
25 25
26 26
27extern AudioWidget *audioUI;
28extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
29extern PlayListWidget *playList; 28extern PlayListWidget *playList;
30 29
31 30
32#define FBIOBLANK 0x4611 31#define FBIOBLANK 0x4611
33 32
34MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 33MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { 34 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) {
36 35
36 audioUI = 0;
37 videoUI = 0;
38 xineControl = 0;
39 recreateAudioAndVideoWidgets();
40
37 fd=-1;fl=-1; 41 fd=-1;fl=-1;
38 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 42 playList->setCaption( tr( "OpiePlayer: Initializating" ) );
39 43
40 qApp->processEvents(); 44 qApp->processEvents();
41 // QPEApplication::grabKeyboard(); // EVIL 45 // QPEApplication::grabKeyboard(); // EVIL
42 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 46 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
43 47
44 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 48 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
45 49
46 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 50 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
47 51
48 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 52 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
49 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 53 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
50 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 54 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
51 55
52 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
53 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
54 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
55 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
56
57 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
58 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
59 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
60 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
61
62 volControl = new VolumeControl; 56 volControl = new VolumeControl;
63 xineControl = new XineControl( mediaPlayerState );
64 Config cfg( "OpiePlayer" ); 57 Config cfg( "OpiePlayer" );
65 cfg.setGroup("PlayList"); 58 cfg.setGroup("PlayList");
66 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 59 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
67 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 60 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
68} 61}
69 62
70MediaPlayer::~MediaPlayer() { 63MediaPlayer::~MediaPlayer() {
71 delete xineControl; 64 delete xineControl;
72 delete volControl; 65 delete volControl;
73} 66}
74 67
75void MediaPlayer::pauseCheck( bool b ) { 68void MediaPlayer::pauseCheck( bool b ) {
76 if ( b && !mediaPlayerState.isPlaying() ) { 69 if ( b && !mediaPlayerState.isPlaying() ) {
77 mediaPlayerState.setPaused( FALSE ); 70 mediaPlayerState.setPaused( FALSE );
78 } 71 }
79} 72}
80 73
81void MediaPlayer::play() { 74void MediaPlayer::play() {
82 mediaPlayerState.setPlaying( FALSE ); 75 mediaPlayerState.setPlaying( FALSE );
83 mediaPlayerState.setPlaying( TRUE ); 76 mediaPlayerState.setPlaying( TRUE );
84} 77}
85 78
86void MediaPlayer::setPlaying( bool play ) { 79void MediaPlayer::setPlaying( bool play ) {
87 if ( !play ) { 80 if ( !play ) {
@@ -330,24 +323,46 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
330 break; 323 break;
331 case Key_F10: //contacts 324 case Key_F10: //contacts
332 break; 325 break;
333 case Key_F11: //menu 326 case Key_F11: //menu
334 break; 327 break;
335 case Key_F12: //home 328 case Key_F12: //home
336 qDebug("Blank here"); 329 qDebug("Blank here");
337// mediaPlayerState->toggleBlank(); 330// mediaPlayerState->toggleBlank();
338 break; 331 break;
339 case Key_F13: //mail 332 case Key_F13: //mail
340 qDebug("Blank here"); 333 qDebug("Blank here");
341 // mediaPlayerState->toggleBlank(); 334 // mediaPlayerState->toggleBlank();
342 break; 335 break;
343 } 336 }
344} 337}
345 338
346void MediaPlayer::cleanUp() {// this happens on closing 339void MediaPlayer::cleanUp() {// this happens on closing
347 Config cfg( "OpiePlayer" ); 340 Config cfg( "OpiePlayer" );
348 mediaPlayerState.writeConfig( cfg ); 341 mediaPlayerState.writeConfig( cfg );
349 playList->writeDefaultPlaylist( ); 342 playList->writeDefaultPlaylist( );
350 343
351// QPEApplication::grabKeyboard(); 344// QPEApplication::grabKeyboard();
352// QPEApplication::ungrabKeyboard(); 345// QPEApplication::ungrabKeyboard();
353} 346}
347
348void MediaPlayer::recreateAudioAndVideoWidgets()
349{
350 delete xineControl;
351 delete audioUI;
352 delete videoUI;
353 audioUI = new AudioWidget( mediaPlayerState, 0, "audioUI" );
354 videoUI = new VideoWidget( mediaPlayerState, 0, "videoUI" );
355
356 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
357 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
358 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
359 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
360
361 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
362 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
363 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
364 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
365
366 xineControl = new XineControl( videoUI, mediaPlayerState );
367}
368