summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 8dadf96..858b51f 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,86 +1,91 @@
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 6
6#include <qmainwindow.h> 7#include <qmainwindow.h>
7#include <qmessagebox.h> 8#include <qmessagebox.h>
8#include <qwidgetstack.h> 9#include <qwidgetstack.h>
9#include <qfile.h> 10#include <qfile.h>
10 11
11#include "mediaplayer.h" 12#include "mediaplayer.h"
12#include "playlistwidget.h" 13#include "playlistwidget.h"
13#include "audiowidget.h" 14#include "audiowidget.h"
14#include "videowidget.h" 15#include "videowidget.h"
15#include "volumecontrol.h" 16#include "volumecontrol.h"
16 17
17#include "mediaplayerstate.h" 18#include "mediaplayerstate.h"
18 19
20// for setBacklight()
21#include <linux/fb.h>
22#include <sys/file.h>
23#include <sys/ioctl.h>
19 24
20 25
21extern AudioWidget *audioUI; 26extern AudioWidget *audioUI;
22extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
23extern PlayListWidget *playList; 28extern PlayListWidget *playList;
24extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
25 30
26 31
27MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 32MediaPlayer::MediaPlayer( QObject *parent, const char *name )
28 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 33 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
29 34
30 35
31 xineControl = new XineControl(); 36 // xineControl = new XineControl();
32// QPEApplication::grabKeyboard(); // EVIL 37// QPEApplication::grabKeyboard(); // EVIL
33 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 38 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
34 39
35 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 40 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
36 41
37 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 42 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
38 43
39 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 44 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
40 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 45 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
46 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
41 47
42 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 48 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
43 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 49 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
44 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 50 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
45 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 51 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
46 52
47 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 53 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
48 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 54 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
49 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
50 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
51 57
52 volControl = new VolumeControl; 58 volControl = new VolumeControl;
53 59 xineControl = new XineControl();
54} 60}
55 61
56MediaPlayer::~MediaPlayer() { 62MediaPlayer::~MediaPlayer() {
57 delete xineControl; 63 delete xineControl;
58 delete volControl; 64 delete volControl;
59} 65}
60 66
61void MediaPlayer::pauseCheck( bool b ) { 67void MediaPlayer::pauseCheck( bool b ) {
62 if ( b && !mediaPlayerState->playing() ) { 68 if ( b && !mediaPlayerState->playing() ) {
63 mediaPlayerState->setPaused( FALSE ); 69 mediaPlayerState->setPaused( FALSE );
64 } 70 }
65} 71}
66 72
67void MediaPlayer::play() { 73void MediaPlayer::play() {
68 mediaPlayerState->setPlaying( FALSE ); 74 mediaPlayerState->setPlaying( FALSE );
69 mediaPlayerState->setPlaying( TRUE ); 75 mediaPlayerState->setPlaying( TRUE );
70} 76}
71 77
72void MediaPlayer::setPlaying( bool play ) { 78void MediaPlayer::setPlaying( bool play ) {
73 if ( !play ) { 79 if ( !play ) {
74 // mediaPlayerState->setPaused( FALSE );
75 return; 80 return;
76 } 81 }
77 82
78 if ( mediaPlayerState->paused() ) { 83 if ( mediaPlayerState->paused() ) {
79 mediaPlayerState->setPaused( FALSE ); 84 mediaPlayerState->setPaused( FALSE );
80 return; 85 return;
81 } 86 }
82 87
83 const DocLnk *playListCurrent = playList->current(); 88 const DocLnk *playListCurrent = playList->current();
84 if ( playListCurrent != NULL ) { 89 if ( playListCurrent != NULL ) {
85 currentFile = playListCurrent; 90 currentFile = playListCurrent;
86 } 91 }
@@ -89,30 +94,24 @@ void MediaPlayer::setPlaying( bool play ) {
89 94
90 xineControl->length(); 95 xineControl->length();
91 long seconds = mediaPlayerState->length();// 96 long seconds = mediaPlayerState->length();//
92 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 97 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
93 qDebug(time); 98 qDebug(time);
94 99
95 QString tickerText; 100 QString tickerText;
96 if( currentFile->file().left(4) == "http" ) 101 if( currentFile->file().left(4) == "http" )
97 tickerText= tr( " File: " ) + currentFile->name(); 102 tickerText= tr( " File: " ) + currentFile->name();
98 else 103 else
99 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 104 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
100 105
101// QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
102
103// if ( !fileInfo.isEmpty() )
104// tickerText += ", " + fileInfo;
105// audioUI->setTickerText( tickerText + "." );
106
107 audioUI->setTickerText( currentFile->file( ) ); 106 audioUI->setTickerText( currentFile->file( ) );
108 107
109} 108}
110 109
111 110
112void MediaPlayer::prev() { 111void MediaPlayer::prev() {
113 if ( playList->prev() ) { 112 if ( playList->prev() ) {
114 play(); 113 play();
115 } else if ( mediaPlayerState->looping() ) { 114 } else if ( mediaPlayerState->looping() ) {
116 if ( playList->last() ) { 115 if ( playList->last() ) {
117 play(); 116 play();
118 } 117 }
@@ -240,44 +239,56 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
240 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 239 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
241 240
242 for ( unsigned int i = 0; i < 10; i++ ) { 241 for ( unsigned int i = 0; i < 10; i++ ) {
243 if ( v > i ) { 242 if ( v > i ) {
244 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 243 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
245 } else { 244 } else {
246 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 245 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
247 } 246 }
248 } 247 }
249 } 248 }
250} 249}
251 250
251
252void MediaPlayer::blank( bool b ) {
253 fd=open("/dev/fb0",O_RDWR);
254 if (fd != -1) {
255
256 if ( !b ) {
257 qDebug("do blanking");
258 ioctl( fd, FBIOBLANK, 3 );
259 isBlanked = TRUE;
260 } else {
261 qDebug("do unblanking");
262 ioctl( fd, FBIOBLANK, 0);
263 isBlanked = FALSE;
264 }
265 close( fd );
266 }
267}
268
252void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 269void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
253 switch ( e->key() ) { 270 switch ( e->key() ) {
254////////////////////////////// Zaurus keys 271////////////////////////////// Zaurus keys
255 case Key_Home: 272 case Key_Home:
256 break; 273 break;
257 case Key_F9: //activity 274 case Key_F9: //activity
258 break; 275 break;
259 case Key_F10: //contacts 276 case Key_F10: //contacts
260 break; 277 break;
261 case Key_F11: //menu 278 case Key_F11: //menu
262 break; 279 break;
263 case Key_F12: //home 280 case Key_F12: //home
264 qDebug("Blank here"); 281 qDebug("Blank here");
282// mediaPlayerState->toggleBlank();
265 break; 283 break;
266 case Key_F13: //mail 284 case Key_F13: //mail
285 qDebug("Blank here");
286// mediaPlayerState->toggleBlank();
267 break; 287 break;
268 } 288 }
269} 289}
270 290
271void MediaPlayer::doBlank() {
272
273}
274
275void MediaPlayer::doUnblank() {
276
277}
278
279void MediaPlayer::cleanUp() { 291void MediaPlayer::cleanUp() {
280// QPEApplication::grabKeyboard(); 292// QPEApplication::grabKeyboard();
281// QPEApplication::ungrabKeyboard(); 293// QPEApplication::ungrabKeyboard();
282
283} 294}