author | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
commit | 657eeb18141838eeb0d18351a6755d7fa686f9d9 (patch) (unidiff) | |
tree | 049c19f776543aee296ce0cd3a1fde8c37ec374b | |
parent | bba0335bbea81519beafb7fec1979a0abbd8a7ea (diff) | |
download | opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.zip opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.gz opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.bz2 |
mediadetect no longer needed, also beginning of id3 etc tag info support along with some other small fixes
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 39 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 79 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 32 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 109 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 14 |
8 files changed, 229 insertions, 101 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 620c71f..a6fd334 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,599 +1,582 @@ | |||
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 | ..}^=.= = ; 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 <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qbutton.h> | 40 | #include <qbutton.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <stdio.h> | 46 | #include <stdio.h> |
47 | 47 | ||
48 | #include "audiowidget.h" | 48 | #include "audiowidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "playlistwidget.h" | 50 | #include "playlistwidget.h" |
51 | 51 | ||
52 | extern MediaPlayerState *mediaPlayerState; | 52 | extern MediaPlayerState *mediaPlayerState; |
53 | extern PlayListWidget *playList; | 53 | extern PlayListWidget *playList; |
54 | 54 | ||
55 | static const int xo = -2; // movable x offset | 55 | static const int xo = -2; // movable x offset |
56 | static const int yo = 22; // movable y offset | 56 | static const int yo = 22; // movable y offset |
57 | 57 | ||
58 | 58 | ||
59 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 59 | Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
60 | setFrameStyle( WinPanel | Sunken ); | 60 | setFrameStyle( WinPanel | Sunken ); |
61 | setText( "No Song" ); | 61 | //setText( "No Song" ); |
62 | } | 62 | } |
63 | 63 | ||
64 | Ticker::~Ticker() { | 64 | Ticker::~Ticker() { |
65 | } | 65 | } |
66 | 66 | ||
67 | void Ticker::setText( const QString& text ) { | 67 | void Ticker::setText( const QString& text ) { |
68 | pos = 0; // reset it everytime the text is changed | 68 | pos = 0; // reset it everytime the text is changed |
69 | scrollText = text; | 69 | scrollText = text; |
70 | pixelLen = fontMetrics().width( scrollText ); | 70 | pixelLen = fontMetrics().width( scrollText ); |
71 | killTimers(); | 71 | killTimers(); |
72 | if ( pixelLen > width() ) { | 72 | if ( pixelLen > width() ) { |
73 | startTimer( 50 ); | 73 | startTimer( 50 ); |
74 | } | 74 | } |
75 | update(); | 75 | update(); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | void Ticker::timerEvent( QTimerEvent * ) { | 79 | void Ticker::timerEvent( QTimerEvent * ) { |
80 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 80 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
81 | scroll( -1, 0, contentsRect() ); | 81 | scroll( -1, 0, contentsRect() ); |
82 | repaint( FALSE ); | 82 | repaint( FALSE ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void Ticker::drawContents( QPainter *p ) { | 85 | void Ticker::drawContents( QPainter *p ) { |
86 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 86 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
87 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 87 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
88 | } | 88 | } |
89 | QPixmap pm( width(), height() ); | 89 | QPixmap pm( width(), height() ); |
90 | pm.fill( colorGroup().base() ); | 90 | pm.fill( colorGroup().base() ); |
91 | QPainter pmp( &pm ); | 91 | QPainter pmp( &pm ); |
92 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { | 92 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { |
93 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 93 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
94 | } | 94 | } |
95 | p->drawPixmap( 0, 0, pm ); | 95 | p->drawPixmap( 0, 0, pm ); |
96 | } | 96 | } |
97 | 97 | ||
98 | struct MediaButton { | 98 | struct MediaButton { |
99 | bool isToggle, isHeld, isDown; | 99 | bool isToggle, isHeld, isDown; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | //Layout information for the audioButtons (and if it is a toggle button or not) | 102 | //Layout information for the audioButtons (and if it is a toggle button or not) |
103 | MediaButton audioButtons[] = { | 103 | MediaButton audioButtons[] = { |
104 | { TRUE, FALSE, FALSE }, // play | 104 | { TRUE, FALSE, FALSE }, // play |
105 | { FALSE, FALSE, FALSE }, // stop | 105 | { FALSE, FALSE, FALSE }, // stop |
106 | { FALSE, FALSE, FALSE }, // next | 106 | { FALSE, FALSE, FALSE }, // next |
107 | { FALSE, FALSE, FALSE }, // previous | 107 | { FALSE, FALSE, FALSE }, // previous |
108 | { FALSE, FALSE, FALSE }, // volume up | 108 | { FALSE, FALSE, FALSE }, // volume up |
109 | { FALSE, FALSE, FALSE }, // volume down | 109 | { FALSE, FALSE, FALSE }, // volume down |
110 | { TRUE, FALSE, FALSE }, // repeat/loop | 110 | { TRUE, FALSE, FALSE }, // repeat/loop |
111 | { FALSE, FALSE, FALSE }, // playlist | 111 | { FALSE, FALSE, FALSE }, // playlist |
112 | { FALSE, FALSE, FALSE }, // forward | 112 | { FALSE, FALSE, FALSE }, // forward |
113 | { FALSE, FALSE, FALSE } // back | 113 | { FALSE, FALSE, FALSE } // back |
114 | }; | 114 | }; |
115 | 115 | ||
116 | const char *skin_mask_file_names[10] = { | 116 | const char *skin_mask_file_names[10] = { |
117 | "play", "stop", "next", "prev", "up", | 117 | "play", "stop", "next", "prev", "up", |
118 | "down", "loop", "playlist", "forward", "back" | 118 | "down", "loop", "playlist", "forward", "back" |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | static void changeTextColor( QWidget *w ) { | 122 | static void changeTextColor( QWidget *w ) { |
123 | QPalette p = w->palette(); | 123 | QPalette p = w->palette(); |
124 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 124 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
125 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 125 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
126 | w->setPalette( p ); | 126 | w->setPalette( p ); |
127 | } | 127 | } |
128 | 128 | ||
129 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 129 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
130 | 130 | ||
131 | 131 | ||
132 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 132 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
133 | 133 | ||
134 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 134 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
135 | 135 | ||
136 | setCaption( tr("OpiePlayer") ); | 136 | setCaption( tr("OpiePlayer") ); |
137 | 137 | ||
138 | Config cfg("OpiePlayer"); | 138 | Config cfg("OpiePlayer"); |
139 | cfg.setGroup("Options"); | 139 | cfg.setGroup("Options"); |
140 | skin = cfg.readEntry("Skin","default"); | 140 | skin = cfg.readEntry("Skin","default"); |
141 | //skin = "scaleTest"; | 141 | //skin = "scaleTest"; |
142 | // color of background, frame, degree of transparency | 142 | // color of background, frame, degree of transparency |
143 | 143 | ||
144 | QString skinPath = "opieplayer2/skins/" + skin; | 144 | QString skinPath = "opieplayer2/skins/" + skin; |
145 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 145 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
146 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 146 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
147 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 147 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
148 | 148 | ||
149 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 149 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
150 | imgButtonMask->fill( 0 ); | 150 | imgButtonMask->fill( 0 ); |
151 | 151 | ||
152 | for ( int i = 0; i < 10; i++ ) { | 152 | for ( int i = 0; i < 10; i++ ) { |
153 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 153 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
154 | masks[i] = new QBitmap( filename ); | 154 | masks[i] = new QBitmap( filename ); |
155 | 155 | ||
156 | if ( !masks[i]->isNull() ) { | 156 | if ( !masks[i]->isNull() ) { |
157 | QImage imgMask = masks[i]->convertToImage(); | 157 | QImage imgMask = masks[i]->convertToImage(); |
158 | uchar **dest = imgButtonMask->jumpTable(); | 158 | uchar **dest = imgButtonMask->jumpTable(); |
159 | for ( int y = 0; y < imgUp->height(); y++ ) { | 159 | for ( int y = 0; y < imgUp->height(); y++ ) { |
160 | uchar *line = dest[y]; | 160 | uchar *line = dest[y]; |
161 | for ( int x = 0; x < imgUp->width(); x++ ) | 161 | for ( int x = 0; x < imgUp->width(); x++ ) |
162 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 162 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
163 | line[x] = i + 1; | 163 | line[x] = i + 1; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | for ( int i = 0; i < 10; i++ ) { | 169 | for ( int i = 0; i < 10; i++ ) { |
170 | buttonPixUp[i] = 0l; | 170 | buttonPixUp[i] = 0l; |
171 | buttonPixDown[i] = 0l; | 171 | buttonPixDown[i] = 0l; |
172 | } | 172 | } |
173 | 173 | ||
174 | setBackgroundPixmap( *pixBg ); | 174 | setBackgroundPixmap( *pixBg ); |
175 | 175 | ||
176 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 176 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
177 | changeTextColor( &songInfo ); | 177 | changeTextColor( &songInfo ); |
178 | 178 | ||
179 | slider.setFixedHeight( 20 ); | 179 | slider.setFixedHeight( 20 ); |
180 | slider.setMinValue( 0 ); | 180 | slider.setMinValue( 0 ); |
181 | slider.setMaxValue( 1 ); | 181 | slider.setMaxValue( 1 ); |
182 | slider.setFocusPolicy( QWidget::NoFocus ); | 182 | slider.setFocusPolicy( QWidget::NoFocus ); |
183 | slider.setBackgroundPixmap( *pixBg ); | 183 | slider.setBackgroundPixmap( *pixBg ); |
184 | 184 | ||
185 | time.setFocusPolicy( QWidget::NoFocus ); | 185 | time.setFocusPolicy( QWidget::NoFocus ); |
186 | time.setAlignment( Qt::AlignCenter ); | 186 | time.setAlignment( Qt::AlignCenter ); |
187 | time.setFrame(FALSE); | 187 | time.setFrame(FALSE); |
188 | changeTextColor( &time ); | 188 | changeTextColor( &time ); |
189 | 189 | ||
190 | resizeEvent( NULL ); | 190 | resizeEvent( NULL ); |
191 | 191 | ||
192 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 192 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
193 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 193 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
194 | 194 | ||
195 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 195 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
196 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 196 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
197 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 197 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
198 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 198 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
199 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 199 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
200 | 200 | ||
201 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 201 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
202 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 202 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
203 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 203 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
204 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 204 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
205 | 205 | ||
206 | 206 | ||
207 | 207 | ||
208 | // Intialise state | 208 | // Intialise state |
209 | setLength( mediaPlayerState->length() ); | 209 | setLength( mediaPlayerState->length() ); |
210 | setPosition( mediaPlayerState->position() ); | 210 | setPosition( mediaPlayerState->position() ); |
211 | setLooping( mediaPlayerState->fullscreen() ); | 211 | setLooping( mediaPlayerState->fullscreen() ); |
212 | // setPaused( mediaPlayerState->paused() ); | 212 | // setPaused( mediaPlayerState->paused() ); |
213 | setPlaying( mediaPlayerState->playing() ); | 213 | setPlaying( mediaPlayerState->playing() ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | AudioWidget::~AudioWidget() { | 217 | AudioWidget::~AudioWidget() { |
218 | 218 | ||
219 | for ( int i = 0; i < 10; i++ ) { | 219 | for ( int i = 0; i < 10; i++ ) { |
220 | delete buttonPixUp[i]; | 220 | delete buttonPixUp[i]; |
221 | delete buttonPixDown[i]; | 221 | delete buttonPixDown[i]; |
222 | } | 222 | } |
223 | delete pixBg; | 223 | delete pixBg; |
224 | delete imgUp; | 224 | delete imgUp; |
225 | delete imgDn; | 225 | delete imgDn; |
226 | delete imgButtonMask; | 226 | delete imgButtonMask; |
227 | for ( int i = 0; i < 10; i++ ) { | 227 | for ( int i = 0; i < 10; i++ ) { |
228 | delete masks[i]; | 228 | delete masks[i]; |
229 | } | 229 | } |
230 | // mediaPlayerState->setPlaying(false); | 230 | // mediaPlayerState->setPlaying(false); |
231 | } | 231 | } |
232 | 232 | ||
233 | namespace { | 233 | namespace { |
234 | 234 | ||
235 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 235 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
236 | QPixmap pix( img.width(), img.height() ); | 236 | QPixmap pix( img.width(), img.height() ); |
237 | QPainter p( &pix ); | 237 | QPainter p( &pix ); |
238 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 238 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
239 | p.drawImage( 0, 0, img ); | 239 | p.drawImage( 0, 0, img ); |
240 | return new QPixmap( pix ); | 240 | return new QPixmap( pix ); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 244 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
245 | QPixmap *pixmap = new QPixmap( pix ); | 245 | QPixmap *pixmap = new QPixmap( pix ); |
246 | pixmap->setMask( mask ); | 246 | pixmap->setMask( mask ); |
247 | return pixmap; | 247 | return pixmap; |
248 | } | 248 | } |
249 | 249 | ||
250 | }; | 250 | }; |
251 | 251 | ||
252 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 252 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
253 | int h = height(); | 253 | int h = height(); |
254 | int w = width(); | 254 | int w = width(); |
255 | 255 | ||
256 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 256 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
257 | slider.setFixedWidth( w - 110 ); | 257 | slider.setFixedWidth( w - 110 ); |
258 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 258 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
259 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 259 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
260 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 260 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
261 | 261 | ||
262 | xoff = ( w - imgUp->width() ) / 2; | 262 | xoff = ( w - imgUp->width() ) / 2; |
263 | yoff = (( h - imgUp->height() ) / 2) - 10; | 263 | yoff = (( h - imgUp->height() ) / 2) - 10; |
264 | QPoint p( xoff, yoff ); | 264 | QPoint p( xoff, yoff ); |
265 | 265 | ||
266 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); | 266 | QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); |
267 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); | 267 | QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); |
268 | 268 | ||
269 | for ( int i = 0; i < 10; i++ ) { | 269 | for ( int i = 0; i < 10; i++ ) { |
270 | if ( !masks[i]->isNull() ) { | 270 | if ( !masks[i]->isNull() ) { |
271 | delete buttonPixUp[i]; | 271 | delete buttonPixUp[i]; |
272 | delete buttonPixDown[i]; | 272 | delete buttonPixDown[i]; |
273 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); | 273 | buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); |
274 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); | 274 | buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | delete pixUp; | 278 | delete pixUp; |
279 | delete pixDn; | 279 | delete pixDn; |
280 | } | 280 | } |
281 | 281 | ||
282 | static bool audioSliderBeingMoved = FALSE; | 282 | static bool audioSliderBeingMoved = FALSE; |
283 | 283 | ||
284 | 284 | ||
285 | void AudioWidget::sliderPressed() { | 285 | void AudioWidget::sliderPressed() { |
286 | audioSliderBeingMoved = TRUE; | 286 | audioSliderBeingMoved = TRUE; |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | void AudioWidget::sliderReleased() { | 290 | void AudioWidget::sliderReleased() { |
291 | audioSliderBeingMoved = FALSE; | 291 | audioSliderBeingMoved = FALSE; |
292 | if ( slider.width() == 0 ) | 292 | if ( slider.width() == 0 ) |
293 | return; | 293 | return; |
294 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 294 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
295 | mediaPlayerState->setPosition( val ); | 295 | mediaPlayerState->setPosition( val ); |
296 | } | 296 | } |
297 | 297 | ||
298 | void AudioWidget::setPosition( long i ) { | 298 | void AudioWidget::setPosition( long i ) { |
299 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 299 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
300 | updateSlider( i, mediaPlayerState->length() ); | 300 | updateSlider( i, mediaPlayerState->length() ); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void AudioWidget::setLength( long max ) { | 304 | void AudioWidget::setLength( long max ) { |
305 | updateSlider( mediaPlayerState->position(), max ); | 305 | updateSlider( mediaPlayerState->position(), max ); |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void AudioWidget::setView( char view ) { | 309 | void AudioWidget::setView( char view ) { |
310 | 310 | ||
311 | // this isnt working for some reason | 311 | // this isnt working for some reason |
312 | 312 | ||
313 | if ( mediaPlayerState->streaming() ) { | 313 | if ( mediaPlayerState->streaming() ) { |
314 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 314 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
315 | if( !slider.isHidden()) { | 315 | if( !slider.isHidden()) { |
316 | slider.hide(); | 316 | slider.hide(); |
317 | } | 317 | } |
318 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 318 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
319 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 319 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
320 | } else { | 320 | } else { |
321 | // this stops the slider from being moved, thus | 321 | // this stops the slider from being moved, thus |
322 | // does not stop stream when it reaches the end | 322 | // does not stop stream when it reaches the end |
323 | slider.show(); | 323 | slider.show(); |
324 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 324 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
325 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 325 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
326 | } | 326 | } |
327 | 327 | ||
328 | if ( view == 'a' ) { | 328 | if ( view == 'a' ) { |
329 | // startTimer( 150 ); | 329 | // startTimer( 150 ); |
330 | showMaximized(); | 330 | showMaximized(); |
331 | } else { | 331 | } else { |
332 | killTimers(); | 332 | killTimers(); |
333 | hide(); | 333 | hide(); |
334 | } | 334 | } |
335 | // qApp->processEvents(); | 335 | // qApp->processEvents(); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | static QString timeAsString( long length ) { | 339 | static QString timeAsString( long length ) { |
340 | int minutes = length / 60; | 340 | int minutes = length / 60; |
341 | int seconds = length % 60; | 341 | int seconds = length % 60; |
342 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 342 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
343 | } | 343 | } |
344 | 344 | ||
345 | void AudioWidget::updateSlider( long i, long max ) { | 345 | void AudioWidget::updateSlider( long i, long max ) { |
346 | 346 | ||
347 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 347 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
348 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 348 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
349 | 349 | ||
350 | if ( max == 0 ) { | 350 | if ( max == 0 ) { |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | // Will flicker too much if we don't do this | 353 | // Will flicker too much if we don't do this |
354 | // Scale to something reasonable | 354 | // Scale to something reasonable |
355 | int width = slider.width(); | 355 | int width = slider.width(); |
356 | int val = int((double)i * width / max); | 356 | int val = int((double)i * width / max); |
357 | if ( !audioSliderBeingMoved ) { | 357 | if ( !audioSliderBeingMoved ) { |
358 | if ( slider.value() != val ) { | 358 | if ( slider.value() != val ) { |
359 | slider.setValue( val ); | 359 | slider.setValue( val ); |
360 | } | 360 | } |
361 | 361 | ||
362 | if ( slider.maxValue() != width ) { | 362 | if ( slider.maxValue() != width ) { |
363 | slider.setMaxValue( width ); | 363 | slider.setMaxValue( width ); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void AudioWidget::setToggleButton( int i, bool down ) { | 369 | void AudioWidget::setToggleButton( int i, bool down ) { |
370 | qDebug("setToggleButton %d", i); | 370 | qDebug("setToggleButton %d", i); |
371 | if ( down != audioButtons[i].isDown ) { | 371 | if ( down != audioButtons[i].isDown ) { |
372 | toggleButton( i ); | 372 | toggleButton( i ); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | void AudioWidget::toggleButton( int i ) { | 377 | void AudioWidget::toggleButton( int i ) { |
378 | audioButtons[i].isDown = !audioButtons[i].isDown; | 378 | audioButtons[i].isDown = !audioButtons[i].isDown; |
379 | QPainter p(this); | 379 | QPainter p(this); |
380 | paintButton ( &p, i ); | 380 | paintButton ( &p, i ); |
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | void AudioWidget::paintButton( QPainter *p, int i ) { | 384 | void AudioWidget::paintButton( QPainter *p, int i ) { |
385 | if ( audioButtons[i].isDown ) { | 385 | if ( audioButtons[i].isDown ) { |
386 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 386 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
387 | } else { | 387 | } else { |
388 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 388 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | 392 | ||
393 | void AudioWidget::skipFor() { | 393 | void AudioWidget::skipFor() { |
394 | skipDirection = +1; | 394 | skipDirection = +1; |
395 | startTimer( 50 ); | 395 | startTimer( 50 ); |
396 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 396 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void AudioWidget::skipBack() { | 399 | void AudioWidget::skipBack() { |
400 | skipDirection = -1; | 400 | skipDirection = -1; |
401 | startTimer( 50 ); | 401 | startTimer( 50 ); |
402 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 402 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | 406 | ||
407 | void AudioWidget::stopSkip() { | 407 | void AudioWidget::stopSkip() { |
408 | killTimers(); | 408 | killTimers(); |
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | void AudioWidget::timerEvent( QTimerEvent * ) { | 412 | void AudioWidget::timerEvent( QTimerEvent * ) { |
413 | if ( skipDirection == +1 ) { | 413 | if ( skipDirection == +1 ) { |
414 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 414 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
415 | } else if ( skipDirection == -1 ) { | 415 | } else if ( skipDirection == -1 ) { |
416 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 416 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 421 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
422 | for ( int i = 0; i < numButtons; i++ ) { | 422 | for ( int i = 0; i < numButtons; i++ ) { |
423 | if ( event->state() == QMouseEvent::LeftButton ) { | 423 | if ( event->state() == QMouseEvent::LeftButton ) { |
424 | // The test to see if the mouse click is inside the button or not | 424 | // The test to see if the mouse click is inside the button or not |
425 | int x = event->pos().x() - xoff; | 425 | int x = event->pos().x() - xoff; |
426 | int y = event->pos().y() - yoff; | 426 | int y = event->pos().y() - yoff; |
427 | 427 | ||
428 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 428 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
429 | && y < imgButtonMask->height() | 429 | && y < imgButtonMask->height() |
430 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 430 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
431 | 431 | ||
432 | if ( isOnButton && !audioButtons[i].isHeld ) { | 432 | if ( isOnButton && !audioButtons[i].isHeld ) { |
433 | audioButtons[i].isHeld = TRUE; | 433 | audioButtons[i].isHeld = TRUE; |
434 | toggleButton(i); | 434 | toggleButton(i); |
435 | switch (i) { | 435 | switch (i) { |
436 | case AudioVolumeUp: | 436 | case AudioVolumeUp: |
437 | emit moreClicked(); | 437 | emit moreClicked(); |
438 | return; | 438 | return; |
439 | case AudioVolumeDown: | 439 | case AudioVolumeDown: |
440 | emit lessClicked(); | 440 | emit lessClicked(); |
441 | return; | 441 | return; |
442 | case AudioForward: | 442 | case AudioForward: |
443 | emit forwardClicked(); | 443 | emit forwardClicked(); |
444 | return; | 444 | return; |
445 | case AudioBack: | 445 | case AudioBack: |
446 | emit backClicked(); | 446 | emit backClicked(); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 449 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
450 | audioButtons[i].isHeld = FALSE; | 450 | audioButtons[i].isHeld = FALSE; |
451 | toggleButton(i); | 451 | toggleButton(i); |
452 | } | 452 | } |
453 | } else { | 453 | } else { |
454 | if ( audioButtons[i].isHeld ) { | 454 | if ( audioButtons[i].isHeld ) { |
455 | audioButtons[i].isHeld = FALSE; | 455 | audioButtons[i].isHeld = FALSE; |
456 | if ( !audioButtons[i].isToggle ) { | 456 | if ( !audioButtons[i].isToggle ) { |
457 | setToggleButton( i, FALSE ); | 457 | setToggleButton( i, FALSE ); |
458 | } | 458 | } |
459 | qDebug("mouseEvent %d", i); | 459 | qDebug("mouseEvent %d", i); |
460 | switch (i) { | 460 | switch (i) { |
461 | case AudioPlay: | 461 | case AudioPlay: |
462 | if( mediaPlayerState->isPaused ) { | 462 | if( mediaPlayerState->isPaused ) { |
463 | // setToggleButton( i, FALSE ); | ||
464 | mediaPlayerState->setPaused( FALSE ); | 463 | mediaPlayerState->setPaused( FALSE ); |
465 | return; | 464 | return; |
466 | } else if( !mediaPlayerState->isPaused ) { | 465 | } else if( !mediaPlayerState->isPaused ) { |
467 | // setToggleButton( i, TRUE ); | ||
468 | mediaPlayerState->setPaused( TRUE ); | 466 | mediaPlayerState->setPaused( TRUE ); |
469 | return; | 467 | return; |
470 | } else { | ||
471 | // setToggleButton( i, TRUE ); | ||
472 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
473 | } | 468 | } |
474 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 469 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
475 | case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; | 470 | case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return; |
476 | case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; | 471 | case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return; |
477 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 472 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
478 | case AudioVolumeUp: emit moreReleased(); return; | 473 | case AudioVolumeUp: emit moreReleased(); return; |
479 | case AudioVolumeDown: emit lessReleased(); return; | 474 | case AudioVolumeDown: emit lessReleased(); return; |
480 | case AudioPlayList: mediaPlayerState->setList(); return; | 475 | case AudioPlayList: mediaPlayerState->setList(); return; |
481 | case AudioForward: emit forwardReleased(); return; | 476 | case AudioForward: emit forwardReleased(); return; |
482 | case AudioBack: emit backReleased(); return; | 477 | case AudioBack: emit backReleased(); return; |
483 | } | 478 | } |
484 | } | 479 | } |
485 | } | 480 | } |
486 | } | 481 | } |
487 | } | 482 | } |
488 | 483 | ||
489 | 484 | ||
490 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 485 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
491 | mouseMoveEvent( event ); | 486 | mouseMoveEvent( event ); |
492 | } | 487 | } |
493 | 488 | ||
494 | 489 | ||
495 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 490 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
496 | mouseMoveEvent( event ); | 491 | mouseMoveEvent( event ); |
497 | } | 492 | } |
498 | 493 | ||
499 | 494 | ||
500 | void AudioWidget::showEvent( QShowEvent* ) { | 495 | void AudioWidget::showEvent( QShowEvent* ) { |
501 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 496 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
502 | mouseMoveEvent( &event ); | 497 | mouseMoveEvent( &event ); |
503 | } | 498 | } |
504 | 499 | ||
505 | 500 | ||
506 | void AudioWidget::closeEvent( QCloseEvent* ) { | 501 | void AudioWidget::closeEvent( QCloseEvent* ) { |
507 | mediaPlayerState->setList(); | 502 | mediaPlayerState->setList(); |
508 | } | 503 | } |
509 | 504 | ||
510 | 505 | ||
511 | void AudioWidget::paintEvent( QPaintEvent * pe) { | 506 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
512 | if ( !pe->erased() ) { | 507 | if ( !pe->erased() ) { |
513 | // Combine with background and double buffer | 508 | // Combine with background and double buffer |
514 | QPixmap pix( pe->rect().size() ); | 509 | QPixmap pix( pe->rect().size() ); |
515 | QPainter p( &pix ); | 510 | QPainter p( &pix ); |
516 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 511 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
517 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 512 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
518 | for ( int i = 0; i < numButtons; i++ ) | 513 | for ( int i = 0; i < numButtons; i++ ) |
519 | paintButton( &p, i ); | 514 | paintButton( &p, i ); |
520 | QPainter p2( this ); | 515 | QPainter p2( this ); |
521 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 516 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
522 | } else { | 517 | } else { |
523 | QPainter p( this ); | 518 | QPainter p( this ); |
524 | for ( int i = 0; i < numButtons; i++ ) | 519 | for ( int i = 0; i < numButtons; i++ ) |
525 | paintButton( &p, i ); | 520 | paintButton( &p, i ); |
526 | } | 521 | } |
527 | } | 522 | } |
528 | 523 | ||
529 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 524 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
530 | switch ( e->key() ) { | 525 | switch ( e->key() ) { |
531 | ////////////////////////////// Zaurus keys | 526 | ////////////////////////////// Zaurus keys |
532 | case Key_Home: | 527 | case Key_Home: |
533 | break; | 528 | break; |
534 | case Key_F9: //activity | 529 | case Key_F9: //activity |
535 | hide(); | 530 | hide(); |
536 | // qDebug("Audio F9"); | 531 | // qDebug("Audio F9"); |
537 | break; | 532 | break; |
538 | case Key_F10: //contacts | 533 | case Key_F10: //contacts |
539 | break; | 534 | break; |
540 | case Key_F11: //menu | 535 | case Key_F11: //menu |
541 | mediaPlayerState->toggleBlank(); | 536 | mediaPlayerState->toggleBlank(); |
542 | break; | 537 | break; |
543 | case Key_F12: //home | 538 | case Key_F12: //home |
544 | break; | 539 | break; |
545 | case Key_F13: //mail | 540 | case Key_F13: //mail |
546 | mediaPlayerState->toggleBlank(); | 541 | mediaPlayerState->toggleBlank(); |
547 | break; | 542 | break; |
548 | case Key_Space: { | 543 | case Key_Space: { |
549 | if(mediaPlayerState->playing()) { | 544 | if(mediaPlayerState->playing()) { |
550 | // toggleButton(1); | 545 | // toggleButton(1); |
551 | mediaPlayerState->setPlaying(FALSE); | 546 | mediaPlayerState->setPlaying(FALSE); |
552 | // toggleButton(1); | 547 | // toggleButton(1); |
553 | } else { | 548 | } else { |
554 | // toggleButton(0); | 549 | // toggleButton(0); |
555 | mediaPlayerState->setPlaying(TRUE); | 550 | mediaPlayerState->setPlaying(TRUE); |
556 | // toggleButton(0); | 551 | // toggleButton(0); |
557 | } | 552 | } |
558 | } | 553 | } |
559 | break; | 554 | break; |
560 | case Key_Down: | 555 | case Key_Down: |
561 | // toggleButton(6); | 556 | // toggleButton(6); |
562 | emit lessClicked(); | 557 | emit lessClicked(); |
563 | emit lessReleased(); | 558 | emit lessReleased(); |
564 | // toggleButton(6); | 559 | // toggleButton(6); |
565 | break; | 560 | break; |
566 | case Key_Up: | 561 | case Key_Up: |
567 | // toggleButton(5); | 562 | // toggleButton(5); |
568 | emit moreClicked(); | 563 | emit moreClicked(); |
569 | emit moreReleased(); | 564 | emit moreReleased(); |
570 | // toggleButton(5); | 565 | // toggleButton(5); |
571 | break; | 566 | break; |
572 | case Key_Right: | 567 | case Key_Right: |
573 | // toggleButton(3); | 568 | // toggleButton(3); |
574 | mediaPlayerState->setNext(); | 569 | mediaPlayerState->setNext(); |
575 | // toggleButton(3); | 570 | // toggleButton(3); |
576 | break; | 571 | break; |
577 | case Key_Left: | 572 | case Key_Left: |
578 | // toggleButton(4); | 573 | // toggleButton(4); |
579 | mediaPlayerState->setPrev(); | 574 | mediaPlayerState->setPrev(); |
580 | // toggleButton(4); | 575 | // toggleButton(4); |
581 | break; | 576 | break; |
582 | case Key_Escape: { | 577 | case Key_Escape: { |
583 | /* | ||
584 | * author pleas tell me where the i come from .-) | ||
585 | #if defined(QT_QWS_IPAQ) | ||
586 | if( mediaPlayerState->isPaused ) { | ||
587 | setToggleButton( i, FALSE ); | ||
588 | mediaPlayerState->setPaused( FALSE ); | ||
589 | } else if( !mediaPlayerState->isPaused ) { | ||
590 | setToggleButton( i, TRUE ); | ||
591 | mediaPlayerState->setPaused( TRUE ); | ||
592 | } | ||
593 | #endif | ||
594 | */ | ||
595 | } | 578 | } |
596 | break; | 579 | break; |
597 | 580 | ||
598 | }; | 581 | }; |
599 | } | 582 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4021d4a..85030de 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,265 +1,284 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | 41 | ||
42 | #include <qgfx_qws.h> | 42 | #include <qgfx_qws.h> |
43 | #include <qdirectpainter_qws.h> | 43 | #include <qdirectpainter_qws.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
46 | #include "frame.h" | 46 | #include "frame.h" |
47 | #include "lib.h" | 47 | #include "lib.h" |
48 | 48 | ||
49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
50 | int width, int height,int bytes ); | 50 | int width, int height,int bytes ); |
51 | 51 | ||
52 | extern "C" { | 52 | extern "C" { |
53 | xine_vo_driver_t* init_video_out_plugin( xine_cfg_entry_t* conf, void* video); | 53 | xine_vo_driver_t* init_video_out_plugin( xine_cfg_entry_t* conf, void* video); |
54 | int null_is_showing_video( const xine_vo_driver_t* self ); | 54 | int null_is_showing_video( const xine_vo_driver_t* self ); |
55 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 55 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
56 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 56 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
57 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 57 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
58 | int null_is_scaling( const xine_vo_driver_t* self ); | 58 | int null_is_scaling( const xine_vo_driver_t* self ); |
59 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 59 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
60 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 60 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
61 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 61 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
62 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 62 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
63 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 63 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
64 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 64 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
65 | } | 65 | } |
66 | 66 | ||
67 | using namespace XINE; | 67 | using namespace XINE; |
68 | 68 | ||
69 | Lib::Lib( XineVideoWidget* widget ) { | 69 | Lib::Lib( XineVideoWidget* widget ) { |
70 | m_video = false; | 70 | m_video = false; |
71 | m_wid = widget; | 71 | m_wid = widget; |
72 | printf("Lib"); | 72 | printf("Lib"); |
73 | QCString str( getenv("HOME") ); | 73 | QCString str( getenv("HOME") ); |
74 | str += "/Settings/opiexine.cf"; | 74 | str += "/Settings/opiexine.cf"; |
75 | // get the configuration | 75 | // get the configuration |
76 | 76 | ||
77 | // not really OO, should be an extra class, later | 77 | // not really OO, should be an extra class, later |
78 | if ( !QFile(str).exists() ) { | 78 | if ( !QFile(str).exists() ) { |
79 | QFile f(str); | 79 | QFile f(str); |
80 | f.open(IO_WriteOnly); | 80 | f.open(IO_WriteOnly); |
81 | QTextStream ts( &f ); | 81 | QTextStream ts( &f ); |
82 | ts << "misc.memcpy_method:glibc\n"; | 82 | ts << "misc.memcpy_method:glibc\n"; |
83 | f.close(); | 83 | f.close(); |
84 | } | 84 | } |
85 | 85 | ||
86 | m_xine = xine_new( ); | 86 | m_xine = xine_new( ); |
87 | 87 | ||
88 | xine_config_load( m_xine, str.data() ); | 88 | xine_config_load( m_xine, str.data() ); |
89 | 89 | ||
90 | 90 | ||
91 | // allocate oss for sound | 91 | // allocate oss for sound |
92 | // and fb for framebuffer | 92 | // and fb for framebuffer |
93 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 93 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
94 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); | 94 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); |
95 | 95 | ||
96 | 96 | ||
97 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 97 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
98 | 98 | ||
99 | 99 | ||
100 | null_display_handler( m_videoOutput, xine_display_frame, this ); | 100 | null_display_handler( m_videoOutput, xine_display_frame, this ); |
101 | xine_init( m_xine, m_audioOutput, m_videoOutput ); | 101 | xine_init( m_xine, m_audioOutput, m_videoOutput ); |
102 | 102 | ||
103 | if (m_wid != 0 ) { | 103 | if (m_wid != 0 ) { |
104 | printf( "!0\n" ); | 104 | printf( "!0\n" ); |
105 | resize ( m_wid-> size ( ) ); | 105 | resize ( m_wid-> size ( ) ); |
106 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 106 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
107 | 107 | ||
108 | m_wid->repaint(); | 108 | m_wid->repaint(); |
109 | } | 109 | } |
110 | 110 | ||
111 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 111 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
112 | } | 112 | } |
113 | 113 | ||
114 | Lib::~Lib() { | 114 | Lib::~Lib() { |
115 | // free( m_config ); | 115 | // free( m_config ); |
116 | xine_remove_event_listener( m_xine, xine_event_handler ); | 116 | xine_remove_event_listener( m_xine, xine_event_handler ); |
117 | xine_exit( m_xine ); | 117 | xine_exit( m_xine ); |
118 | /* FIXME either free or delete but valgrind bitches against both */ | 118 | /* FIXME either free or delete but valgrind bitches against both */ |
119 | //free( m_videoOutput ); | 119 | //free( m_videoOutput ); |
120 | //delete m_audioOutput; | 120 | //delete m_audioOutput; |
121 | } | 121 | } |
122 | 122 | ||
123 | void Lib::resize ( const QSize &s ) { | 123 | void Lib::resize ( const QSize &s ) { |
124 | if ( s. width ( ) && s. height ( ) ) { | 124 | if ( s. width ( ) && s. height ( ) ) { |
125 | ::null_set_gui_width( m_videoOutput, s. width() ); | 125 | ::null_set_gui_width( m_videoOutput, s. width() ); |
126 | ::null_set_gui_height( m_videoOutput, s. height() ); | 126 | ::null_set_gui_height( m_videoOutput, s. height() ); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | QCString Lib::version() { | 130 | QCString Lib::version() { |
131 | // QCString str( xine_get_str_version() ); | 131 | // QCString str( xine_get_str_version() ); |
132 | // return str; | 132 | // return str; |
133 | return "test"; | 133 | return "test"; |
134 | } | 134 | } |
135 | 135 | ||
136 | int Lib::majorVersion() { | 136 | int Lib::majorVersion() { |
137 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 137 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
138 | return m_major_version; | 138 | return m_major_version; |
139 | } | 139 | } |
140 | 140 | ||
141 | int Lib::minorVersion() { | 141 | int Lib::minorVersion() { |
142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 142 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
143 | return m_minor_version; | 143 | return m_minor_version; |
144 | } | 144 | } |
145 | 145 | ||
146 | int Lib::subVersion() { | 146 | int Lib::subVersion() { |
147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); | 147 | xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); |
148 | return m_sub_version; | 148 | return m_sub_version; |
149 | } | 149 | } |
150 | 150 | ||
151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 151 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
152 | QString str = fileName.stripWhiteSpace(); | 152 | QString str = fileName.stripWhiteSpace(); |
153 | xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ); | 153 | if ( !xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ) ) { |
154 | return 0; | ||
155 | } | ||
154 | return xine_play( m_xine, startPos, start_time); | 156 | return xine_play( m_xine, startPos, start_time); |
155 | } | 157 | } |
156 | 158 | ||
157 | void Lib::stop() { | 159 | void Lib::stop() { |
158 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 160 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
159 | xine_stop( m_xine ); | 161 | xine_stop( m_xine ); |
160 | } | 162 | } |
161 | 163 | ||
162 | void Lib::pause() { | 164 | void Lib::pause() { |
163 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 165 | xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); |
164 | } | 166 | } |
165 | 167 | ||
166 | int Lib::speed() { | 168 | int Lib::speed() { |
167 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); | 169 | return xine_get_param ( m_xine, XINE_PARAM_SPEED ); |
168 | } | 170 | } |
169 | 171 | ||
170 | void Lib::setSpeed( int speed ) { | 172 | void Lib::setSpeed( int speed ) { |
171 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); | 173 | xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); |
172 | } | 174 | } |
173 | 175 | ||
174 | int Lib::status() { | 176 | int Lib::status() { |
175 | return xine_get_status( m_xine ); | 177 | return xine_get_status( m_xine ); |
176 | } | 178 | } |
177 | 179 | ||
178 | int Lib::currentPosition() { | 180 | int Lib::currentPosition() { |
179 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 181 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
180 | return m_pos; | 182 | return m_pos; |
181 | } | 183 | } |
182 | 184 | ||
183 | int Lib::currentTime() { | 185 | int Lib::currentTime() { |
184 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 186 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
185 | return m_time/1000; | 187 | return m_time/1000; |
186 | } | 188 | } |
187 | 189 | ||
188 | int Lib::length() { | 190 | int Lib::length() { |
189 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); | 191 | xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); |
190 | return m_length/1000; | 192 | return m_length/1000; |
191 | } | 193 | } |
192 | 194 | ||
193 | bool Lib::isSeekable() { | 195 | bool Lib::isSeekable() { |
194 | return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE ); | 196 | return xine_get_stream_info( m_xine, XINE_STREAM_INFO_SEEKABLE ); |
197 | } | ||
198 | |||
199 | void Lib::seekTo( int time ) { | ||
200 | // xine_trick_mode ( m_xine, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | ||
201 | xine_play( m_xine, 0, time ); | ||
195 | } | 202 | } |
196 | 203 | ||
204 | |||
197 | Frame Lib::currentFrame() { | 205 | Frame Lib::currentFrame() { |
198 | Frame frame; | 206 | Frame frame; |
199 | return frame; | 207 | return frame; |
200 | }; | 208 | }; |
201 | 209 | ||
202 | QString Lib::metaInfo() { | 210 | QString Lib::metaInfo( int number) { |
203 | xine_get_meta_info( m_xine, 0 ); | 211 | return xine_get_meta_info( m_xine, number ); |
204 | } | 212 | } |
205 | 213 | ||
206 | int Lib::error() { | 214 | int Lib::error() { |
207 | return xine_get_error( m_xine ); | 215 | return xine_get_error( m_xine ); |
208 | }; | 216 | }; |
209 | 217 | ||
210 | void Lib::handleXineEvent( xine_event_t* t ) { | 218 | void Lib::handleXineEvent( xine_event_t* t ) { |
211 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { | 219 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { |
212 | emit stopped(); | 220 | emit stopped(); |
213 | } | 221 | } |
214 | } | 222 | } |
215 | 223 | ||
216 | 224 | ||
217 | void Lib::setShowVideo( bool video ) { | 225 | void Lib::setShowVideo( bool video ) { |
218 | m_video = video; | 226 | m_video = video; |
219 | ::null_set_show_video( m_videoOutput, video ); | 227 | ::null_set_show_video( m_videoOutput, video ); |
220 | } | 228 | } |
221 | 229 | ||
222 | bool Lib::isShowingVideo() { | 230 | bool Lib::isShowingVideo() { |
223 | return ::null_is_showing_video( m_videoOutput ); | 231 | return ::null_is_showing_video( m_videoOutput ); |
224 | } | 232 | } |
225 | 233 | ||
234 | bool Lib::hasVideo() { | ||
235 | //looks like it is not implemented yet | ||
236 | //return xine_get_stream_info( m_xine, XINE_STREAM_INFO_VIDEO_CHANNELS ); | ||
237 | // ugly hack until xine is ready, look for the width of the video | ||
238 | int test = xine_get_stream_info( m_xine, 2 ); | ||
239 | if( test > 0 ) { | ||
240 | // qDebug( QString(" has video: %1").arg( test ) ); | ||
241 | return true; | ||
242 | } else { | ||
243 | //qDebug ( "does not have video "); | ||
244 | return false; | ||
245 | } | ||
246 | } | ||
247 | |||
226 | void Lib::showVideoFullScreen( bool fullScreen ) { | 248 | void Lib::showVideoFullScreen( bool fullScreen ) { |
227 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 249 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
228 | } | 250 | } |
229 | 251 | ||
230 | bool Lib::isVideoFullScreen() { | 252 | bool Lib::isVideoFullScreen() { |
231 | return ::null_is_fullscreen( m_videoOutput ); | 253 | return ::null_is_fullscreen( m_videoOutput ); |
232 | } | 254 | } |
233 | 255 | ||
234 | void Lib::setScaling( bool scale ) { | 256 | void Lib::setScaling( bool scale ) { |
235 | ::null_set_scaling( m_videoOutput, scale ); | 257 | ::null_set_scaling( m_videoOutput, scale ); |
236 | } | 258 | } |
237 | 259 | ||
238 | void Lib::setGamma( int value ) { | 260 | void Lib::setGamma( int value ) { |
239 | //qDebug( QString( "%1").arg(value) ); | 261 | //qDebug( QString( "%1").arg(value) ); |
240 | ::null_set_videoGamma( m_videoOutput, value ); | 262 | ::null_set_videoGamma( m_videoOutput, value ); |
241 | } | 263 | } |
242 | 264 | ||
243 | bool Lib::isScaling() { | 265 | bool Lib::isScaling() { |
244 | return ::null_is_scaling( m_videoOutput ); | 266 | return ::null_is_scaling( m_videoOutput ); |
245 | } | 267 | } |
246 | 268 | ||
247 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 269 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
248 | ( (Lib*)user_data)->handleXineEvent( t ); | 270 | ( (Lib*)user_data)->handleXineEvent( t ); |
249 | } | 271 | } |
250 | 272 | ||
251 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 273 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
252 | int width, int height, int bytes ) { | 274 | int width, int height, int bytes ) { |
253 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 275 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
254 | } | 276 | } |
255 | 277 | ||
256 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 278 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
257 | if ( !m_video ) { | 279 | if ( !m_video ) { |
258 | qWarning("not showing video now"); | 280 | qWarning("not showing video now"); |
259 | return; | 281 | return; |
260 | } | 282 | } |
261 | |||
262 | // qWarning( "called draw frame %d %d", width, height ); | ||
263 | |||
264 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 283 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
265 | } | 284 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 29adc4d..6cdd9c6 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,173 +1,197 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef ZECKEXINELIB_H | 34 | #ifndef ZECKEXINELIB_H |
35 | #define ZECKEXINELIB_H | 35 | #define ZECKEXINELIB_H |
36 | 36 | ||
37 | #include <qcstring.h> | 37 | #include <qcstring.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <xine.h> | 41 | #include <xine.h> |
42 | //#include "xine.h" | 42 | //#include "xine.h" |
43 | 43 | ||
44 | class XineVideoWidget; | 44 | class XineVideoWidget; |
45 | 45 | ||
46 | namespace XINE { | 46 | namespace XINE { |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Lib wrapps the simple interface | 49 | * Lib wrapps the simple interface |
50 | * of libxine for easy every day use | 50 | * of libxine for easy every day use |
51 | * This will become a full C++ Wrapper | 51 | * This will become a full C++ Wrapper |
52 | * It supports playing, pausing, info, | 52 | * It supports playing, pausing, info, |
53 | * stooping, seeking. | 53 | * stooping, seeking. |
54 | */ | 54 | */ |
55 | class Frame; | 55 | class Frame; |
56 | class Lib : public QObject { | 56 | class Lib : public QObject { |
57 | Q_OBJECT | 57 | Q_OBJECT |
58 | public: | 58 | public: |
59 | Lib(XineVideoWidget* = 0); | 59 | Lib(XineVideoWidget* = 0); |
60 | ~Lib(); | 60 | ~Lib(); |
61 | QCString version(); | 61 | QCString version(); |
62 | int majorVersion()/*const*/; | 62 | int majorVersion()/*const*/; |
63 | int minorVersion()/*const*/; | 63 | int minorVersion()/*const*/; |
64 | int subVersion()/*const*/; | 64 | int subVersion()/*const*/; |
65 | 65 | ||
66 | 66 | ||
67 | void resize ( const QSize &s ); | 67 | void resize ( const QSize &s ); |
68 | 68 | ||
69 | int play( const QString& fileName, | 69 | int play( const QString& fileName, |
70 | int startPos = 0, | 70 | int startPos = 0, |
71 | int start_time = 0 ); | 71 | int start_time = 0 ); |
72 | void stop() /*const*/; | 72 | void stop() /*const*/; |
73 | void pause()/*const*/; | 73 | void pause()/*const*/; |
74 | 74 | ||
75 | int speed() /*const*/; | 75 | int speed() /*const*/; |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Set the speed of the stream, if codec supports it | 78 | * Set the speed of the stream, if codec supports it |
79 | * XINE_SPEED_PAUSE 0 | 79 | * XINE_SPEED_PAUSE 0 |
80 | * XINE_SPEED_SLOW_4 1 | 80 | * XINE_SPEED_SLOW_4 1 |
81 | * XINE_SPEED_SLOW_2 2 | 81 | * XINE_SPEED_SLOW_2 2 |
82 | * XINE_SPEED_NORMAL 4 | 82 | * XINE_SPEED_NORMAL 4 |
83 | * XINE_SPEED_FAST_2 8 | 83 | * XINE_SPEED_FAST_2 8 |
84 | *XINE_SPEED_FAST_4 16 | 84 | *XINE_SPEED_FAST_4 16 |
85 | */ | 85 | */ |
86 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | 86 | void setSpeed( int speed = XINE_SPEED_PAUSE ); |
87 | 87 | ||
88 | int status() /*const*/; | 88 | int status() /*const*/; |
89 | 89 | ||
90 | int currentPosition()/*const*/; | 90 | int currentPosition()/*const*/; |
91 | //in seconds | 91 | //in seconds |
92 | int currentTime()/*const*/; | 92 | int currentTime()/*const*/; |
93 | int length() /*const*/; | 93 | int length() /*const*/; |
94 | 94 | ||
95 | bool isSeekable()/*const*/; | 95 | bool isSeekable()/*const*/; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Whether or not to show video output | 98 | * Whether or not to show video output |
99 | */ | 99 | */ |
100 | void setShowVideo(bool video); | 100 | void setShowVideo(bool video); |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * is we show video | 103 | * is we show video |
104 | */ | 104 | */ |
105 | bool isShowingVideo() /*const*/; | 105 | bool isShowingVideo() /*const*/; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * | 108 | * |
109 | */ | 109 | */ |
110 | void showVideoFullScreen( bool fullScreen ); | 110 | void showVideoFullScreen( bool fullScreen ); |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * | 113 | * |
114 | */ | 114 | */ |
115 | bool isVideoFullScreen()/*const*/ ; | 115 | bool isVideoFullScreen()/*const*/ ; |
116 | 116 | ||
117 | 117 | ||
118 | /** | 118 | /** |
119 | * Get the meta info (like author etc) from the stream | 119 | * Get the meta info (like author etc) from the stream |
120 | * | 120 | * XINE_META_INFO_TITLE 0 |
121 | * XINE_META_INFO_COMMENT 1 | ||
122 | * XINE_META_INFO_ARTIST 2 | ||
123 | * XINE_META_INFO_GENRE 3 | ||
124 | * XINE_META_INFO_ALBUM 4 | ||
125 | * XINE_META_INFO_YEAR 5 | ||
126 | * XINE_META_INFO_VIDEOCODEC 6 | ||
127 | * XINE_META_INFO_AUDIOCODEC 7 | ||
128 | * XINE_META_INFO_SYSTEMLAYER 8 | ||
129 | * XINE_META_INFO_INPUT_PLUGIN 9 | ||
121 | */ | 130 | */ |
122 | QString metaInfo() ; | 131 | QString metaInfo( int number ); |
123 | 132 | ||
124 | /** | 133 | /** |
125 | * | 134 | * |
126 | */ | 135 | */ |
127 | bool isScaling(); | 136 | bool isScaling(); |
128 | 137 | ||
129 | /** | 138 | /** |
139 | * seek to a position | ||
140 | */ | ||
141 | void seekTo( int time ); | ||
142 | |||
143 | /** | ||
144 | * | ||
145 | * @return is media stream has video | ||
146 | */ | ||
147 | bool hasVideo(); | ||
148 | |||
149 | /** | ||
130 | * | 150 | * |
131 | */ | 151 | */ |
132 | void setScaling( bool ); | 152 | void setScaling( bool ); |
133 | 153 | ||
134 | /** | 154 | /** |
135 | * Set the Gamma value for video output | 155 | * Set the Gamma value for video output |
136 | * @param int the value between -100 and 100, 0 is original | 156 | * @param int the value between -100 and 100, 0 is original |
137 | */ | 157 | */ |
138 | void setGamma( int ); | 158 | void setGamma( int ); |
139 | 159 | ||
140 | /** | 160 | /** |
141 | * test | 161 | * test |
142 | */ | 162 | */ |
143 | Frame currentFrame()/*const*/; | 163 | Frame currentFrame()/*const*/; |
144 | 164 | ||
145 | /** | 165 | /** |
146 | * Returns the error code | 166 | * Returns the error code |
167 | * XINE_ERROR_NONE 0 | ||
168 | * XINE_ERROR_NO_INPUT_PLUGIN 1 | ||
169 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 | ||
170 | * XINE_ERROR_DEMUXER_FAILED 3 | ||
147 | */ | 171 | */ |
148 | int error() /*const*/; | 172 | int error() /*const*/; |
149 | 173 | ||
150 | signals: | 174 | signals: |
151 | void stopped(); | 175 | void stopped(); |
152 | private: | 176 | private: |
153 | int m_bytes_per_pixel; | 177 | int m_bytes_per_pixel; |
154 | int m_length, m_pos, m_time; | 178 | int m_length, m_pos, m_time; |
155 | int m_major_version, m_minor_version, m_sub_version; | 179 | int m_major_version, m_minor_version, m_sub_version; |
156 | bool m_video:1; | 180 | bool m_video:1; |
157 | XineVideoWidget *m_wid; | 181 | XineVideoWidget *m_wid; |
158 | xine_t *m_xine; | 182 | xine_t *m_xine; |
159 | xine_cfg_entry_t *m_config; | 183 | xine_cfg_entry_t *m_config; |
160 | xine_vo_driver_t *m_videoOutput; | 184 | xine_vo_driver_t *m_videoOutput; |
161 | xine_ao_driver_t* m_audioOutput; | 185 | xine_ao_driver_t* m_audioOutput; |
162 | 186 | ||
163 | void handleXineEvent( xine_event_t* t ); | 187 | void handleXineEvent( xine_event_t* t ); |
164 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 188 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
165 | // C -> C++ bridge for the event system | 189 | // C -> C++ bridge for the event system |
166 | static void xine_event_handler( void* user_data, xine_event_t* t); | 190 | static void xine_event_handler( void* user_data, xine_event_t* t); |
167 | static void xine_display_frame( void* user_data, uint8_t* frame , | 191 | static void xine_display_frame( void* user_data, uint8_t* frame , |
168 | int width, int height, int bytes ); | 192 | int width, int height, int bytes ); |
169 | }; | 193 | }; |
170 | }; | 194 | }; |
171 | 195 | ||
172 | 196 | ||
173 | #endif | 197 | #endif |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 553e3c1..8da7f73 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,333 +1,346 @@ | |||
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 | extern AudioWidget *audioUI; | 27 | extern AudioWidget *audioUI; |
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | extern MediaPlayerState *mediaPlayerState; | 30 | extern MediaPlayerState *mediaPlayerState; |
31 | 31 | ||
32 | 32 | ||
33 | #define FBIOBLANK 0x4611 | 33 | #define FBIOBLANK 0x4611 |
34 | 34 | ||
35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 35 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
36 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 36 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
37 | 37 | ||
38 | playList->setCaption(tr("OpiePlayer: Initializating")); | 38 | playList->setCaption(tr("OpiePlayer: Initializating")); |
39 | 39 | ||
40 | qApp->processEvents(); | 40 | qApp->processEvents(); |
41 | // QPEApplication::grabKeyboard(); // EVIL | 41 | // QPEApplication::grabKeyboard(); // EVIL |
42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
43 | 43 | ||
44 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 44 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
45 | 45 | ||
46 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
47 | 47 | ||
48 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 48 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
49 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 49 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
50 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
51 | 51 | ||
52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
53 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 53 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
54 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 54 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
55 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 55 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
56 | 56 | ||
57 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 57 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
58 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 58 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
59 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 59 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
60 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 60 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
61 | 61 | ||
62 | volControl = new VolumeControl; | 62 | volControl = new VolumeControl; |
63 | xineControl = new XineControl(); | 63 | xineControl = new XineControl(); |
64 | playList->setCaption(tr("OpiePlayer")); | 64 | playList->setCaption(tr("OpiePlayer")); |
65 | } | 65 | } |
66 | 66 | ||
67 | MediaPlayer::~MediaPlayer() { | 67 | MediaPlayer::~MediaPlayer() { |
68 | delete xineControl; | 68 | delete xineControl; |
69 | delete volControl; | 69 | delete volControl; |
70 | } | 70 | } |
71 | 71 | ||
72 | void MediaPlayer::pauseCheck( bool b ) { | 72 | void MediaPlayer::pauseCheck( bool b ) { |
73 | if ( b && !mediaPlayerState->playing() ) { | 73 | if ( b && !mediaPlayerState->playing() ) { |
74 | mediaPlayerState->setPaused( FALSE ); | 74 | mediaPlayerState->setPaused( FALSE ); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | void MediaPlayer::play() { | 78 | void MediaPlayer::play() { |
79 | mediaPlayerState->setPlaying( FALSE ); | 79 | mediaPlayerState->setPlaying( FALSE ); |
80 | mediaPlayerState->setPlaying( TRUE ); | 80 | mediaPlayerState->setPlaying( TRUE ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void MediaPlayer::setPlaying( bool play ) { | 83 | void MediaPlayer::setPlaying( bool play ) { |
84 | if ( !play ) { | 84 | if ( !play ) { |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | 87 | ||
88 | if ( mediaPlayerState->paused() ) { | 88 | if ( mediaPlayerState->paused() ) { |
89 | mediaPlayerState->setPaused( FALSE ); | 89 | mediaPlayerState->setPaused( FALSE ); |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | 92 | ||
93 | QString tickerText, time, fileName; | 93 | QString tickerText, time, fileName; |
94 | if( playList->whichList() == 0 ) { //check for filelist | 94 | if( playList->whichList() == 0 ) { //check for filelist |
95 | const DocLnk *playListCurrent = playList->current(); | 95 | const DocLnk *playListCurrent = playList->current(); |
96 | if ( playListCurrent != NULL ) { | 96 | if ( playListCurrent != NULL ) { |
97 | currentFile = playListCurrent; | 97 | currentFile = playListCurrent; |
98 | } | 98 | } |
99 | xineControl->play( currentFile->file() ); | 99 | xineControl->play( currentFile->file() ); |
100 | fileName = currentFile->name(); | 100 | fileName = currentFile->name(); |
101 | long seconds = mediaPlayerState->length();// | 101 | long seconds = mediaPlayerState->length();// |
102 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 102 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
103 | qDebug(time); | 103 | //qDebug(time); |
104 | 104 | ||
105 | } else { //if playing in file list.. play in a different way | 105 | } else { |
106 | // random and looping settings enabled causes problems here, | 106 | //if playing in file list.. play in a different way |
107 | // since there is no selected file in the playlist, but a selected file in the file list, | 107 | // random and looping settings enabled causes problems here, |
108 | // so we remember and shutoff | 108 | // since there is no selected file in the playlist, but a selected file in the file list, |
109 | // so we remember and shutoff | ||
109 | l = mediaPlayerState->looping(); | 110 | l = mediaPlayerState->looping(); |
110 | if(l) | 111 | if(l) { |
111 | mediaPlayerState->setLooping( false ); | 112 | mediaPlayerState->setLooping( false ); |
113 | } | ||
112 | r = mediaPlayerState->shuffled(); | 114 | r = mediaPlayerState->shuffled(); |
113 | mediaPlayerState->setShuffled(false); | 115 | mediaPlayerState->setShuffled( false ); |
114 | 116 | ||
115 | fileName = playList->currentFileListPathName(); | 117 | fileName = playList->currentFileListPathName(); |
116 | xineControl->play( fileName); | 118 | xineControl->play( fileName ); |
117 | long seconds = mediaPlayerState->length();// | 119 | long seconds = mediaPlayerState->length(); |
118 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 120 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
119 | qDebug(time); | 121 | //qDebug(time); |
120 | if( fileName.left(4) != "http" ) | 122 | if( fileName.left(4) != "http" ) { |
121 | fileName = QFileInfo( fileName).baseName(); | 123 | fileName = QFileInfo( fileName ).baseName(); |
124 | } | ||
122 | 125 | ||
123 | } | 126 | } |
124 | if( fileName.left(4) == "http" ) | 127 | |
125 | tickerText= tr( " File: " ) + fileName; | 128 | if( fileName.left(4) == "http" ) { |
126 | else | 129 | if ( xineControl->getMetaInfo().isEmpty() ) { |
127 | tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time; | 130 | tickerText = tr( " File: " ) + fileName; |
131 | } else { | ||
132 | tickerText = xineControl->getMetaInfo(); | ||
133 | } | ||
134 | } else { | ||
135 | if ( xineControl->getMetaInfo().isEmpty() ) { | ||
136 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | ||
137 | } else { | ||
138 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | ||
139 | } | ||
140 | } | ||
128 | audioUI->setTickerText( tickerText ); | 141 | audioUI->setTickerText( tickerText ); |
129 | } | 142 | } |
130 | 143 | ||
131 | 144 | ||
132 | void MediaPlayer::prev() { | 145 | void MediaPlayer::prev() { |
133 | if(playList->whichList() == 0) { //if using the playlist | 146 | if( playList->whichList() == 0 ) { //if using the playlist |
134 | if ( playList->prev() ) { | 147 | if ( playList->prev() ) { |
135 | play(); | 148 | play(); |
136 | } else if ( mediaPlayerState->looping() ) { | 149 | } else if ( mediaPlayerState->looping() ) { |
137 | if ( playList->last() ) { | 150 | if ( playList->last() ) { |
138 | play(); | 151 | play(); |
139 | } | 152 | } |
140 | } else { | 153 | } else { |
141 | mediaPlayerState->setList(); | 154 | mediaPlayerState->setList(); |
142 | } | 155 | } |
143 | } | 156 | } |
144 | } | 157 | } |
145 | 158 | ||
146 | 159 | ||
147 | void MediaPlayer::next() { | 160 | void MediaPlayer::next() { |
148 | 161 | ||
149 | if(playList->whichList() == 0) { //if using the playlist | 162 | if(playList->whichList() == 0) { //if using the playlist |
150 | if ( playList->next() ) { | 163 | if ( playList->next() ) { |
151 | play(); | 164 | play(); |
152 | } else if ( mediaPlayerState->looping() ) { | 165 | } else if ( mediaPlayerState->looping() ) { |
153 | if ( playList->first() ) { | 166 | if ( playList->first() ) { |
154 | play(); | 167 | play(); |
155 | } | 168 | } |
156 | } else { | 169 | } else { |
157 | mediaPlayerState->setList(); | 170 | mediaPlayerState->setList(); |
158 | } | 171 | } |
159 | } else { //if playing from file list, let's just stop | 172 | } else { //if playing from file list, let's just stop |
160 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 173 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
161 | mediaPlayerState->setPlaying(false); | 174 | mediaPlayerState->setPlaying(false); |
162 | mediaPlayerState->setView('l'); | 175 | mediaPlayerState->setView('l'); |
163 | if(l) mediaPlayerState->setLooping(l); | 176 | if(l) mediaPlayerState->setLooping(l); |
164 | if(r) mediaPlayerState->setShuffled(r); | 177 | if(r) mediaPlayerState->setShuffled(r); |
165 | } | 178 | } |
166 | qApp->processEvents(); | 179 | qApp->processEvents(); |
167 | } | 180 | } |
168 | 181 | ||
169 | 182 | ||
170 | void MediaPlayer::startDecreasingVolume() { | 183 | void MediaPlayer::startDecreasingVolume() { |
171 | volumeDirection = -1; | 184 | volumeDirection = -1; |
172 | startTimer( 100 ); | 185 | startTimer( 100 ); |
173 | volControl->decVol(2); | 186 | volControl->decVol(2); |
174 | } | 187 | } |
175 | 188 | ||
176 | 189 | ||
177 | void MediaPlayer::startIncreasingVolume() { | 190 | void MediaPlayer::startIncreasingVolume() { |
178 | volumeDirection = +1; | 191 | volumeDirection = +1; |
179 | startTimer( 100 ); | 192 | startTimer( 100 ); |
180 | volControl->incVol(2); | 193 | volControl->incVol(2); |
181 | } | 194 | } |
182 | 195 | ||
183 | 196 | ||
184 | bool drawnOnScreenDisplay = FALSE; | 197 | bool drawnOnScreenDisplay = FALSE; |
185 | unsigned int onScreenDisplayVolume = 0; | 198 | unsigned int onScreenDisplayVolume = 0; |
186 | const int yoff = 110; | 199 | const int yoff = 110; |
187 | 200 | ||
188 | void MediaPlayer::stopChangingVolume() { | 201 | void MediaPlayer::stopChangingVolume() { |
189 | killTimers(); | 202 | killTimers(); |
190 | // Get rid of the on-screen display stuff | 203 | // Get rid of the on-screen display stuff |
191 | drawnOnScreenDisplay = FALSE; | 204 | drawnOnScreenDisplay = FALSE; |
192 | onScreenDisplayVolume = 0; | 205 | onScreenDisplayVolume = 0; |
193 | int w=0; | 206 | int w=0; |
194 | int h=0; | 207 | int h=0; |
195 | if( !xineControl->hasVideo()) { | 208 | if( !xineControl->hasVideo() ) { |
196 | w = audioUI->width(); | 209 | w = audioUI->width(); |
197 | h = audioUI->height(); | 210 | h = audioUI->height(); |
198 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 211 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
199 | } else { | 212 | } else { |
200 | w = videoUI->width(); | 213 | w = videoUI->width(); |
201 | h = videoUI->height(); | 214 | h = videoUI->height(); |
202 | videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | 215 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
203 | } | 216 | } |
204 | } | 217 | } |
205 | 218 | ||
206 | 219 | ||
207 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 220 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
208 | if ( volumeDirection == +1 ) { | 221 | if ( volumeDirection == +1 ) { |
209 | volControl->incVol(2); | 222 | volControl->incVol( 2 ); |
210 | } else if ( volumeDirection == -1 ) { | 223 | } else if ( volumeDirection == -1 ) { |
211 | volControl->decVol(2); | 224 | volControl->decVol( 2 ); |
212 | } | 225 | } |
213 | 226 | ||
214 | 227 | ||
215 | // TODO FIXME | 228 | // TODO FIXME |
216 | // huh?? | 229 | // huh?? |
217 | unsigned int v= 0; | 230 | unsigned int v= 0; |
218 | v = volControl->volume(); | 231 | v = volControl->volume(); |
219 | v = v / 10; | 232 | v = v / 10; |
220 | 233 | ||
221 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 234 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
222 | return; | 235 | return; |
223 | } | 236 | } |
224 | 237 | ||
225 | int w=0; int h=0; | 238 | int w=0; int h=0; |
226 | if( !xineControl->hasVideo()) { | 239 | if( !xineControl->hasVideo() ) { |
227 | w = audioUI->width(); | 240 | w = audioUI->width(); |
228 | h = audioUI->height(); | 241 | h = audioUI->height(); |
229 | 242 | ||
230 | if ( drawnOnScreenDisplay ) { | 243 | if ( drawnOnScreenDisplay ) { |
231 | if ( onScreenDisplayVolume > v ) { | 244 | if ( onScreenDisplayVolume > v ) { |
232 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 245 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
233 | } | 246 | } |
234 | } | 247 | } |
235 | drawnOnScreenDisplay = TRUE; | 248 | drawnOnScreenDisplay = TRUE; |
236 | onScreenDisplayVolume = v; | 249 | onScreenDisplayVolume = v; |
237 | QPainter p( audioUI ); | 250 | QPainter p( audioUI ); |
238 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 251 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
239 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 252 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
240 | 253 | ||
241 | QFont f; | 254 | QFont f; |
242 | f.setPixelSize( 20 ); | 255 | f.setPixelSize( 20 ); |
243 | f.setBold( TRUE ); | 256 | f.setBold( TRUE ); |
244 | p.setFont( f ); | 257 | p.setFont( f ); |
245 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 258 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
246 | 259 | ||
247 | for ( unsigned int i = 0; i < 10; i++ ) { | 260 | for ( unsigned int i = 0; i < 10; i++ ) { |
248 | if ( v > i ) { | 261 | if ( v > i ) { |
249 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 262 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
250 | } else { | 263 | } else { |
251 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 264 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
252 | } | 265 | } |
253 | } | 266 | } |
254 | } else { | 267 | } else { |
255 | w = videoUI->width(); | 268 | w = videoUI->width(); |
256 | h = videoUI->height(); | 269 | h = videoUI->height(); |
257 | 270 | ||
258 | if ( drawnOnScreenDisplay ) { | 271 | if ( drawnOnScreenDisplay ) { |
259 | if ( onScreenDisplayVolume > v ) { | 272 | if ( onScreenDisplayVolume > v ) { |
260 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | 273 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
261 | } | 274 | } |
262 | } | 275 | } |
263 | drawnOnScreenDisplay = TRUE; | 276 | drawnOnScreenDisplay = TRUE; |
264 | onScreenDisplayVolume = v; | 277 | onScreenDisplayVolume = v; |
265 | QPainter p( videoUI ); | 278 | QPainter p( videoUI ); |
266 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 279 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
267 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 280 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
268 | 281 | ||
269 | QFont f; | 282 | QFont f; |
270 | f.setPixelSize( 20 ); | 283 | f.setPixelSize( 20 ); |
271 | f.setBold( TRUE ); | 284 | f.setBold( TRUE ); |
272 | p.setFont( f ); | 285 | p.setFont( f ); |
273 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 286 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
274 | 287 | ||
275 | for ( unsigned int i = 0; i < 10; i++ ) { | 288 | for ( unsigned int i = 0; i < 10; i++ ) { |
276 | if ( v > i ) { | 289 | if ( v > i ) { |
277 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 290 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
278 | } else { | 291 | } else { |
279 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 292 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
280 | } | 293 | } |
281 | } | 294 | } |
282 | } | 295 | } |
283 | } | 296 | } |
284 | 297 | ||
285 | 298 | ||
286 | void MediaPlayer::blank( bool b ) { | 299 | void MediaPlayer::blank( bool b ) { |
287 | fd=open("/dev/fb0",O_RDWR); | 300 | fd=open("/dev/fb0",O_RDWR); |
288 | if (fd != -1) { | 301 | if (fd != -1) { |
289 | if ( b ) { | 302 | if ( b ) { |
290 | qDebug("do blanking"); | 303 | qDebug("do blanking"); |
291 | ioctl( fd, FBIOBLANK, 3 ); | 304 | ioctl( fd, FBIOBLANK, 3 ); |
292 | isBlanked = TRUE; | 305 | isBlanked = TRUE; |
293 | } else { | 306 | } else { |
294 | qDebug("do unblanking"); | 307 | qDebug("do unblanking"); |
295 | ioctl( fd, FBIOBLANK, 0); | 308 | ioctl( fd, FBIOBLANK, 0); |
296 | isBlanked = FALSE; | 309 | isBlanked = FALSE; |
297 | } | 310 | } |
298 | close( fd ); | 311 | close( fd ); |
299 | } else { | 312 | } else { |
300 | qDebug("<< /dev/fb0 could not be opened >>"); | 313 | qDebug("<< /dev/fb0 could not be opened >>"); |
301 | } | 314 | } |
302 | } | 315 | } |
303 | 316 | ||
304 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 317 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
305 | switch ( e->key() ) { | 318 | switch ( e->key() ) { |
306 | ////////////////////////////// Zaurus keys | 319 | ////////////////////////////// Zaurus keys |
307 | case Key_Home: | 320 | case Key_Home: |
308 | break; | 321 | break; |
309 | case Key_F9: //activity | 322 | case Key_F9: //activity |
310 | break; | 323 | break; |
311 | case Key_F10: //contacts | 324 | case Key_F10: //contacts |
312 | break; | 325 | break; |
313 | case Key_F11: //menu | 326 | case Key_F11: //menu |
314 | break; | 327 | break; |
315 | case Key_F12: //home | 328 | case Key_F12: //home |
316 | qDebug("Blank here"); | 329 | qDebug("Blank here"); |
317 | // mediaPlayerState->toggleBlank(); | 330 | // mediaPlayerState->toggleBlank(); |
318 | break; | 331 | break; |
319 | case Key_F13: //mail | 332 | case Key_F13: //mail |
320 | qDebug("Blank here"); | 333 | qDebug("Blank here"); |
321 | // mediaPlayerState->toggleBlank(); | 334 | // mediaPlayerState->toggleBlank(); |
322 | break; | 335 | break; |
323 | } | 336 | } |
324 | } | 337 | } |
325 | 338 | ||
326 | void MediaPlayer::cleanUp() {// this happens on closing | 339 | void MediaPlayer::cleanUp() {// this happens on closing |
327 | Config cfg( "OpiePlayer" ); | 340 | Config cfg( "OpiePlayer" ); |
328 | mediaPlayerState->writeConfig( cfg ); | 341 | mediaPlayerState->writeConfig( cfg ); |
329 | playList->writeConfig( cfg ); | 342 | playList->writeConfig( cfg ); |
330 | 343 | ||
331 | // QPEApplication::grabKeyboard(); | 344 | // QPEApplication::grabKeyboard(); |
332 | // QPEApplication::ungrabKeyboard(); | 345 | // QPEApplication::ungrabKeyboard(); |
333 | } | 346 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 05be128..131db33 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h | |||
@@ -1,46 +1,78 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 LJP <> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
1 | 33 | ||
2 | #ifndef MEDIA_PLAYER_H | 34 | #ifndef MEDIA_PLAYER_H |
3 | #define MEDIA_PLAYER_H | 35 | #define MEDIA_PLAYER_H |
4 | 36 | ||
5 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
6 | #include <qframe.h> | 38 | #include <qframe.h> |
7 | #include <qpe/qlibrary.h> | 39 | #include <qpe/qlibrary.h> |
8 | #include <qpe/mediaplayerplugininterface.h> | 40 | #include <qpe/mediaplayerplugininterface.h> |
9 | 41 | ||
10 | #include "xinecontrol.h" | 42 | #include "xinecontrol.h" |
11 | 43 | ||
12 | class DocLnk; | 44 | class DocLnk; |
13 | class VolumeControl; | 45 | class VolumeControl; |
14 | 46 | ||
15 | class MediaPlayer : public QObject { | 47 | class MediaPlayer : public QObject { |
16 | Q_OBJECT | 48 | Q_OBJECT |
17 | public: | 49 | public: |
18 | MediaPlayer( QObject *parent, const char *name ); | 50 | MediaPlayer( QObject *parent, const char *name ); |
19 | ~MediaPlayer(); | 51 | ~MediaPlayer(); |
20 | private slots: | 52 | private slots: |
21 | void setPlaying( bool ); | 53 | void setPlaying( bool ); |
22 | void pauseCheck( bool ); | 54 | void pauseCheck( bool ); |
23 | void play(); | 55 | void play(); |
24 | void next(); | 56 | void next(); |
25 | void prev(); | 57 | void prev(); |
26 | void startIncreasingVolume(); | 58 | void startIncreasingVolume(); |
27 | void startDecreasingVolume(); | 59 | void startDecreasingVolume(); |
28 | void stopChangingVolume(); | 60 | void stopChangingVolume(); |
29 | void cleanUp(); | 61 | void cleanUp(); |
30 | void blank( bool ); | 62 | void blank( bool ); |
31 | 63 | ||
32 | protected: | 64 | protected: |
33 | void timerEvent( QTimerEvent *e ); | 65 | void timerEvent( QTimerEvent *e ); |
34 | void keyReleaseEvent( QKeyEvent *e); | 66 | void keyReleaseEvent( QKeyEvent *e); |
35 | private: | 67 | private: |
36 | bool isBlanked, l, r; | 68 | bool isBlanked, l, r; |
37 | int fd; | 69 | int fd; |
38 | int volumeDirection; | 70 | int volumeDirection; |
39 | const DocLnk *currentFile; | 71 | const DocLnk *currentFile; |
40 | XineControl *xineControl; | 72 | XineControl *xineControl; |
41 | VolumeControl *volControl; | 73 | VolumeControl *volControl; |
42 | }; | 74 | }; |
43 | 75 | ||
44 | 76 | ||
45 | #endif // MEDIA_PLAYER_H | 77 | #endif // MEDIA_PLAYER_H |
46 | 78 | ||
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index 1b687a3..619d36d 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,24 +1,24 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ | 7 | frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ |
8 | alphablend.h yuv2rgb.h | 8 | alphablend.h yuv2rgb.h |
9 | SOURCES = main.cpp \ | 9 | SOURCES = main.cpp \ |
10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ | 10 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \ |
11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 11 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ | 12 | frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ |
13 | playlistwidgetgui.cpp\ | 13 | playlistwidgetgui.cpp\ |
14 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S | 14 | alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S |
15 | TARGET = opieplayer2 | 15 | TARGET = opieplayer2 |
16 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
17 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
18 | LIBS += -lqpe -lpthread -lopie -lxine | 18 | LIBS += -lqpe -lpthread -lopie -lxine |
19 | MOC_DIR = qpeobj | 19 | MOC_DIR = qpeobj |
20 | OBJECTS_DIR = qpeobj | 20 | OBJECTS_DIR = qpeobj |
21 | 21 | ||
22 | #INCLUDEPATH += $(OPIEDIR)/include | 22 | #INCLUDEPATH += $(OPIEDIR)/include |
23 | #DEPENDPATH += $(OPIEDIR)/include | 23 | #DEPENDPATH += $(OPIEDIR)/include |
24 | 24 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index fabc9a5..c22822c 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,200 +1,247 @@ | |||
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 <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
38 | #include "xinecontrol.h" | 39 | #include "xinecontrol.h" |
39 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
40 | #include "videowidget.h" | 41 | #include "videowidget.h" |
41 | 42 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
43 | extern VideoWidget *videoUI; | 44 | extern VideoWidget *videoUI; |
44 | XineControl::XineControl( QObject *parent, const char *name ) | 45 | XineControl::XineControl( QObject *parent, const char *name ) |
45 | : QObject( parent, name ) { | 46 | : QObject( parent, name ) { |
47 | |||
46 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 48 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
47 | 49 | ||
48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 50 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 51 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 52 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 54 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 55 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
54 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 56 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
55 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
56 | 58 | ||
57 | disabledSuspendScreenSaver = FALSE; | 59 | disabledSuspendScreenSaver = FALSE; |
58 | } | 60 | } |
59 | 61 | ||
60 | XineControl::~XineControl() { | 62 | XineControl::~XineControl() { |
61 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 63 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
62 | if ( disabledSuspendScreenSaver ) { | 64 | if ( disabledSuspendScreenSaver ) { |
63 | disabledSuspendScreenSaver = FALSE; | 65 | disabledSuspendScreenSaver = FALSE; |
64 | // Re-enable the suspend mode | 66 | // Re-enable the suspend mode |
65 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 67 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
66 | } | 68 | } |
67 | #endif | 69 | #endif |
68 | delete libXine; | 70 | delete libXine; |
69 | } | 71 | } |
70 | 72 | ||
71 | void XineControl::play( const QString& fileName ) { | 73 | void XineControl::play( const QString& fileName ) { |
72 | hasVideoChannel=FALSE; | 74 | hasVideoChannel = FALSE; |
73 | hasAudioChannel=FALSE; | 75 | hasAudioChannel = FALSE; |
74 | m_fileName = fileName; | 76 | m_fileName = fileName; |
75 | 77 | ||
76 | //qDebug("<<FILENAME: " + fileName + ">>>>"); | 78 | //qDebug("<<FILENAME: " + fileName + ">>>>"); |
77 | 79 | ||
78 | libXine->play( fileName ); | 80 | if ( !libXine->play( fileName ) ) { |
79 | mediaPlayerState->setPlaying( true ); | 81 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
80 | char whichGui = mdetect.videoOrAudio( fileName ); | ||
81 | if (whichGui == 'f') { | ||
82 | qDebug("Nicht erkannter Dateityp"); | ||
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | if (whichGui == 'a') { | 84 | mediaPlayerState->setPlaying( true ); |
85 | |||
86 | char whichGui; | ||
87 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); | ||
88 | if ( !libXine->hasVideo() ) { | ||
89 | whichGui = 'a'; | ||
90 | qDebug("HAS AUDIO"); | ||
86 | libXine->setShowVideo( false ); | 91 | libXine->setShowVideo( false ); |
87 | hasAudioChannel=TRUE; | 92 | hasAudioChannel = TRUE; |
88 | } else { | 93 | } else { |
94 | whichGui = 'v'; | ||
95 | qDebug("HAS VIDEO"); | ||
89 | libXine->setShowVideo( true ); | 96 | libXine->setShowVideo( true ); |
90 | hasVideoChannel=TRUE; | 97 | hasVideoChannel = TRUE; |
91 | } | 98 | } |
92 | // determine if slider is shown | 99 | // determine if slider is shown |
93 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 100 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
94 | // which gui (video / audio) | 101 | // which gui (video / audio) |
95 | mediaPlayerState->setView( whichGui ); | 102 | mediaPlayerState->setView( whichGui ); |
96 | 103 | ||
97 | |||
98 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 104 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
99 | if ( !disabledSuspendScreenSaver ) { | 105 | if ( !disabledSuspendScreenSaver ) { |
100 | disabledSuspendScreenSaver = TRUE; | 106 | disabledSuspendScreenSaver = TRUE; |
101 | // Stop the screen from blanking and power saving state | 107 | // Stop the screen from blanking and power saving state |
102 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 108 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
103 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 109 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
104 | } | 110 | } |
105 | #endif | 111 | #endif |
106 | 112 | ||
107 | length(); | 113 | length(); |
108 | position(); | 114 | position(); |
109 | } | 115 | } |
110 | 116 | ||
111 | void XineControl::nextMedia() { | 117 | void XineControl::nextMedia() { |
112 | mediaPlayerState->setNext(); | 118 | mediaPlayerState->setNext(); |
113 | } | 119 | } |
114 | 120 | ||
115 | void XineControl::setGamma( int value ) { | 121 | void XineControl::setGamma( int value ) { |
116 | libXine->setGamma( value ); | 122 | libXine->setGamma( value ); |
117 | } | 123 | } |
118 | 124 | ||
119 | void XineControl::stop( bool isSet ) { | 125 | void XineControl::stop( bool isSet ) { |
120 | if ( !isSet) { | 126 | if ( !isSet ) { |
121 | libXine->stop( ); | 127 | libXine->stop(); |
122 | 128 | ||
123 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 129 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
124 | if ( disabledSuspendScreenSaver ) { | 130 | if ( disabledSuspendScreenSaver ) { |
125 | disabledSuspendScreenSaver = FALSE; | 131 | disabledSuspendScreenSaver = FALSE; |
126 | // Re-enable the suspend mode | 132 | // Re-enable the suspend mode |
127 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 133 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
128 | } | 134 | } |
129 | #endif | 135 | #endif |
130 | |||
131 | } | 136 | } |
132 | } | 137 | } |
133 | 138 | ||
134 | /** | 139 | /** |
135 | * Pause playback | 140 | * Pause playback |
136 | * @isSet | 141 | * @isSet |
137 | */ | 142 | */ |
138 | void XineControl::pause( bool isSet) { | 143 | void XineControl::pause( bool isSet) { |
139 | if (isSet) { | 144 | if ( isSet ) { |
140 | libXine->pause(); | 145 | libXine->pause(); |
141 | } else { | 146 | } else { |
142 | libXine->play( m_fileName, 0, m_currentTime); | 147 | libXine->play( m_fileName, 0, m_currentTime ); |
143 | } | 148 | } |
144 | } | 149 | } |
145 | 150 | ||
146 | 151 | ||
147 | /** | 152 | /** |
148 | * get current time in playback | 153 | * get current time in playback |
149 | */ | 154 | */ |
150 | long XineControl::currentTime() { | 155 | long XineControl::currentTime() { |
151 | // todo: jede sekunde überprüfen | 156 | // todo: jede sekunde überprüfen |
152 | m_currentTime = libXine->currentTime(); | 157 | m_currentTime = libXine->currentTime(); |
153 | return m_currentTime; | 158 | return m_currentTime; |
154 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 159 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
155 | } | 160 | } |
156 | 161 | ||
157 | /** | 162 | /** |
158 | * Set the length of the media file | 163 | * Set the length of the media file |
159 | */ | 164 | */ |
160 | void XineControl::length() { | 165 | void XineControl::length() { |
161 | m_length = libXine->length(); | 166 | m_length = libXine->length(); |
162 | mediaPlayerState->setLength( m_length ); | 167 | mediaPlayerState->setLength( m_length ); |
163 | } | 168 | } |
164 | 169 | ||
165 | 170 | ||
166 | /** | 171 | /** |
167 | * Reports the position the xine backend is at right now | 172 | * Reports the position the xine backend is at right now |
168 | * @return long the postion in seconds | 173 | * @return long the postion in seconds |
169 | */ | 174 | */ |
170 | long XineControl::position() { | 175 | long XineControl::position() { |
171 | m_position = ( currentTime() ); | 176 | m_position = ( currentTime() ); |
172 | mediaPlayerState->updatePosition( m_position ); | 177 | mediaPlayerState->updatePosition( m_position ); |
173 | long emitPos = (long)m_position; | 178 | long emitPos = (long)m_position; |
174 | emit positionChanged( emitPos ); | 179 | emit positionChanged( emitPos ); |
175 | if(mediaPlayerState->isPlaying) | 180 | if( mediaPlayerState->isPlaying ) { |
176 | // needs to be stopped the media is stopped | 181 | // needs to be stopped the media is stopped |
177 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 182 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
178 | // qDebug("POSITION : %d", m_position); | 183 | } |
184 | // qDebug("POSITION : %d", m_position); | ||
179 | return m_position; | 185 | return m_position; |
180 | } | 186 | } |
181 | 187 | ||
182 | /** | 188 | /** |
183 | * Set videoplayback to fullscreen | 189 | * Set videoplayback to fullscreen |
184 | * @param isSet | 190 | * @param isSet |
185 | */ | 191 | */ |
186 | void XineControl::setFullscreen( bool isSet ) { | 192 | void XineControl::setFullscreen( bool isSet ) { |
187 | libXine->showVideoFullScreen( isSet); | 193 | libXine->showVideoFullScreen( isSet ); |
194 | } | ||
195 | |||
196 | |||
197 | QString XineControl::getMetaInfo() { | ||
198 | |||
199 | QString returnString; | ||
200 | |||
201 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | ||
202 | returnString += tr( " Titel: " + libXine->metaInfo( 0 ) ); | ||
203 | } | ||
204 | |||
205 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | ||
206 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | ||
207 | } | ||
208 | |||
209 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | ||
210 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | ||
211 | } | ||
212 | |||
213 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | ||
214 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | ||
215 | } | ||
216 | |||
217 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | ||
218 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | ||
219 | } | ||
220 | |||
221 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | ||
222 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | ||
223 | } | ||
224 | return returnString; | ||
225 | } | ||
226 | |||
227 | QString XineControl::getErrorCode() { | ||
228 | int errorCode = libXine->error(); | ||
229 | |||
230 | if ( errorCode == 1 ) { | ||
231 | return tr( "No input plugin found for this media type" ); | ||
232 | } else { | ||
233 | return tr( "Some other error" ); | ||
234 | } | ||
188 | } | 235 | } |
189 | 236 | ||
190 | /** | 237 | /** |
191 | * Seek to a position in the track | 238 | * Seek to a position in the track |
192 | * @param second the second to jump to | 239 | * @param second the second to jump to |
193 | */ | 240 | */ |
194 | void XineControl::seekTo( long second ) { | 241 | void XineControl::seekTo( long second ) { |
195 | libXine->play( m_fileName , 0, (int)second ); | 242 | libXine->seekTo( (int)second ); |
196 | } | 243 | } |
197 | 244 | ||
198 | void XineControl::videoResized ( const QSize &s ) { | 245 | void XineControl::videoResized ( const QSize &s ) { |
199 | libXine-> resize ( s ); | 246 | libXine->resize( s ); |
200 | } | 247 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 1de610b..b1300a8 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,106 +1,116 @@ | |||
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 "mediadetect.h" | ||
39 | #include <qobject.h> | 38 | #include <qobject.h> |
40 | 39 | ||
41 | class XineControl : public QObject { | 40 | class XineControl : public QObject { |
42 | Q_OBJECT | 41 | Q_OBJECT |
43 | public: | 42 | public: |
44 | XineControl( QObject *parent = 0, const char *name =0 ); | 43 | XineControl( QObject *parent = 0, const char *name =0 ); |
45 | ~XineControl(); | 44 | ~XineControl(); |
46 | 45 | ||
47 | bool hasVideo() const { return hasVideoChannel; } | 46 | bool hasVideo() const { return hasVideoChannel; } |
48 | bool hasAudio() const { return hasAudioChannel; } | 47 | bool hasAudio() const { return hasAudioChannel; } |
49 | 48 | ||
50 | public slots: | 49 | public slots: |
51 | void play( const QString& fileName ); | 50 | void play( const QString& fileName ); |
52 | void stop( bool ); | 51 | void stop( bool ); |
53 | 52 | ||
54 | /** | 53 | /** |
55 | * Pause the media stream | 54 | * Pause the media stream |
56 | * @param if pause or not | 55 | * @param if pause or not |
57 | */ | 56 | */ |
58 | void pause( bool ); | 57 | void pause( bool ); |
59 | 58 | ||
60 | /** | 59 | /** |
61 | * Set videos fullscreen | 60 | * Set videos fullscreen |
62 | * @param yes or no | 61 | * @param yes or no |
63 | */ | 62 | */ |
64 | void setFullscreen( bool ); | 63 | void setFullscreen( bool ); |
65 | 64 | ||
66 | /** | 65 | /** |
67 | * | 66 | * |
68 | */ | 67 | */ |
69 | long currentTime(); | 68 | long currentTime(); |
70 | void seekTo( long ); | 69 | void seekTo( long ); |
71 | // get length of media file and set it | 70 | // get length of media file and set it |
72 | void length(); | 71 | void length(); |
73 | long position(); | 72 | long position(); |
74 | 73 | ||
75 | /** | 74 | /** |
76 | * Proceed to the next media file in playlist | 75 | * Proceed to the next media file in playlist |
77 | */ | 76 | */ |
78 | void nextMedia(); | 77 | void nextMedia(); |
79 | 78 | ||
79 | /** | ||
80 | * Get as much info about the stream from xine as possible | ||
81 | */ | ||
82 | QString getMetaInfo(); | ||
83 | |||
84 | /** | ||
85 | * get the error code and "translate" it for the user | ||
86 | * | ||
87 | */ | ||
88 | QString getErrorCode(); | ||
89 | |||
90 | |||
80 | void videoResized ( const QSize &s ); | 91 | void videoResized ( const QSize &s ); |
81 | 92 | ||
82 | /** | 93 | /** |
83 | * Set the gamma value of the video output | 94 | * Set the gamma value of the video output |
84 | * @param int value between -100 and 100, 0 is original | 95 | * @param int value between -100 and 100, 0 is original |
85 | */ | 96 | */ |
86 | void setGamma( int ); | 97 | void setGamma( int ); |
87 | 98 | ||
88 | 99 | ||
89 | private: | 100 | private: |
90 | XINE::Lib *libXine; | 101 | XINE::Lib *libXine; |
91 | MediaDetect mdetect; | ||
92 | long m_currentTime; | 102 | long m_currentTime; |
93 | long m_position; | 103 | long m_position; |
94 | int m_length; | 104 | int m_length; |
95 | QString m_fileName; | 105 | QString m_fileName; |
96 | bool disabledSuspendScreenSaver : 1; | 106 | bool disabledSuspendScreenSaver : 1; |
97 | bool hasVideoChannel : 1; | 107 | bool hasVideoChannel : 1; |
98 | bool hasAudioChannel : 1; | 108 | bool hasAudioChannel : 1; |
99 | 109 | ||
100 | signals: | 110 | signals: |
101 | void positionChanged( long ); | 111 | void positionChanged( long ); |
102 | 112 | ||
103 | }; | 113 | }; |
104 | 114 | ||
105 | 115 | ||
106 | #endif | 116 | #endif |