author | simon <simon> | 2002-12-11 11:40:20 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 11:40:20 (UTC) |
commit | 03ac4af4d6014bbd46b12d5fe89ee2cc73941080 (patch) (unidiff) | |
tree | f88296c20f73e7e46d03daff3000ef34acd31bb0 | |
parent | 9431b69a1efab055c28c77e780df012b0a476a57 (diff) | |
download | opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.zip opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.tar.gz opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.tar.bz2 |
- slight simplification of XineControl constructor
- fixed a race between the video resizing and the xine initialization
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 27 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 4 |
5 files changed, 37 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 0d9a5b8..c230d6f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,377 +1,377 @@ | |||
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 | 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 | ||
27 | 27 | ||
28 | 28 | ||
29 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
30 | 30 | ||
31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
33 | 33 | ||
34 | audioUI = 0; | 34 | audioUI = 0; |
35 | videoUI = 0; | 35 | videoUI = 0; |
36 | xineControl = 0; | 36 | xineControl = 0; |
37 | recreateAudioAndVideoWidgets(); | 37 | recreateAudioAndVideoWidgets(); |
38 | 38 | ||
39 | fd=-1;fl=-1; | 39 | fd=-1;fl=-1; |
40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
41 | 41 | ||
42 | qApp->processEvents(); | 42 | qApp->processEvents(); |
43 | // QPEApplication::grabKeyboard(); // EVIL | 43 | // QPEApplication::grabKeyboard(); // EVIL |
44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
45 | 45 | ||
46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
47 | 47 | ||
48 | // What is pauseCheck good for? (Simon) | 48 | // What is pauseCheck good for? (Simon) |
49 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 49 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
50 | 50 | ||
51 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 51 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
52 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 52 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
53 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
54 | 54 | ||
55 | volControl = new VolumeControl; | 55 | volControl = new VolumeControl; |
56 | Config cfg( "OpiePlayer" ); | 56 | Config cfg( "OpiePlayer" ); |
57 | cfg.setGroup("PlayList"); | 57 | cfg.setGroup("PlayList"); |
58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
60 | } | 60 | } |
61 | 61 | ||
62 | MediaPlayer::~MediaPlayer() { | 62 | MediaPlayer::~MediaPlayer() { |
63 | delete xineControl; | 63 | delete xineControl; |
64 | delete audioUI; | 64 | delete audioUI; |
65 | delete videoUI; | 65 | delete videoUI; |
66 | delete volControl; | 66 | delete volControl; |
67 | } | 67 | } |
68 | 68 | ||
69 | void MediaPlayer::pauseCheck( bool b ) { | 69 | void MediaPlayer::pauseCheck( bool b ) { |
70 | if ( b && !mediaPlayerState.isPlaying() ) { | 70 | if ( b && !mediaPlayerState.isPlaying() ) { |
71 | mediaPlayerState.setPaused( FALSE ); | 71 | mediaPlayerState.setPaused( FALSE ); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | void MediaPlayer::play() { | 75 | void MediaPlayer::play() { |
76 | mediaPlayerState.setPlaying( FALSE ); | 76 | mediaPlayerState.setPlaying( FALSE ); |
77 | mediaPlayerState.setPlaying( TRUE ); | 77 | mediaPlayerState.setPlaying( TRUE ); |
78 | } | 78 | } |
79 | 79 | ||
80 | void MediaPlayer::setPlaying( bool play ) { | 80 | void MediaPlayer::setPlaying( bool play ) { |
81 | if ( !play ) { | 81 | if ( !play ) { |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | 84 | ||
85 | if ( mediaPlayerState.isPaused() ) { | 85 | if ( mediaPlayerState.isPaused() ) { |
86 | mediaPlayerState.setPaused( FALSE ); | 86 | mediaPlayerState.setPaused( FALSE ); |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | 89 | ||
90 | QString tickerText, time, fileName; | 90 | QString tickerText, time, fileName; |
91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
92 | //if playing in file list.. play in a different way | 92 | //if playing in file list.. play in a different way |
93 | // random and looping settings enabled causes problems here, | 93 | // random and looping settings enabled causes problems here, |
94 | // since there is no selected file in the playlist, but a selected file in the file list, | 94 | // since there is no selected file in the playlist, but a selected file in the file list, |
95 | // so we remember and shutoff | 95 | // so we remember and shutoff |
96 | l = mediaPlayerState.isLooping(); | 96 | l = mediaPlayerState.isLooping(); |
97 | if(l) { | 97 | if(l) { |
98 | mediaPlayerState.setLooping( false ); | 98 | mediaPlayerState.setLooping( false ); |
99 | } | 99 | } |
100 | r = mediaPlayerState.isShuffled(); | 100 | r = mediaPlayerState.isShuffled(); |
101 | mediaPlayerState.setShuffled( false ); | 101 | mediaPlayerState.setShuffled( false ); |
102 | } | 102 | } |
103 | 103 | ||
104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
105 | fileName = playListEntry.name; | 105 | fileName = playListEntry.name; |
106 | xineControl->play( playListEntry.file ); | 106 | xineControl->play( playListEntry.file ); |
107 | 107 | ||
108 | long seconds = mediaPlayerState.length(); | 108 | long seconds = mediaPlayerState.length(); |
109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
110 | 110 | ||
111 | if( fileName.left(4) == "http" ) { | 111 | if( fileName.left(4) == "http" ) { |
112 | fileName = QFileInfo( fileName ).baseName(); | 112 | fileName = QFileInfo( fileName ).baseName(); |
113 | if ( xineControl->getMetaInfo().isEmpty() ) { | 113 | if ( xineControl->getMetaInfo().isEmpty() ) { |
114 | tickerText = tr( " File: " ) + fileName; | 114 | tickerText = tr( " File: " ) + fileName; |
115 | } else { | 115 | } else { |
116 | tickerText = xineControl->getMetaInfo(); | 116 | tickerText = xineControl->getMetaInfo(); |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | if ( xineControl->getMetaInfo().isEmpty() ) { | 119 | if ( xineControl->getMetaInfo().isEmpty() ) { |
120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
121 | } else { | 121 | } else { |
122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | audioUI->setTickerText( tickerText ); | 125 | audioUI->setTickerText( tickerText ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void MediaPlayer::prev() { | 129 | void MediaPlayer::prev() { |
130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
131 | if ( playList.prev() ) { | 131 | if ( playList.prev() ) { |
132 | play(); | 132 | play(); |
133 | } else if ( mediaPlayerState.isLooping() ) { | 133 | } else if ( mediaPlayerState.isLooping() ) { |
134 | if ( playList.last() ) { | 134 | if ( playList.last() ) { |
135 | play(); | 135 | play(); |
136 | } | 136 | } |
137 | } else { | 137 | } else { |
138 | mediaPlayerState.setList(); | 138 | mediaPlayerState.setList(); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | void MediaPlayer::next() { | 144 | void MediaPlayer::next() { |
145 | 145 | ||
146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
147 | if ( playList.next() ) { | 147 | if ( playList.next() ) { |
148 | play(); | 148 | play(); |
149 | } else if ( mediaPlayerState.isLooping() ) { | 149 | } else if ( mediaPlayerState.isLooping() ) { |
150 | if ( playList.first() ) { | 150 | if ( playList.first() ) { |
151 | play(); | 151 | play(); |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | mediaPlayerState.setList(); | 154 | mediaPlayerState.setList(); |
155 | } | 155 | } |
156 | } else { //if playing from file list, let's just stop | 156 | } else { //if playing from file list, let's just stop |
157 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 157 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
158 | mediaPlayerState.setPlaying(false); | 158 | mediaPlayerState.setPlaying(false); |
159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
160 | if(l) mediaPlayerState.setLooping(l); | 160 | if(l) mediaPlayerState.setLooping(l); |
161 | if(r) mediaPlayerState.setShuffled(r); | 161 | if(r) mediaPlayerState.setShuffled(r); |
162 | } | 162 | } |
163 | qApp->processEvents(); | 163 | qApp->processEvents(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | void MediaPlayer::startDecreasingVolume() { | 167 | void MediaPlayer::startDecreasingVolume() { |
168 | volumeDirection = -1; | 168 | volumeDirection = -1; |
169 | startTimer( 100 ); | 169 | startTimer( 100 ); |
170 | volControl->decVol(2); | 170 | volControl->decVol(2); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void MediaPlayer::startIncreasingVolume() { | 174 | void MediaPlayer::startIncreasingVolume() { |
175 | volumeDirection = +1; | 175 | volumeDirection = +1; |
176 | startTimer( 100 ); | 176 | startTimer( 100 ); |
177 | volControl->incVol(2); | 177 | volControl->incVol(2); |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | bool drawnOnScreenDisplay = FALSE; | 181 | bool drawnOnScreenDisplay = FALSE; |
182 | unsigned int onScreenDisplayVolume = 0; | 182 | unsigned int onScreenDisplayVolume = 0; |
183 | const int yoff = 110; | 183 | const int yoff = 110; |
184 | 184 | ||
185 | void MediaPlayer::stopChangingVolume() { | 185 | void MediaPlayer::stopChangingVolume() { |
186 | killTimers(); | 186 | killTimers(); |
187 | // Get rid of the on-screen display stuff | 187 | // Get rid of the on-screen display stuff |
188 | drawnOnScreenDisplay = FALSE; | 188 | drawnOnScreenDisplay = FALSE; |
189 | onScreenDisplayVolume = 0; | 189 | onScreenDisplayVolume = 0; |
190 | int w=0; | 190 | int w=0; |
191 | int h=0; | 191 | int h=0; |
192 | if( !xineControl->hasVideo() ) { | 192 | if( !xineControl->hasVideo() ) { |
193 | w = audioUI->width(); | 193 | w = audioUI->width(); |
194 | h = audioUI->height(); | 194 | h = audioUI->height(); |
195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
196 | } else { | 196 | } else { |
197 | w = videoUI->width(); | 197 | w = videoUI->width(); |
198 | h = videoUI->height(); | 198 | h = videoUI->height(); |
199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 204 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
205 | if ( volumeDirection == +1 ) { | 205 | if ( volumeDirection == +1 ) { |
206 | volControl->incVol( 2 ); | 206 | volControl->incVol( 2 ); |
207 | } else if ( volumeDirection == -1 ) { | 207 | } else if ( volumeDirection == -1 ) { |
208 | volControl->decVol( 2 ); | 208 | volControl->decVol( 2 ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | // TODO FIXME | 212 | // TODO FIXME |
213 | // huh?? | 213 | // huh?? |
214 | unsigned int v= 0; | 214 | unsigned int v= 0; |
215 | v = volControl->volume(); | 215 | v = volControl->volume(); |
216 | v = v / 10; | 216 | v = v / 10; |
217 | 217 | ||
218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | int w=0; int h=0; | 222 | int w=0; int h=0; |
223 | if( !xineControl->hasVideo() ) { | 223 | if( !xineControl->hasVideo() ) { |
224 | w = audioUI->width(); | 224 | w = audioUI->width(); |
225 | h = audioUI->height(); | 225 | h = audioUI->height(); |
226 | 226 | ||
227 | if ( drawnOnScreenDisplay ) { | 227 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 228 | if ( onScreenDisplayVolume > v ) { |
229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | drawnOnScreenDisplay = TRUE; | 232 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 233 | onScreenDisplayVolume = v; |
234 | QPainter p( audioUI ); | 234 | QPainter p( audioUI ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 237 | ||
238 | QFont f; | 238 | QFont f; |
239 | f.setPixelSize( 20 ); | 239 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 240 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 241 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 243 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 244 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 245 | if ( v > i ) { |
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 247 | } else { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } else { | 251 | } else { |
252 | w = videoUI->width(); | 252 | w = videoUI->width(); |
253 | h = videoUI->height(); | 253 | h = videoUI->height(); |
254 | 254 | ||
255 | if ( drawnOnScreenDisplay ) { | 255 | if ( drawnOnScreenDisplay ) { |
256 | if ( onScreenDisplayVolume > v ) { | 256 | if ( onScreenDisplayVolume > v ) { |
257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | drawnOnScreenDisplay = TRUE; | 260 | drawnOnScreenDisplay = TRUE; |
261 | onScreenDisplayVolume = v; | 261 | onScreenDisplayVolume = v; |
262 | QPainter p( videoUI ); | 262 | QPainter p( videoUI ); |
263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
265 | 265 | ||
266 | QFont f; | 266 | QFont f; |
267 | f.setPixelSize( 20 ); | 267 | f.setPixelSize( 20 ); |
268 | f.setBold( TRUE ); | 268 | f.setBold( TRUE ); |
269 | p.setFont( f ); | 269 | p.setFont( f ); |
270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
271 | 271 | ||
272 | for ( unsigned int i = 0; i < 10; i++ ) { | 272 | for ( unsigned int i = 0; i < 10; i++ ) { |
273 | if ( v > i ) { | 273 | if ( v > i ) { |
274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
275 | } else { | 275 | } else { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void MediaPlayer::blank( bool b ) { | 283 | void MediaPlayer::blank( bool b ) { |
284 | fd=open("/dev/fb0",O_RDWR); | 284 | fd=open("/dev/fb0",O_RDWR); |
285 | #ifdef QT_QWS_EBX | 285 | #ifdef QT_QWS_EBX |
286 | fl= open( "/dev/fl", O_RDWR ); | 286 | fl= open( "/dev/fl", O_RDWR ); |
287 | #endif | 287 | #endif |
288 | if (fd != -1) { | 288 | if (fd != -1) { |
289 | if ( b ) { | 289 | if ( b ) { |
290 | qDebug("do blanking"); | 290 | qDebug("do blanking"); |
291 | #ifdef QT_QWS_EBX | 291 | #ifdef QT_QWS_EBX |
292 | ioctl( fd, FBIOBLANK, 1 ); | 292 | ioctl( fd, FBIOBLANK, 1 ); |
293 | if(fl !=-1) { | 293 | if(fl !=-1) { |
294 | ioctl( fl, 2 ); | 294 | ioctl( fl, 2 ); |
295 | ::close(fl); | 295 | ::close(fl); |
296 | } | 296 | } |
297 | #else | 297 | #else |
298 | ioctl( fd, FBIOBLANK, 3 ); | 298 | ioctl( fd, FBIOBLANK, 3 ); |
299 | #endif | 299 | #endif |
300 | isBlanked = TRUE; | 300 | isBlanked = TRUE; |
301 | } else { | 301 | } else { |
302 | qDebug("do unblanking"); | 302 | qDebug("do unblanking"); |
303 | ioctl( fd, FBIOBLANK, 0); | 303 | ioctl( fd, FBIOBLANK, 0); |
304 | #ifdef QT_QWS_EBX | 304 | #ifdef QT_QWS_EBX |
305 | if(fl != -1) { | 305 | if(fl != -1) { |
306 | ioctl( fl, 1); | 306 | ioctl( fl, 1); |
307 | ::close(fl); | 307 | ::close(fl); |
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | isBlanked = FALSE; | 310 | isBlanked = FALSE; |
311 | } | 311 | } |
312 | close( fd ); | 312 | close( fd ); |
313 | } else { | 313 | } else { |
314 | qDebug("<< /dev/fb0 could not be opened >>"); | 314 | qDebug("<< /dev/fb0 could not be opened >>"); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
319 | switch ( e->key() ) { | 319 | switch ( e->key() ) { |
320 | ////////////////////////////// Zaurus keys | 320 | ////////////////////////////// Zaurus keys |
321 | case Key_Home: | 321 | case Key_Home: |
322 | break; | 322 | break; |
323 | case Key_F9: //activity | 323 | case Key_F9: //activity |
324 | break; | 324 | break; |
325 | case Key_F10: //contacts | 325 | case Key_F10: //contacts |
326 | break; | 326 | break; |
327 | case Key_F11: //menu | 327 | case Key_F11: //menu |
328 | break; | 328 | break; |
329 | case Key_F12: //home | 329 | case Key_F12: //home |
330 | qDebug("Blank here"); | 330 | qDebug("Blank here"); |
331 | // mediaPlayerState->toggleBlank(); | 331 | // mediaPlayerState->toggleBlank(); |
332 | break; | 332 | break; |
333 | case Key_F13: //mail | 333 | case Key_F13: //mail |
334 | qDebug("Blank here"); | 334 | qDebug("Blank here"); |
335 | // mediaPlayerState->toggleBlank(); | 335 | // mediaPlayerState->toggleBlank(); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | void MediaPlayer::cleanUp() {// this happens on closing | 340 | void MediaPlayer::cleanUp() {// this happens on closing |
341 | Config cfg( "OpiePlayer" ); | 341 | Config cfg( "OpiePlayer" ); |
342 | mediaPlayerState.writeConfig( cfg ); | 342 | mediaPlayerState.writeConfig( cfg ); |
343 | playList.writeDefaultPlaylist( ); | 343 | playList.writeDefaultPlaylist( ); |
344 | 344 | ||
345 | // QPEApplication::grabKeyboard(); | 345 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 346 | // QPEApplication::ungrabKeyboard(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() | 349 | void MediaPlayer::recreateAudioAndVideoWidgets() |
350 | { | 350 | { |
351 | delete xineControl; | 351 | delete xineControl; |
352 | delete audioUI; | 352 | delete audioUI; |
353 | delete videoUI; | 353 | delete videoUI; |
354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 356 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 361 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 366 | ||
367 | xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); | 367 | xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); |
368 | connect( xineControl, SIGNAL( initialized() ), | 368 | connect( xineControl, SIGNAL( initialized() ), |
369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); | 369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); |
370 | } | 370 | } |
371 | 371 | ||
372 | void MediaPlayer::reloadSkins() | 372 | void MediaPlayer::reloadSkins() |
373 | { | 373 | { |
374 | audioUI->loadSkin(); | 374 | audioUI->loadSkin(); |
375 | videoUI->loadSkin(); | 375 | videoUI->loadSkin(); |
376 | } | 376 | } |
377 | 377 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 14e71d9..e791c3b 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,256 +1,264 @@ | |||
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 | 42 | ||
42 | XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, | 43 | XineControl::XineControl( XineVideoWidget *xineWidget, |
43 | MediaPlayerState &_mediaPlayerState, | 44 | MediaPlayerState &_mediaPlayerState, |
44 | QObject *parent, const char *name ) | 45 | QObject *parent, const char *name ) |
45 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) | 46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
46 | { | 47 | { |
47 | 48 | ||
48 | libXine = new XINE::Lib( xineWidget ); | 49 | libXine = new XINE::Lib( xineWidget ); |
49 | 50 | ||
50 | connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); | ||
51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); | 52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); |
53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
58 | connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); | 58 | connect( libXine, SIGNAL( initialized() ), this, SLOT( xineInitialized() ) ); |
59 | 59 | ||
60 | disabledSuspendScreenSaver = FALSE; | 60 | disabledSuspendScreenSaver = FALSE; |
61 | } | 61 | } |
62 | 62 | ||
63 | XineControl::~XineControl() { | 63 | XineControl::~XineControl() { |
64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
65 | if ( disabledSuspendScreenSaver ) { | 65 | if ( disabledSuspendScreenSaver ) { |
66 | disabledSuspendScreenSaver = FALSE; | 66 | disabledSuspendScreenSaver = FALSE; |
67 | // Re-enable the suspend mode | 67 | // Re-enable the suspend mode |
68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
69 | } | 69 | } |
70 | #endif | 70 | #endif |
71 | delete libXine; | 71 | delete libXine; |
72 | } | 72 | } |
73 | 73 | ||
74 | void XineControl::play( const QString& fileName ) { | 74 | void XineControl::play( const QString& fileName ) { |
75 | hasVideoChannel = FALSE; | 75 | hasVideoChannel = FALSE; |
76 | hasAudioChannel = FALSE; | 76 | hasAudioChannel = FALSE; |
77 | m_fileName = fileName; | 77 | m_fileName = fileName; |
78 | 78 | ||
79 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 79 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
80 | 80 | ||
81 | if ( !libXine->play( fileName, 0, 0 ) ) { | 81 | if ( !libXine->play( fileName, 0, 0 ) ) { |
82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
83 | // toggle stop so the the play button is reset | 83 | // toggle stop so the the play button is reset |
84 | mediaPlayerState.setPlaying( false ); | 84 | mediaPlayerState.setPlaying( false ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | mediaPlayerState.setPlaying( true ); | 87 | mediaPlayerState.setPlaying( true ); |
88 | 88 | ||
89 | MediaPlayerState::DisplayType displayType; | 89 | MediaPlayerState::DisplayType displayType; |
90 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); | 90 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); |
91 | if ( !libXine->hasVideo() ) { | 91 | if ( !libXine->hasVideo() ) { |
92 | displayType = MediaPlayerState::Audio; | 92 | displayType = MediaPlayerState::Audio; |
93 | qDebug("HAS AUDIO"); | 93 | qDebug("HAS AUDIO"); |
94 | libXine->setShowVideo( false ); | 94 | libXine->setShowVideo( false ); |
95 | hasAudioChannel = TRUE; | 95 | hasAudioChannel = TRUE; |
96 | } else { | 96 | } else { |
97 | displayType = MediaPlayerState::Video; | 97 | displayType = MediaPlayerState::Video; |
98 | qDebug("HAS VIDEO"); | 98 | qDebug("HAS VIDEO"); |
99 | libXine->setShowVideo( true ); | 99 | libXine->setShowVideo( true ); |
100 | hasVideoChannel = TRUE; | 100 | hasVideoChannel = TRUE; |
101 | } | 101 | } |
102 | // determine if slider is shown | 102 | // determine if slider is shown |
103 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 103 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
104 | 104 | ||
105 | // which gui (video / audio) | 105 | // which gui (video / audio) |
106 | mediaPlayerState.setDisplayType( displayType ); | 106 | mediaPlayerState.setDisplayType( displayType ); |
107 | 107 | ||
108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
109 | if ( !disabledSuspendScreenSaver ) { | 109 | if ( !disabledSuspendScreenSaver ) { |
110 | disabledSuspendScreenSaver = TRUE; | 110 | disabledSuspendScreenSaver = TRUE; |
111 | // Stop the screen from blanking and power saving state | 111 | // Stop the screen from blanking and power saving state |
112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
114 | } | 114 | } |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | length(); | 117 | length(); |
118 | position(); | 118 | position(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void XineControl::nextMedia() { | 121 | void XineControl::nextMedia() { |
122 | mediaPlayerState.setNext(); | 122 | mediaPlayerState.setNext(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void XineControl::setGamma( int value ) { | 125 | void XineControl::setGamma( int value ) { |
126 | libXine->setGamma( value ); | 126 | libXine->setGamma( value ); |
127 | } | 127 | } |
128 | 128 | ||
129 | void XineControl::xineInitialized() | ||
130 | { | ||
131 | connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); | ||
132 | libXine->resize( xineVideoWidget->videoSize() ); | ||
133 | |||
134 | emit initialized(); | ||
135 | } | ||
136 | |||
129 | void XineControl::stop( bool isSet ) { | 137 | void XineControl::stop( bool isSet ) { |
130 | if ( !isSet ) { | 138 | if ( !isSet ) { |
131 | libXine->stop(); | 139 | libXine->stop(); |
132 | 140 | ||
133 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 141 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
134 | if ( disabledSuspendScreenSaver ) { | 142 | if ( disabledSuspendScreenSaver ) { |
135 | disabledSuspendScreenSaver = FALSE; | 143 | disabledSuspendScreenSaver = FALSE; |
136 | // Re-enable the suspend mode | 144 | // Re-enable the suspend mode |
137 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 145 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
138 | } | 146 | } |
139 | #endif | 147 | #endif |
140 | } | 148 | } |
141 | } | 149 | } |
142 | 150 | ||
143 | /** | 151 | /** |
144 | * Pause playback | 152 | * Pause playback |
145 | * @isSet | 153 | * @isSet |
146 | */ | 154 | */ |
147 | void XineControl::pause( bool isSet) { | 155 | void XineControl::pause( bool isSet) { |
148 | libXine->pause( isSet ); | 156 | libXine->pause( isSet ); |
149 | } | 157 | } |
150 | 158 | ||
151 | 159 | ||
152 | /** | 160 | /** |
153 | * get current time in playback | 161 | * get current time in playback |
154 | */ | 162 | */ |
155 | long XineControl::currentTime() { | 163 | long XineControl::currentTime() { |
156 | // todo: jede sekunde überprüfen | 164 | // todo: jede sekunde überprüfen |
157 | m_currentTime = libXine->currentTime(); | 165 | m_currentTime = libXine->currentTime(); |
158 | return m_currentTime; | 166 | return m_currentTime; |
159 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 167 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
160 | } | 168 | } |
161 | 169 | ||
162 | /** | 170 | /** |
163 | * Set the length of the media file | 171 | * Set the length of the media file |
164 | */ | 172 | */ |
165 | void XineControl::length() { | 173 | void XineControl::length() { |
166 | m_length = libXine->length(); | 174 | m_length = libXine->length(); |
167 | mediaPlayerState.setLength( m_length ); | 175 | mediaPlayerState.setLength( m_length ); |
168 | } | 176 | } |
169 | 177 | ||
170 | 178 | ||
171 | /** | 179 | /** |
172 | * Reports the position the xine backend is at right now | 180 | * Reports the position the xine backend is at right now |
173 | * @return long the postion in seconds | 181 | * @return long the postion in seconds |
174 | */ | 182 | */ |
175 | long XineControl::position() { | 183 | long XineControl::position() { |
176 | m_position = ( currentTime() ); | 184 | m_position = ( currentTime() ); |
177 | mediaPlayerState.updatePosition( m_position ); | 185 | mediaPlayerState.updatePosition( m_position ); |
178 | long emitPos = (long)m_position; | 186 | long emitPos = (long)m_position; |
179 | emit positionChanged( emitPos ); | 187 | emit positionChanged( emitPos ); |
180 | if( mediaPlayerState.isPlaying() ) { | 188 | if( mediaPlayerState.isPlaying() ) { |
181 | // needs to be stopped the media is stopped | 189 | // needs to be stopped the media is stopped |
182 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 190 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
183 | } | 191 | } |
184 | // qDebug("POSITION : %d", m_position); | 192 | // qDebug("POSITION : %d", m_position); |
185 | return m_position; | 193 | return m_position; |
186 | } | 194 | } |
187 | 195 | ||
188 | /** | 196 | /** |
189 | * Set videoplayback to fullscreen | 197 | * Set videoplayback to fullscreen |
190 | * @param isSet | 198 | * @param isSet |
191 | */ | 199 | */ |
192 | void XineControl::setFullscreen( bool isSet ) { | 200 | void XineControl::setFullscreen( bool isSet ) { |
193 | libXine->showVideoFullScreen( isSet ); | 201 | libXine->showVideoFullScreen( isSet ); |
194 | } | 202 | } |
195 | 203 | ||
196 | 204 | ||
197 | QString XineControl::getMetaInfo() { | 205 | QString XineControl::getMetaInfo() { |
198 | 206 | ||
199 | QString returnString; | 207 | QString returnString; |
200 | 208 | ||
201 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 209 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
202 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 210 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
203 | } | 211 | } |
204 | 212 | ||
205 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 213 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
206 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 214 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
207 | } | 215 | } |
208 | 216 | ||
209 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 217 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
210 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 218 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
211 | } | 219 | } |
212 | 220 | ||
213 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 221 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
214 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 222 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
215 | } | 223 | } |
216 | 224 | ||
217 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 225 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
218 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 226 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
219 | } | 227 | } |
220 | 228 | ||
221 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 229 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
222 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 230 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
223 | } | 231 | } |
224 | return returnString; | 232 | return returnString; |
225 | } | 233 | } |
226 | 234 | ||
227 | QString XineControl::getErrorCode() { | 235 | QString XineControl::getErrorCode() { |
228 | 236 | ||
229 | int errorCode = libXine->error(); | 237 | int errorCode = libXine->error(); |
230 | 238 | ||
231 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 239 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
232 | 240 | ||
233 | if ( errorCode == 1 ) { | 241 | if ( errorCode == 1 ) { |
234 | return tr( "No input plugin found for this media type" ); | 242 | return tr( "No input plugin found for this media type" ); |
235 | } else if ( errorCode == 2 ) { | 243 | } else if ( errorCode == 2 ) { |
236 | return tr( "No demux plugin found for this media type" ); | 244 | return tr( "No demux plugin found for this media type" ); |
237 | } else if ( errorCode == 3 ) { | 245 | } else if ( errorCode == 3 ) { |
238 | return tr( "Demuxing failed for this media type" ); | 246 | return tr( "Demuxing failed for this media type" ); |
239 | } else if ( errorCode == 4 ) { | 247 | } else if ( errorCode == 4 ) { |
240 | return tr( "Malformed MRL" ); | 248 | return tr( "Malformed MRL" ); |
241 | } else { | 249 | } else { |
242 | return tr( "Some other error" ); | 250 | return tr( "Some other error" ); |
243 | } | 251 | } |
244 | } | 252 | } |
245 | 253 | ||
246 | /** | 254 | /** |
247 | * Seek to a position in the track | 255 | * Seek to a position in the track |
248 | * @param second the second to jump to | 256 | * @param second the second to jump to |
249 | */ | 257 | */ |
250 | void XineControl::seekTo( long second ) { | 258 | void XineControl::seekTo( long second ) { |
251 | libXine->seekTo( (int)second ); | 259 | libXine->seekTo( (int)second ); |
252 | } | 260 | } |
253 | 261 | ||
254 | void XineControl::videoResized ( const QSize &s ) { | 262 | void XineControl::videoResized ( const QSize &s ) { |
255 | libXine->resize( s ); | 263 | libXine->resize( s ); |
256 | } | 264 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 000529c..085de3f 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,122 +1,126 @@ | |||
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 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | class XineControl : public QObject { | 42 | class XineControl : public QObject { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, | 45 | XineControl( XineVideoWidget *xineWidget, |
46 | MediaPlayerState &_mediaPlayerState, | 46 | MediaPlayerState &_mediaPlayerState, |
47 | QObject *parent = 0, const char *name =0 ); | 47 | QObject *parent = 0, const char *name =0 ); |
48 | ~XineControl(); | 48 | ~XineControl(); |
49 | 49 | ||
50 | bool hasVideo() const { return hasVideoChannel; } | 50 | bool hasVideo() const { return hasVideoChannel; } |
51 | bool hasAudio() const { return hasAudioChannel; } | 51 | bool hasAudio() const { return hasAudioChannel; } |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void play( const QString& fileName ); | 54 | void play( const QString& fileName ); |
55 | void stop( bool ); | 55 | void stop( bool ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Pause the media stream | 58 | * Pause the media stream |
59 | * @param if pause or not | 59 | * @param if pause or not |
60 | */ | 60 | */ |
61 | void pause( bool ); | 61 | void pause( bool ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Set videos fullscreen | 64 | * Set videos fullscreen |
65 | * @param yes or no | 65 | * @param yes or no |
66 | */ | 66 | */ |
67 | void setFullscreen( bool ); | 67 | void setFullscreen( bool ); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * | 70 | * |
71 | */ | 71 | */ |
72 | long currentTime(); | 72 | long currentTime(); |
73 | void seekTo( long ); | 73 | void seekTo( long ); |
74 | // get length of media file and set it | 74 | // get length of media file and set it |
75 | void length(); | 75 | void length(); |
76 | long position(); | 76 | long position(); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Proceed to the next media file in playlist | 79 | * Proceed to the next media file in playlist |
80 | */ | 80 | */ |
81 | void nextMedia(); | 81 | void nextMedia(); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get as much info about the stream from xine as possible | 84 | * Get as much info about the stream from xine as possible |
85 | */ | 85 | */ |
86 | QString getMetaInfo(); | 86 | QString getMetaInfo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * get the error code and "translate" it for the user | 89 | * get the error code and "translate" it for the user |
90 | * | 90 | * |
91 | */ | 91 | */ |
92 | QString getErrorCode(); | 92 | QString getErrorCode(); |
93 | 93 | ||
94 | 94 | ||
95 | void videoResized ( const QSize &s ); | 95 | void videoResized ( const QSize &s ); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Set the gamma value of the video output | 98 | * Set the gamma value of the video output |
99 | * @param int value between -100 and 100, 0 is original | 99 | * @param int value between -100 and 100, 0 is original |
100 | */ | 100 | */ |
101 | void setGamma( int ); | 101 | void setGamma( int ); |
102 | 102 | ||
103 | 103 | ||
104 | private slots: | ||
105 | void xineInitialized(); | ||
106 | |||
104 | private: | 107 | private: |
105 | XINE::Lib *libXine; | 108 | XINE::Lib *libXine; |
106 | long m_currentTime; | 109 | long m_currentTime; |
107 | long m_position; | 110 | long m_position; |
108 | int m_length; | 111 | int m_length; |
109 | QString m_fileName; | 112 | QString m_fileName; |
110 | bool disabledSuspendScreenSaver : 1; | 113 | bool disabledSuspendScreenSaver : 1; |
111 | bool hasVideoChannel : 1; | 114 | bool hasVideoChannel : 1; |
112 | bool hasAudioChannel : 1; | 115 | bool hasAudioChannel : 1; |
113 | MediaPlayerState &mediaPlayerState; | 116 | MediaPlayerState &mediaPlayerState; |
117 | XineVideoWidget *xineVideoWidget; | ||
114 | 118 | ||
115 | signals: | 119 | signals: |
116 | void positionChanged( long ); | 120 | void positionChanged( long ); |
117 | 121 | ||
118 | void initialized(); | 122 | void initialized(); |
119 | }; | 123 | }; |
120 | 124 | ||
121 | 125 | ||
122 | #endif | 126 | #endif |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1d88cea..791818e 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -1,272 +1,277 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
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 <qimage.h> | 34 | #include <qimage.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #include <qdirectpainter_qws.h> | 37 | #include <qdirectpainter_qws.h> |
38 | #include <qgfx_qws.h> | 38 | #include <qgfx_qws.h> |
39 | #include <qsize.h> | 39 | #include <qsize.h> |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | 42 | ||
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
46 | 46 | ||
47 | 47 | ||
48 | // 0 deg rot: copy a line from src to dst (use libc memcpy) | 48 | // 0 deg rot: copy a line from src to dst (use libc memcpy) |
49 | 49 | ||
50 | // 180 deg rot: copy a line from src to dst reversed | 50 | // 180 deg rot: copy a line from src to dst reversed |
51 | 51 | ||
52 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 52 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
53 | { | 53 | { |
54 | ((char *) src ) += len; | 54 | ((char *) src ) += len; |
55 | 55 | ||
56 | len >>= 1; | 56 | len >>= 1; |
57 | while ( len-- ) | 57 | while ( len-- ) |
58 | *((short int *) dst )++ = *--((short int *) src ); | 58 | *((short int *) dst )++ = *--((short int *) src ); |
59 | } | 59 | } |
60 | 60 | ||
61 | // 90 deg rot: copy a column from src to dst | 61 | // 90 deg rot: copy a column from src to dst |
62 | 62 | ||
63 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 63 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
64 | { | 64 | { |
65 | len >>= 1; | 65 | len >>= 1; |
66 | while ( len-- ) { | 66 | while ( len-- ) { |
67 | *((short int *) dst )++ = *((short int *) src ); | 67 | *((short int *) dst )++ = *((short int *) src ); |
68 | ((char *) src ) += step; | 68 | ((char *) src ) += step; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | // 270 deg rot: copy a column from src to dst reversed | 72 | // 270 deg rot: copy a column from src to dst reversed |
73 | 73 | ||
74 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 74 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
75 | { | 75 | { |
76 | len >>= 1; | 76 | len >>= 1; |
77 | 77 | ||
78 | ((char *) src ) += ( len * step ); | 78 | ((char *) src ) += ( len * step ); |
79 | 79 | ||
80 | while ( len-- ) { | 80 | while ( len-- ) { |
81 | ((char *) src ) -= step; | 81 | ((char *) src ) -= step; |
82 | *((short int *) dst )++ = *((short int *) src ); | 82 | *((short int *) dst )++ = *((short int *) src ); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
89 | { | 89 | { |
90 | setBackgroundMode ( NoBackground ); | 90 | setBackgroundMode ( NoBackground ); |
91 | 91 | ||
92 | m_logo = 0; | 92 | m_logo = 0; |
93 | m_buff = 0; | 93 | m_buff = 0; |
94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
96 | m_rotation = 0; | 96 | m_rotation = 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | XineVideoWidget::~XineVideoWidget ( ) | 100 | XineVideoWidget::~XineVideoWidget ( ) |
101 | { | 101 | { |
102 | delete m_logo; | 102 | delete m_logo; |
103 | } | 103 | } |
104 | 104 | ||
105 | void XineVideoWidget::clear ( ) | 105 | void XineVideoWidget::clear ( ) |
106 | { | 106 | { |
107 | m_buff = 0; | 107 | m_buff = 0; |
108 | repaint ( false ); | 108 | repaint ( false ); |
109 | } | 109 | } |
110 | 110 | ||
111 | QSize XineVideoWidget::videoSize() const | ||
112 | { | ||
113 | QSize s = size(); | ||
114 | bool fs = ( s == qApp->desktop()->size() ); | ||
115 | |||
116 | // if we are in fullscreen mode, do not rotate the video | ||
117 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
118 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; | ||
119 | |||
120 | if ( fs && qt_screen->isTransformed() ) | ||
121 | s = qt_screen->mapToDevice( s ); | ||
122 | |||
123 | return s; | ||
124 | } | ||
125 | |||
111 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 126 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
112 | { | 127 | { |
113 | if ( m_buff == 0 ) { | 128 | if ( m_buff == 0 ) { |
114 | QPainter p ( this ); | 129 | QPainter p ( this ); |
115 | p. fillRect ( rect ( ), black ); | 130 | p. fillRect ( rect ( ), black ); |
116 | if ( m_logo ) | 131 | if ( m_logo ) |
117 | p. drawImage ( 0, 0, *m_logo ); | 132 | p. drawImage ( 0, 0, *m_logo ); |
118 | } | 133 | } |
119 | else { | 134 | else { |
120 | // Qt needs to be notified which areas were really updated .. strange | 135 | // Qt needs to be notified which areas were really updated .. strange |
121 | QArray <QRect> qt_bug_workaround_clip_rects; | 136 | QArray <QRect> qt_bug_workaround_clip_rects; |
122 | 137 | ||
123 | { | 138 | { |
124 | QDirectPainter dp ( this ); | 139 | QDirectPainter dp ( this ); |
125 | 140 | ||
126 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 141 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
127 | 142 | ||
128 | uchar *fb = dp. frameBuffer ( ); | 143 | uchar *fb = dp. frameBuffer ( ); |
129 | uchar *frame = m_buff; | 144 | uchar *frame = m_buff; |
130 | 145 | ||
131 | // where is the video frame in fb coordinates | 146 | // where is the video frame in fb coordinates |
132 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 147 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
133 | 148 | ||
134 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 149 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
135 | 150 | ||
136 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 151 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
137 | const QRect &clip = dp. rect ( i ); | 152 | const QRect &clip = dp. rect ( i ); |
138 | 153 | ||
139 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 154 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
140 | 155 | ||
141 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb | 156 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb |
142 | uchar *src = frame; | 157 | uchar *src = frame; |
143 | 158 | ||
144 | // Adjust the start the source data based on the rotation (xine frame) | 159 | // Adjust the start the source data based on the rotation (xine frame) |
145 | switch ( rot ) { | 160 | switch ( rot ) { |
146 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; | 161 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; |
147 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; | 162 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; |
148 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; | 163 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; |
149 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; | 164 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; |
150 | default: break; | 165 | default: break; |
151 | } | 166 | } |
152 | 167 | ||
153 | // all of the following widths/heights are fb relative (0deg rotation) | 168 | // all of the following widths/heights are fb relative (0deg rotation) |
154 | 169 | ||
155 | uint leftfill = 0; // black border on the "left" side of the video frame | 170 | uint leftfill = 0; // black border on the "left" side of the video frame |
156 | uint framefill = 0; // "width" of the video frame | 171 | uint framefill = 0; // "width" of the video frame |
157 | uint rightfill = 0; // black border on the "right" side of the video frame | 172 | uint rightfill = 0; // black border on the "right" side of the video frame |
158 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | 173 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect |
159 | 174 | ||
160 | if ( clip. left ( ) < framerect. left ( )) | 175 | if ( clip. left ( ) < framerect. left ( )) |
161 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 176 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
162 | if ( clip. right ( ) > framerect. right ( )) | 177 | if ( clip. right ( ) > framerect. right ( )) |
163 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 178 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
164 | 179 | ||
165 | framefill = clipwidth - ( leftfill + rightfill ); | 180 | framefill = clipwidth - ( leftfill + rightfill ); |
166 | 181 | ||
167 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 182 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
168 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 183 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
169 | // "above" or "below" the video -> black | 184 | // "above" or "below" the video -> black |
170 | memset ( dst, 0, clipwidth ); | 185 | memset ( dst, 0, clipwidth ); |
171 | } | 186 | } |
172 | else { | 187 | else { |
173 | if ( leftfill ) | 188 | if ( leftfill ) |
174 | memset ( dst, 0, leftfill ); // "left" border -> black | 189 | memset ( dst, 0, leftfill ); // "left" border -> black |
175 | 190 | ||
176 | if ( framefill ) { // blit in the video frame | 191 | if ( framefill ) { // blit in the video frame |
177 | // see above for an explanation of the different memcpys | 192 | // see above for an explanation of the different memcpys |
178 | 193 | ||
179 | switch ( rot ) { | 194 | switch ( rot ) { |
180 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 195 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
181 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 196 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
182 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 197 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
183 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 198 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
184 | default: break; | 199 | default: break; |
185 | } | 200 | } |
186 | } | 201 | } |
187 | if ( rightfill ) | 202 | if ( rightfill ) |
188 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | 203 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
189 | } | 204 | } |
190 | 205 | ||
191 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 206 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
192 | 207 | ||
193 | // advance one "line" in the xine frame data | 208 | // advance one "line" in the xine frame data |
194 | switch ( rot ) { | 209 | switch ( rot ) { |
195 | case 0: src += m_bytes_per_line_frame;break; | 210 | case 0: src += m_bytes_per_line_frame;break; |
196 | case 1: src -= m_bytes_per_pixel; break; | 211 | case 1: src -= m_bytes_per_pixel; break; |
197 | case 2: src -= m_bytes_per_line_frame; break; | 212 | case 2: src -= m_bytes_per_line_frame; break; |
198 | case 3: src += m_bytes_per_pixel; break; | 213 | case 3: src += m_bytes_per_pixel; break; |
199 | default: break; | 214 | default: break; |
200 | } | 215 | } |
201 | } | 216 | } |
202 | } | 217 | } |
203 | } | 218 | } |
204 | 219 | ||
205 | { | 220 | { |
206 | // QVFB hack by Martin Jones | 221 | // QVFB hack by Martin Jones |
207 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 222 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
208 | 223 | ||
209 | QPainter p ( this ); | 224 | QPainter p ( this ); |
210 | 225 | ||
211 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 226 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
212 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 227 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
213 | } | 228 | } |
214 | } | 229 | } |
215 | } | 230 | } |
216 | } | 231 | } |
217 | 232 | ||
218 | 233 | ||
219 | QImage *XineVideoWidget::logo ( ) const | 234 | QImage *XineVideoWidget::logo ( ) const |
220 | { | 235 | { |
221 | return m_logo; | 236 | return m_logo; |
222 | } | 237 | } |
223 | 238 | ||
224 | 239 | ||
225 | void XineVideoWidget::setLogo ( QImage* logo ) | 240 | void XineVideoWidget::setLogo ( QImage* logo ) |
226 | { | 241 | { |
227 | delete m_logo; | 242 | delete m_logo; |
228 | m_logo = logo; | 243 | m_logo = logo; |
229 | } | 244 | } |
230 | 245 | ||
231 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 246 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
232 | { | 247 | { |
233 | bool rot90 = (( -m_rotation ) & 1 ); | 248 | bool rot90 = (( -m_rotation ) & 1 ); |
234 | 249 | ||
235 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 250 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
236 | int d = w; | 251 | int d = w; |
237 | w = h; | 252 | w = h; |
238 | h = d; | 253 | h = d; |
239 | } | 254 | } |
240 | 255 | ||
241 | m_lastframe = m_thisframe; | 256 | m_lastframe = m_thisframe; |
242 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 257 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
243 | 258 | ||
244 | m_buff = img; | 259 | m_buff = img; |
245 | m_bytes_per_line_frame = bpl; | 260 | m_bytes_per_line_frame = bpl; |
246 | 261 | ||
247 | // only repaint the area that *really* needs to be repainted | 262 | // only repaint the area that *really* needs to be repainted |
248 | 263 | ||
249 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 264 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
250 | } | 265 | } |
251 | 266 | ||
252 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 267 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
253 | { | 268 | { |
254 | QSize s = size ( ); | 269 | emit videoResized( videoSize() ); |
255 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | ||
256 | |||
257 | // if we are in fullscreen mode, do not rotate the video | ||
258 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
259 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | ||
260 | |||
261 | if ( fs && qt_screen-> isTransformed ( )) | ||
262 | s = qt_screen-> mapToDevice ( s ); | ||
263 | |||
264 | emit videoResized ( s ); | ||
265 | } | 270 | } |
266 | 271 | ||
267 | 272 | ||
268 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 273 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
269 | { | 274 | { |
270 | emit clicked(); | 275 | emit clicked(); |
271 | } | 276 | } |
272 | 277 | ||
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 33f1470..8b3a3ea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h | |||
@@ -1,74 +1,76 @@ | |||
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 Robert Griebl <sandman@handhelds.org> | 4 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 5 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
6 | =. | 6 | =. |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; Library General Public License for more | 21 | ..}^=.= = ; Library General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | 30 | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | 38 | ||
39 | class QImage; | 39 | class QImage; |
40 | 40 | ||
41 | 41 | ||
42 | class XineVideoWidget : public QWidget { | 42 | class XineVideoWidget : public QWidget { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | XineVideoWidget ( QWidget* parent, const char* name ); | 46 | XineVideoWidget ( QWidget* parent, const char* name ); |
47 | ~XineVideoWidget ( ); | 47 | ~XineVideoWidget ( ); |
48 | QImage *logo ( ) const; | 48 | QImage *logo ( ) const; |
49 | void setLogo ( QImage *image ); | 49 | void setLogo ( QImage *image ); |
50 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); | 50 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); |
51 | void clear ( ); | 51 | void clear ( ); |
52 | 52 | ||
53 | QSize videoSize() const; | ||
54 | |||
53 | protected: | 55 | protected: |
54 | void paintEvent( QPaintEvent *p ); | 56 | void paintEvent( QPaintEvent *p ); |
55 | void resizeEvent ( QResizeEvent *r ); | 57 | void resizeEvent ( QResizeEvent *r ); |
56 | 58 | ||
57 | void mouseReleaseEvent ( QMouseEvent *e ); | 59 | void mouseReleaseEvent ( QMouseEvent *e ); |
58 | 60 | ||
59 | signals: | 61 | signals: |
60 | void clicked ( ); | 62 | void clicked ( ); |
61 | void videoResized ( const QSize &s ); | 63 | void videoResized ( const QSize &s ); |
62 | 64 | ||
63 | private: | 65 | private: |
64 | QRect m_lastframe; | 66 | QRect m_lastframe; |
65 | QRect m_thisframe; | 67 | QRect m_thisframe; |
66 | 68 | ||
67 | uchar *m_buff; | 69 | uchar *m_buff; |
68 | int m_bytes_per_line_fb; | 70 | int m_bytes_per_line_fb; |
69 | int m_bytes_per_line_frame; | 71 | int m_bytes_per_line_frame; |
70 | int m_bytes_per_pixel; | 72 | int m_bytes_per_pixel; |
71 | QImage *m_logo; | 73 | QImage *m_logo; |
72 | int m_rotation; | 74 | mutable int m_rotation; |
73 | }; | 75 | }; |
74 | 76 | ||