author | simon <simon> | 2002-12-11 14:25:49 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 14:25:49 (UTC) |
commit | 7a17954c26add31f28b69989f54e0f28a17c8949 (patch) (unidiff) | |
tree | 8603026771be07c996f49a29375fda64c8cd0e67 | |
parent | 16138f0cdf46994d20ade71b5621b82fb9386933 (diff) | |
download | opie-7a17954c26add31f28b69989f54e0f28a17c8949.zip opie-7a17954c26add31f28b69989f54e0f28a17c8949.tar.gz opie-7a17954c26add31f28b69989f54e0f28a17c8949.tar.bz2 |
- roll back the threaded xine initialization, the mediaplayer initialization
state and the PlayButton change set
- instead load the audio-/video widget and the xine control on-demand. much
faster and much simpler for startup
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 92 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 120 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 13 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.h | 18 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 6 |
11 files changed, 84 insertions, 241 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 20fd1e2..1e0dc21 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,389 +1,301 @@ | |||
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 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | 42 | ||
43 | #include <qgfx_qws.h> | 43 | #include <qgfx_qws.h> |
44 | #include <qdirectpainter_qws.h> | 44 | #include <qdirectpainter_qws.h> |
45 | 45 | ||
46 | #include <assert.h> | 46 | #include <assert.h> |
47 | 47 | ||
48 | #include "xinevideowidget.h" | 48 | #include "xinevideowidget.h" |
49 | #include "frame.h" | 49 | #include "frame.h" |
50 | #include "lib.h" | 50 | #include "lib.h" |
51 | 51 | ||
52 | 52 | ||
53 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 53 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
54 | int width, int height,int bytes ); | 54 | int width, int height,int bytes ); |
55 | 55 | ||
56 | extern "C" { | 56 | extern "C" { |
57 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 57 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
58 | int null_is_showing_video( const xine_vo_driver_t* self ); | 58 | int null_is_showing_video( const xine_vo_driver_t* self ); |
59 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 59 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
60 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 60 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
61 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 61 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
62 | int null_is_scaling( const xine_vo_driver_t* self ); | 62 | int null_is_scaling( const xine_vo_driver_t* self ); |
63 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 63 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
64 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 64 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
65 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 65 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
66 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 66 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
67 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 67 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
68 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 68 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
69 | } | 69 | } |
70 | 70 | ||
71 | using namespace XINE; | 71 | using namespace XINE; |
72 | 72 | ||
73 | Lib::Lib( XineVideoWidget* widget ) | 73 | Lib::Lib( XineVideoWidget* widget ) |
74 | { | 74 | { |
75 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
76 | m_initialized = false; | ||
77 | m_video = false; | 75 | m_video = false; |
78 | m_wid = widget; | 76 | m_wid = widget; |
79 | printf("Lib"); | 77 | printf("Lib"); |
80 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 78 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
81 | // get the configuration | 79 | // get the configuration |
82 | 80 | ||
83 | // not really OO, should be an extra class, later | 81 | // not really OO, should be an extra class, later |
84 | if ( !QFile::exists(configPath) ) { | 82 | if ( !QFile::exists(configPath) ) { |
85 | QFile f(configPath); | 83 | QFile f(configPath); |
86 | f.open(IO_WriteOnly); | 84 | f.open(IO_WriteOnly); |
87 | QTextStream ts( &f ); | 85 | QTextStream ts( &f ); |
88 | ts << "misc.memcpy_method:glibc\n"; | 86 | ts << "misc.memcpy_method:glibc\n"; |
89 | f.close(); | 87 | f.close(); |
90 | } | 88 | } |
91 | 89 | ||
92 | start(); | ||
93 | } | ||
94 | |||
95 | void Lib::run() | ||
96 | { | ||
97 | initialize(); | ||
98 | } | ||
99 | |||
100 | void Lib::initialize() | ||
101 | { | ||
102 | m_xine = xine_new( ); | 90 | m_xine = xine_new( ); |
103 | 91 | ||
104 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | ||
105 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 92 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
106 | 93 | ||
107 | xine_init( m_xine ); | 94 | xine_init( m_xine ); |
108 | 95 | ||
109 | // allocate oss for sound | 96 | // allocate oss for sound |
110 | // and fb for framebuffer | 97 | // and fb for framebuffer |
111 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 98 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
112 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 99 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
113 | 100 | ||
114 | 101 | ||
115 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 102 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
116 | 103 | ||
117 | 104 | ||
118 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 105 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
119 | 106 | ||
120 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 107 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
121 | 108 | ||
122 | if (m_wid != 0 ) { | 109 | if (m_wid != 0 ) { |
123 | printf( "!0\n" ); | 110 | printf( "!0\n" ); |
124 | resize ( m_wid-> size ( ) ); | 111 | resize ( m_wid-> size ( ) ); |
125 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 112 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
126 | 113 | ||
127 | // m_wid->repaint(); | 114 | // m_wid->repaint(); |
128 | } | 115 | } |
129 | 116 | ||
130 | m_queue = xine_event_new_queue (m_stream); | 117 | m_queue = xine_event_new_queue (m_stream); |
131 | 118 | ||
132 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 119 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
133 | |||
134 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
135 | m_initialized = true; | ||
136 | |||
137 | send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay ); | ||
138 | } | 120 | } |
139 | 121 | ||
140 | Lib::~Lib() { | 122 | Lib::~Lib() { |
141 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
142 | |||
143 | assert( m_initialized ); | ||
144 | |||
145 | // free( m_config ); | 123 | // free( m_config ); |
146 | 124 | ||
147 | xine_close( m_stream ); | 125 | xine_close( m_stream ); |
148 | 126 | ||
149 | xine_event_dispose_queue( m_queue ); | 127 | xine_event_dispose_queue( m_queue ); |
150 | 128 | ||
151 | xine_dispose( m_stream ); | 129 | xine_dispose( m_stream ); |
152 | 130 | ||
153 | xine_exit( m_xine ); | 131 | xine_exit( m_xine ); |
154 | /* FIXME either free or delete but valgrind bitches against both */ | 132 | /* FIXME either free or delete but valgrind bitches against both */ |
155 | //free( m_videoOutput ); | 133 | //free( m_videoOutput ); |
156 | //delete m_audioOutput; | 134 | //delete m_audioOutput; |
157 | } | 135 | } |
158 | 136 | ||
159 | void Lib::assertInitialized() const | ||
160 | { | ||
161 | ThreadUtil::AutoLock lock( m_initGuard ); | ||
162 | |||
163 | if ( m_initialized ) | ||
164 | return; | ||
165 | |||
166 | qDebug( "LibXine: xine function called while not being initialized, yet! Fix the caller!" ); | ||
167 | assert( m_initialized ); | ||
168 | } | ||
169 | |||
170 | void Lib::resize ( const QSize &s ) { | 137 | void Lib::resize ( const QSize &s ) { |
171 | if ( s. width ( ) && s. height ( ) ) { | 138 | if ( s. width ( ) && s. height ( ) ) { |
172 | ::null_set_gui_width( m_videoOutput, s. width() ); | 139 | ::null_set_gui_width( m_videoOutput, s. width() ); |
173 | ::null_set_gui_height( m_videoOutput, s. height() ); | 140 | ::null_set_gui_height( m_videoOutput, s. height() ); |
174 | } | 141 | } |
175 | } | 142 | } |
176 | 143 | ||
177 | int Lib::majorVersion() { | 144 | int Lib::majorVersion() { |
178 | int major, minor, sub; | 145 | int major, minor, sub; |
179 | xine_get_version ( &major, &minor, &sub ); | 146 | xine_get_version ( &major, &minor, &sub ); |
180 | return major; | 147 | return major; |
181 | } | 148 | } |
182 | 149 | ||
183 | int Lib::minorVersion() { | 150 | int Lib::minorVersion() { |
184 | int major, minor, sub; | 151 | int major, minor, sub; |
185 | xine_get_version ( &major, &minor, &sub ); | 152 | xine_get_version ( &major, &minor, &sub ); |
186 | return minor; | 153 | return minor; |
187 | } | 154 | } |
188 | 155 | ||
189 | int Lib::subVersion() { | 156 | int Lib::subVersion() { |
190 | int major, minor, sub; | 157 | int major, minor, sub; |
191 | xine_get_version ( &major, &minor, &sub ); | 158 | xine_get_version ( &major, &minor, &sub ); |
192 | return sub; | 159 | return sub; |
193 | } | 160 | } |
194 | 161 | ||
195 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 162 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
196 | assertInitialized(); | ||
197 | |||
198 | QString str = fileName.stripWhiteSpace(); | 163 | QString str = fileName.stripWhiteSpace(); |
199 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 164 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { |
200 | return 0; | 165 | return 0; |
201 | } | 166 | } |
202 | return xine_play( m_stream, startPos, start_time); | 167 | return xine_play( m_stream, startPos, start_time); |
203 | } | 168 | } |
204 | 169 | ||
205 | void Lib::stop() { | 170 | void Lib::stop() { |
206 | assertInitialized(); | ||
207 | |||
208 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 171 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
209 | xine_stop( m_stream ); | 172 | xine_stop( m_stream ); |
210 | } | 173 | } |
211 | 174 | ||
212 | void Lib::pause( bool toggle ) { | 175 | void Lib::pause( bool toggle ) { |
213 | assertInitialized(); | ||
214 | |||
215 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 176 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
216 | } | 177 | } |
217 | 178 | ||
218 | int Lib::speed() const { | 179 | int Lib::speed() const { |
219 | assertInitialized(); | ||
220 | |||
221 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 180 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
222 | } | 181 | } |
223 | 182 | ||
224 | void Lib::setSpeed( int speed ) { | 183 | void Lib::setSpeed( int speed ) { |
225 | assertInitialized(); | ||
226 | |||
227 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 184 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
228 | } | 185 | } |
229 | 186 | ||
230 | int Lib::status() const { | 187 | int Lib::status() const { |
231 | assertInitialized(); | ||
232 | |||
233 | return xine_get_status( m_stream ); | 188 | return xine_get_status( m_stream ); |
234 | } | 189 | } |
235 | 190 | ||
236 | int Lib::currentPosition() const { | 191 | int Lib::currentPosition() const { |
237 | assertInitialized(); | ||
238 | |||
239 | int pos, time, length; | 192 | int pos, time, length; |
240 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 193 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
241 | return pos; | 194 | return pos; |
242 | } | 195 | } |
243 | 196 | ||
244 | int Lib::currentTime() const { | 197 | int Lib::currentTime() const { |
245 | assertInitialized(); | ||
246 | |||
247 | int pos, time, length; | 198 | int pos, time, length; |
248 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 199 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
249 | return time/1000; | 200 | return time/1000; |
250 | } | 201 | } |
251 | 202 | ||
252 | int Lib::length() const { | 203 | int Lib::length() const { |
253 | assertInitialized(); | ||
254 | |||
255 | int pos, time, length; | 204 | int pos, time, length; |
256 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 205 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
257 | return length/1000; | 206 | return length/1000; |
258 | } | 207 | } |
259 | 208 | ||
260 | bool Lib::isSeekable() const { | 209 | bool Lib::isSeekable() const { |
261 | assertInitialized(); | ||
262 | |||
263 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 210 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
264 | } | 211 | } |
265 | 212 | ||
266 | void Lib::seekTo( int time ) { | 213 | void Lib::seekTo( int time ) { |
267 | assertInitialized(); | ||
268 | |||
269 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 214 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
270 | // since its now milliseconds we need *1000 | 215 | // since its now milliseconds we need *1000 |
271 | xine_play( m_stream, 0, time*1000 ); | 216 | xine_play( m_stream, 0, time*1000 ); |
272 | } | 217 | } |
273 | 218 | ||
274 | 219 | ||
275 | Frame Lib::currentFrame() const { | 220 | Frame Lib::currentFrame() const { |
276 | assertInitialized(); | ||
277 | |||
278 | Frame frame; | 221 | Frame frame; |
279 | return frame; | 222 | return frame; |
280 | }; | 223 | }; |
281 | 224 | ||
282 | QString Lib::metaInfo( int number) const { | 225 | QString Lib::metaInfo( int number) const { |
283 | assertInitialized(); | ||
284 | |||
285 | return xine_get_meta_info( m_stream, number ); | 226 | return xine_get_meta_info( m_stream, number ); |
286 | } | 227 | } |
287 | 228 | ||
288 | int Lib::error() const { | 229 | int Lib::error() const { |
289 | assertInitialized(); | ||
290 | |||
291 | return xine_get_error( m_stream ); | 230 | return xine_get_error( m_stream ); |
292 | }; | 231 | }; |
293 | 232 | ||
294 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 233 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
295 | { | 234 | { |
296 | assert( sendType == ThreadUtil::Channel::OneWay ); | 235 | assert( sendType == ThreadUtil::Channel::OneWay ); |
297 | switch ( msg->type() ) { | 236 | handleXineEvent( msg->type() ); |
298 | case XineMessageType: | ||
299 | handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent ); | ||
300 | break; | ||
301 | case InitializationMessageType: | ||
302 | emit initialized(); | ||
303 | break; | ||
304 | } | ||
305 | delete msg; | 237 | delete msg; |
306 | } | 238 | } |
307 | 239 | ||
308 | void Lib::handleXineEvent( const xine_event_t* t ) { | 240 | void Lib::handleXineEvent( const xine_event_t* t ) { |
309 | send( new XineMessage( t->type ), OneWay ); | 241 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
310 | } | 242 | } |
311 | 243 | ||
312 | void Lib::handleXineEvent( int type ) { | 244 | void Lib::handleXineEvent( int type ) { |
313 | assertInitialized(); | ||
314 | |||
315 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 245 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
316 | emit stopped(); | 246 | emit stopped(); |
317 | } | 247 | } |
318 | } | 248 | } |
319 | 249 | ||
320 | 250 | ||
321 | void Lib::setShowVideo( bool video ) { | 251 | void Lib::setShowVideo( bool video ) { |
322 | assertInitialized(); | ||
323 | |||
324 | m_video = video; | 252 | m_video = video; |
325 | ::null_set_show_video( m_videoOutput, video ); | 253 | ::null_set_show_video( m_videoOutput, video ); |
326 | } | 254 | } |
327 | 255 | ||
328 | bool Lib::isShowingVideo() const { | 256 | bool Lib::isShowingVideo() const { |
329 | assertInitialized(); | ||
330 | |||
331 | return ::null_is_showing_video( m_videoOutput ); | 257 | return ::null_is_showing_video( m_videoOutput ); |
332 | } | 258 | } |
333 | 259 | ||
334 | bool Lib::hasVideo() const { | 260 | bool Lib::hasVideo() const { |
335 | assertInitialized(); | ||
336 | |||
337 | return xine_get_stream_info( m_stream, 18 ); | 261 | return xine_get_stream_info( m_stream, 18 ); |
338 | } | 262 | } |
339 | 263 | ||
340 | void Lib::showVideoFullScreen( bool fullScreen ) { | 264 | void Lib::showVideoFullScreen( bool fullScreen ) { |
341 | assertInitialized(); | ||
342 | |||
343 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 265 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
344 | } | 266 | } |
345 | 267 | ||
346 | bool Lib::isVideoFullScreen() const { | 268 | bool Lib::isVideoFullScreen() const { |
347 | assertInitialized(); | ||
348 | |||
349 | return ::null_is_fullscreen( m_videoOutput ); | 269 | return ::null_is_fullscreen( m_videoOutput ); |
350 | } | 270 | } |
351 | 271 | ||
352 | void Lib::setScaling( bool scale ) { | 272 | void Lib::setScaling( bool scale ) { |
353 | assertInitialized(); | ||
354 | |||
355 | ::null_set_scaling( m_videoOutput, scale ); | 273 | ::null_set_scaling( m_videoOutput, scale ); |
356 | } | 274 | } |
357 | 275 | ||
358 | void Lib::setGamma( int value ) { | 276 | void Lib::setGamma( int value ) { |
359 | assertInitialized(); | ||
360 | |||
361 | //qDebug( QString( "%1").arg(value) ); | 277 | //qDebug( QString( "%1").arg(value) ); |
362 | /* int gammaValue = ( 100 + value ); */ | 278 | /* int gammaValue = ( 100 + value ); */ |
363 | ::null_set_videoGamma( m_videoOutput, value ); | 279 | ::null_set_videoGamma( m_videoOutput, value ); |
364 | } | 280 | } |
365 | 281 | ||
366 | bool Lib::isScaling() const { | 282 | bool Lib::isScaling() const { |
367 | assertInitialized(); | ||
368 | |||
369 | return ::null_is_scaling( m_videoOutput ); | 283 | return ::null_is_scaling( m_videoOutput ); |
370 | } | 284 | } |
371 | 285 | ||
372 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 286 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
373 | ( (Lib*)user_data)->handleXineEvent( t ); | 287 | ( (Lib*)user_data)->handleXineEvent( t ); |
374 | } | 288 | } |
375 | 289 | ||
376 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 290 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
377 | int width, int height, int bytes ) { | 291 | int width, int height, int bytes ) { |
378 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 292 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
379 | } | 293 | } |
380 | 294 | ||
381 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 295 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
382 | assertInitialized(); | ||
383 | |||
384 | if ( !m_video ) { | 296 | if ( !m_video ) { |
385 | qWarning("not showing video now"); | 297 | qWarning("not showing video now"); |
386 | return; | 298 | return; |
387 | } | 299 | } |
388 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 300 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
389 | } | 301 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 34b85b9..aba2ec9 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,228 +1,208 @@ | |||
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 | #include "threadutil.h" | 44 | #include "threadutil.h" |
45 | 45 | ||
46 | class XineVideoWidget; | 46 | class XineVideoWidget; |
47 | 47 | ||
48 | namespace XINE { | 48 | namespace XINE { |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Lib wrapps the simple interface | 51 | * Lib wrapps the simple interface |
52 | * of libxine for easy every day use | 52 | * of libxine for easy every day use |
53 | * This will become a full C++ Wrapper | 53 | * This will become a full C++ Wrapper |
54 | * It supports playing, pausing, info, | 54 | * It supports playing, pausing, info, |
55 | * stooping, seeking. | 55 | * stooping, seeking. |
56 | */ | 56 | */ |
57 | class Frame; | 57 | class Frame; |
58 | class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread | 58 | class Lib : public ThreadUtil::Channel |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | Lib(XineVideoWidget* = 0); | 62 | Lib(XineVideoWidget* = 0); |
63 | ~Lib(); | 63 | ~Lib(); |
64 | static int majorVersion(); | 64 | static int majorVersion(); |
65 | static int minorVersion(); | 65 | static int minorVersion(); |
66 | static int subVersion(); | 66 | static int subVersion(); |
67 | 67 | ||
68 | 68 | ||
69 | void resize ( const QSize &s ); | 69 | void resize ( const QSize &s ); |
70 | 70 | ||
71 | int play( const QString& fileName, | 71 | int play( const QString& fileName, |
72 | int startPos = 0, | 72 | int startPos = 0, |
73 | int start_time = 0 ); | 73 | int start_time = 0 ); |
74 | void stop(); | 74 | void stop(); |
75 | void pause( bool toggle ); | 75 | void pause( bool toggle ); |
76 | 76 | ||
77 | int speed() const; | 77 | int speed() const; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Set the speed of the stream, if codec supports it | 80 | * Set the speed of the stream, if codec supports it |
81 | * XINE_SPEED_PAUSE 0 | 81 | * XINE_SPEED_PAUSE 0 |
82 | * XINE_SPEED_SLOW_4 1 | 82 | * XINE_SPEED_SLOW_4 1 |
83 | * XINE_SPEED_SLOW_2 2 | 83 | * XINE_SPEED_SLOW_2 2 |
84 | * XINE_SPEED_NORMAL 4 | 84 | * XINE_SPEED_NORMAL 4 |
85 | * XINE_SPEED_FAST_2 8 | 85 | * XINE_SPEED_FAST_2 8 |
86 | *XINE_SPEED_FAST_4 16 | 86 | *XINE_SPEED_FAST_4 16 |
87 | */ | 87 | */ |
88 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | 88 | void setSpeed( int speed = XINE_SPEED_PAUSE ); |
89 | 89 | ||
90 | int status() const; | 90 | int status() const; |
91 | 91 | ||
92 | int currentPosition()const; | 92 | int currentPosition()const; |
93 | //in seconds | 93 | //in seconds |
94 | int currentTime()const; | 94 | int currentTime()const; |
95 | 95 | ||
96 | int length() const; | 96 | int length() const; |
97 | 97 | ||
98 | bool isSeekable()const; | 98 | bool isSeekable()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Whether or not to show video output | 101 | * Whether or not to show video output |
102 | */ | 102 | */ |
103 | void setShowVideo(bool video); | 103 | void setShowVideo(bool video); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * is we show video | 106 | * is we show video |
107 | */ | 107 | */ |
108 | bool isShowingVideo() const; | 108 | bool isShowingVideo() const; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * | 111 | * |
112 | */ | 112 | */ |
113 | void showVideoFullScreen( bool fullScreen ); | 113 | void showVideoFullScreen( bool fullScreen ); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * | 116 | * |
117 | */ | 117 | */ |
118 | bool isVideoFullScreen() const; | 118 | bool isVideoFullScreen() const; |
119 | 119 | ||
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Get the meta info (like author etc) from the stream | 122 | * Get the meta info (like author etc) from the stream |
123 | * XINE_META_INFO_TITLE 0 | 123 | * XINE_META_INFO_TITLE 0 |
124 | * XINE_META_INFO_COMMENT 1 | 124 | * XINE_META_INFO_COMMENT 1 |
125 | * XINE_META_INFO_ARTIST 2 | 125 | * XINE_META_INFO_ARTIST 2 |
126 | * XINE_META_INFO_GENRE 3 | 126 | * XINE_META_INFO_GENRE 3 |
127 | * XINE_META_INFO_ALBUM 4 | 127 | * XINE_META_INFO_ALBUM 4 |
128 | * XINE_META_INFO_YEAR 5 | 128 | * XINE_META_INFO_YEAR 5 |
129 | * XINE_META_INFO_VIDEOCODEC 6 | 129 | * XINE_META_INFO_VIDEOCODEC 6 |
130 | * XINE_META_INFO_AUDIOCODEC 7 | 130 | * XINE_META_INFO_AUDIOCODEC 7 |
131 | * XINE_META_INFO_SYSTEMLAYER 8 | 131 | * XINE_META_INFO_SYSTEMLAYER 8 |
132 | * XINE_META_INFO_INPUT_PLUGIN 9 | 132 | * XINE_META_INFO_INPUT_PLUGIN 9 |
133 | */ | 133 | */ |
134 | QString metaInfo( int number ) const; | 134 | QString metaInfo( int number ) const; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * | 137 | * |
138 | */ | 138 | */ |
139 | bool isScaling() const; | 139 | bool isScaling() const; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * seek to a position | 142 | * seek to a position |
143 | */ | 143 | */ |
144 | void seekTo( int time ); | 144 | void seekTo( int time ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * | 147 | * |
148 | * @return is media stream has video | 148 | * @return is media stream has video |
149 | */ | 149 | */ |
150 | bool hasVideo() const; | 150 | bool hasVideo() const; |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * | 153 | * |
154 | */ | 154 | */ |
155 | void setScaling( bool ); | 155 | void setScaling( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Set the Gamma value for video output | 158 | * Set the Gamma value for video output |
159 | * @param int the value between -100 and 100, 0 is original | 159 | * @param int the value between -100 and 100, 0 is original |
160 | */ | 160 | */ |
161 | void setGamma( int ); | 161 | void setGamma( int ); |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * test | 164 | * test |
165 | */ | 165 | */ |
166 | Frame currentFrame() const; | 166 | Frame currentFrame() const; |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * Returns the error code | 169 | * Returns the error code |
170 | * XINE_ERROR_NONE 0 | 170 | * XINE_ERROR_NONE 0 |
171 | * XINE_ERROR_NO_INPUT_PLUGIN 1 | 171 | * XINE_ERROR_NO_INPUT_PLUGIN 1 |
172 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 | 172 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 |
173 | * XINE_ERROR_DEMUXER_FAILED 3 | 173 | * XINE_ERROR_DEMUXER_FAILED 3 |
174 | */ | 174 | */ |
175 | int error() const; | 175 | int error() const; |
176 | 176 | ||
177 | signals: | 177 | signals: |
178 | 178 | ||
179 | void stopped(); | 179 | void stopped(); |
180 | 180 | ||
181 | void initialized(); | 181 | void initialized(); |
182 | 182 | ||
183 | protected: | 183 | protected: |
184 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); | 184 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); |
185 | 185 | ||
186 | virtual void run(); | ||
187 | |||
188 | private: | 186 | private: |
189 | void initialize(); | ||
190 | |||
191 | void assertInitialized() const; | ||
192 | |||
193 | enum { XineMessageType = 1, InitializationMessageType }; | ||
194 | |||
195 | struct XineMessage : public ThreadUtil::ChannelMessage | ||
196 | { | ||
197 | XineMessage( int _xineEvent ) : ThreadUtil::ChannelMessage( XineMessageType ), | ||
198 | xineEvent( _xineEvent ) | ||
199 | {} | ||
200 | |||
201 | int xineEvent; | ||
202 | }; | ||
203 | |||
204 | mutable ThreadUtil::Mutex m_initGuard; | ||
205 | bool m_initialized : 1; | ||
206 | |||
207 | int m_bytes_per_pixel; | 187 | int m_bytes_per_pixel; |
208 | bool m_video:1; | 188 | bool m_video:1; |
209 | XineVideoWidget *m_wid; | 189 | XineVideoWidget *m_wid; |
210 | xine_t *m_xine; | 190 | xine_t *m_xine; |
211 | xine_stream_t *m_stream; | 191 | xine_stream_t *m_stream; |
212 | xine_cfg_entry_t *m_config; | 192 | xine_cfg_entry_t *m_config; |
213 | xine_vo_driver_t *m_videoOutput; | 193 | xine_vo_driver_t *m_videoOutput; |
214 | xine_ao_driver_t* m_audioOutput; | 194 | xine_ao_driver_t* m_audioOutput; |
215 | xine_event_queue_t *m_queue; | 195 | xine_event_queue_t *m_queue; |
216 | 196 | ||
217 | void handleXineEvent( const xine_event_t* t ); | 197 | void handleXineEvent( const xine_event_t* t ); |
218 | void handleXineEvent( int type ); | 198 | void handleXineEvent( int type ); |
219 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 199 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
220 | // C -> C++ bridge for the event system | 200 | // C -> C++ bridge for the event system |
221 | static void xine_event_handler( void* user_data, const xine_event_t* t); | 201 | static void xine_event_handler( void* user_data, const xine_event_t* t); |
222 | static void xine_display_frame( void* user_data, uint8_t* frame , | 202 | static void xine_display_frame( void* user_data, uint8_t* frame , |
223 | int width, int height, int bytes ); | 203 | int width, int height, int bytes ); |
224 | }; | 204 | }; |
225 | }; | 205 | }; |
226 | 206 | ||
227 | 207 | ||
228 | #endif | 208 | #endif |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index c230d6f..bbc60dd 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,377 +1,395 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
6 | #include <qfileinfo.h> | 6 | #include <qfileinfo.h> |
7 | 7 | ||
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | 12 | ||
13 | #include "mediaplayer.h" | 13 | #include "mediaplayer.h" |
14 | #include "playlistwidget.h" | 14 | #include "playlistwidget.h" |
15 | #include "audiowidget.h" | 15 | #include "audiowidget.h" |
16 | #include "videowidget.h" | 16 | #include "videowidget.h" |
17 | #include "volumecontrol.h" | 17 | #include "volumecontrol.h" |
18 | 18 | ||
19 | #include "mediaplayerstate.h" | 19 | #include "mediaplayerstate.h" |
20 | 20 | ||
21 | // for setBacklight() | 21 | // for setBacklight() |
22 | #include <linux/fb.h> | 22 | #include <linux/fb.h> |
23 | #include <sys/file.h> | 23 | #include <sys/file.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
30 | 30 | ||
31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
33 | 33 | ||
34 | audioUI = 0; | 34 | m_audioUI = 0; |
35 | videoUI = 0; | 35 | m_videoUI = 0; |
36 | xineControl = 0; | 36 | m_xineControl = 0; |
37 | recreateAudioAndVideoWidgets(); | ||
38 | 37 | ||
39 | fd=-1;fl=-1; | 38 | fd=-1;fl=-1; |
40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 39 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
41 | 40 | ||
42 | qApp->processEvents(); | 41 | qApp->processEvents(); |
43 | // QPEApplication::grabKeyboard(); // EVIL | 42 | // QPEApplication::grabKeyboard(); // EVIL |
44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 43 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
45 | 44 | ||
46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 45 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
47 | 46 | ||
48 | // What is pauseCheck good for? (Simon) | 47 | // What is pauseCheck good for? (Simon) |
49 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 48 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
50 | 49 | ||
51 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 50 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
52 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 51 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
53 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 52 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
54 | 53 | ||
55 | volControl = new VolumeControl; | 54 | volControl = new VolumeControl; |
56 | Config cfg( "OpiePlayer" ); | 55 | Config cfg( "OpiePlayer" ); |
57 | cfg.setGroup("PlayList"); | 56 | cfg.setGroup("PlayList"); |
58 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 57 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
59 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 58 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
60 | } | 59 | } |
61 | 60 | ||
62 | MediaPlayer::~MediaPlayer() { | 61 | MediaPlayer::~MediaPlayer() { |
63 | delete xineControl; | 62 | delete m_xineControl; |
64 | delete audioUI; | 63 | delete m_audioUI; |
65 | delete videoUI; | 64 | delete m_videoUI; |
66 | delete volControl; | 65 | delete volControl; |
67 | } | 66 | } |
68 | 67 | ||
69 | void MediaPlayer::pauseCheck( bool b ) { | 68 | void MediaPlayer::pauseCheck( bool b ) { |
70 | if ( b && !mediaPlayerState.isPlaying() ) { | 69 | if ( b && !mediaPlayerState.isPlaying() ) { |
71 | mediaPlayerState.setPaused( FALSE ); | 70 | mediaPlayerState.setPaused( FALSE ); |
72 | } | 71 | } |
73 | } | 72 | } |
74 | 73 | ||
75 | void MediaPlayer::play() { | 74 | void MediaPlayer::play() { |
76 | mediaPlayerState.setPlaying( FALSE ); | 75 | mediaPlayerState.setPlaying( FALSE ); |
77 | mediaPlayerState.setPlaying( TRUE ); | 76 | mediaPlayerState.setPlaying( TRUE ); |
78 | } | 77 | } |
79 | 78 | ||
80 | void MediaPlayer::setPlaying( bool play ) { | 79 | void MediaPlayer::setPlaying( bool play ) { |
81 | if ( !play ) { | 80 | if ( !play ) { |
82 | return; | 81 | return; |
83 | } | 82 | } |
84 | 83 | ||
85 | if ( mediaPlayerState.isPaused() ) { | 84 | if ( mediaPlayerState.isPaused() ) { |
86 | mediaPlayerState.setPaused( FALSE ); | 85 | mediaPlayerState.setPaused( FALSE ); |
87 | return; | 86 | return; |
88 | } | 87 | } |
89 | 88 | ||
90 | QString tickerText, time, fileName; | 89 | QString tickerText, time, fileName; |
91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 90 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
92 | //if playing in file list.. play in a different way | 91 | //if playing in file list.. play in a different way |
93 | // random and looping settings enabled causes problems here, | 92 | // random and looping settings enabled causes problems here, |
94 | // since there is no selected file in the playlist, but a selected file in the file list, | 93 | // since there is no selected file in the playlist, but a selected file in the file list, |
95 | // so we remember and shutoff | 94 | // so we remember and shutoff |
96 | l = mediaPlayerState.isLooping(); | 95 | l = mediaPlayerState.isLooping(); |
97 | if(l) { | 96 | if(l) { |
98 | mediaPlayerState.setLooping( false ); | 97 | mediaPlayerState.setLooping( false ); |
99 | } | 98 | } |
100 | r = mediaPlayerState.isShuffled(); | 99 | r = mediaPlayerState.isShuffled(); |
101 | mediaPlayerState.setShuffled( false ); | 100 | mediaPlayerState.setShuffled( false ); |
102 | } | 101 | } |
103 | 102 | ||
104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 103 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
105 | fileName = playListEntry.name; | 104 | fileName = playListEntry.name; |
106 | xineControl->play( playListEntry.file ); | 105 | xineControl()->play( playListEntry.file ); |
107 | 106 | ||
108 | long seconds = mediaPlayerState.length(); | 107 | long seconds = mediaPlayerState.length(); |
109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 108 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
110 | 109 | ||
111 | if( fileName.left(4) == "http" ) { | 110 | if( fileName.left(4) == "http" ) { |
112 | fileName = QFileInfo( fileName ).baseName(); | 111 | fileName = QFileInfo( fileName ).baseName(); |
113 | if ( xineControl->getMetaInfo().isEmpty() ) { | 112 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
114 | tickerText = tr( " File: " ) + fileName; | 113 | tickerText = tr( " File: " ) + fileName; |
115 | } else { | 114 | } else { |
116 | tickerText = xineControl->getMetaInfo(); | 115 | tickerText = xineControl()->getMetaInfo(); |
117 | } | 116 | } |
118 | } else { | 117 | } else { |
119 | if ( xineControl->getMetaInfo().isEmpty() ) { | 118 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 119 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
121 | } else { | 120 | } else { |
122 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 121 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
123 | } | 122 | } |
124 | } | 123 | } |
125 | audioUI->setTickerText( tickerText ); | 124 | audioUI()->setTickerText( tickerText ); |
126 | } | 125 | } |
127 | 126 | ||
128 | 127 | ||
129 | void MediaPlayer::prev() { | 128 | void MediaPlayer::prev() { |
130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 129 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
131 | if ( playList.prev() ) { | 130 | if ( playList.prev() ) { |
132 | play(); | 131 | play(); |
133 | } else if ( mediaPlayerState.isLooping() ) { | 132 | } else if ( mediaPlayerState.isLooping() ) { |
134 | if ( playList.last() ) { | 133 | if ( playList.last() ) { |
135 | play(); | 134 | play(); |
136 | } | 135 | } |
137 | } else { | 136 | } else { |
138 | mediaPlayerState.setList(); | 137 | mediaPlayerState.setList(); |
139 | } | 138 | } |
140 | } | 139 | } |
141 | } | 140 | } |
142 | 141 | ||
143 | 142 | ||
144 | void MediaPlayer::next() { | 143 | void MediaPlayer::next() { |
145 | 144 | ||
146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 145 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
147 | if ( playList.next() ) { | 146 | if ( playList.next() ) { |
148 | play(); | 147 | play(); |
149 | } else if ( mediaPlayerState.isLooping() ) { | 148 | } else if ( mediaPlayerState.isLooping() ) { |
150 | if ( playList.first() ) { | 149 | if ( playList.first() ) { |
151 | play(); | 150 | play(); |
152 | } | 151 | } |
153 | } else { | 152 | } else { |
154 | mediaPlayerState.setList(); | 153 | mediaPlayerState.setList(); |
155 | } | 154 | } |
156 | } else { //if playing from file list, let's just stop | 155 | } else { //if playing from file list, let's just stop |
157 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 156 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
158 | mediaPlayerState.setPlaying(false); | 157 | mediaPlayerState.setPlaying(false); |
159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 158 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
160 | if(l) mediaPlayerState.setLooping(l); | 159 | if(l) mediaPlayerState.setLooping(l); |
161 | if(r) mediaPlayerState.setShuffled(r); | 160 | if(r) mediaPlayerState.setShuffled(r); |
162 | } | 161 | } |
163 | qApp->processEvents(); | 162 | qApp->processEvents(); |
164 | } | 163 | } |
165 | 164 | ||
166 | 165 | ||
167 | void MediaPlayer::startDecreasingVolume() { | 166 | void MediaPlayer::startDecreasingVolume() { |
168 | volumeDirection = -1; | 167 | volumeDirection = -1; |
169 | startTimer( 100 ); | 168 | startTimer( 100 ); |
170 | volControl->decVol(2); | 169 | volControl->decVol(2); |
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
174 | void MediaPlayer::startIncreasingVolume() { | 173 | void MediaPlayer::startIncreasingVolume() { |
175 | volumeDirection = +1; | 174 | volumeDirection = +1; |
176 | startTimer( 100 ); | 175 | startTimer( 100 ); |
177 | volControl->incVol(2); | 176 | volControl->incVol(2); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | bool drawnOnScreenDisplay = FALSE; | 180 | bool drawnOnScreenDisplay = FALSE; |
182 | unsigned int onScreenDisplayVolume = 0; | 181 | unsigned int onScreenDisplayVolume = 0; |
183 | const int yoff = 110; | 182 | const int yoff = 110; |
184 | 183 | ||
185 | void MediaPlayer::stopChangingVolume() { | 184 | void MediaPlayer::stopChangingVolume() { |
186 | killTimers(); | 185 | killTimers(); |
187 | // Get rid of the on-screen display stuff | 186 | // Get rid of the on-screen display stuff |
188 | drawnOnScreenDisplay = FALSE; | 187 | drawnOnScreenDisplay = FALSE; |
189 | onScreenDisplayVolume = 0; | 188 | onScreenDisplayVolume = 0; |
190 | int w=0; | 189 | int w=0; |
191 | int h=0; | 190 | int h=0; |
192 | if( !xineControl->hasVideo() ) { | 191 | if( !xineControl()->hasVideo() ) { |
193 | w = audioUI->width(); | 192 | w = audioUI()->width(); |
194 | h = audioUI->height(); | 193 | h = audioUI()->height(); |
195 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 194 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
196 | } else { | 195 | } else { |
197 | w = videoUI->width(); | 196 | w = videoUI()->width(); |
198 | h = videoUI->height(); | 197 | h = videoUI()->height(); |
199 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 198 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
200 | } | 199 | } |
201 | } | 200 | } |
202 | 201 | ||
203 | 202 | ||
204 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 203 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
205 | if ( volumeDirection == +1 ) { | 204 | if ( volumeDirection == +1 ) { |
206 | volControl->incVol( 2 ); | 205 | volControl->incVol( 2 ); |
207 | } else if ( volumeDirection == -1 ) { | 206 | } else if ( volumeDirection == -1 ) { |
208 | volControl->decVol( 2 ); | 207 | volControl->decVol( 2 ); |
209 | } | 208 | } |
210 | 209 | ||
211 | 210 | ||
212 | // TODO FIXME | 211 | // TODO FIXME |
213 | // huh?? | 212 | // huh?? |
214 | unsigned int v= 0; | 213 | unsigned int v= 0; |
215 | v = volControl->volume(); | 214 | v = volControl->volume(); |
216 | v = v / 10; | 215 | v = v / 10; |
217 | 216 | ||
218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 217 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
219 | return; | 218 | return; |
220 | } | 219 | } |
221 | 220 | ||
222 | int w=0; int h=0; | 221 | int w=0; int h=0; |
223 | if( !xineControl->hasVideo() ) { | 222 | if( !xineControl()->hasVideo() ) { |
224 | w = audioUI->width(); | 223 | w = audioUI()->width(); |
225 | h = audioUI->height(); | 224 | h = audioUI()->height(); |
226 | 225 | ||
227 | if ( drawnOnScreenDisplay ) { | 226 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 227 | if ( onScreenDisplayVolume > v ) { |
229 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 228 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
230 | } | 229 | } |
231 | } | 230 | } |
232 | drawnOnScreenDisplay = TRUE; | 231 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 232 | onScreenDisplayVolume = v; |
234 | QPainter p( audioUI ); | 233 | QPainter p( audioUI() ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 234 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 236 | ||
238 | QFont f; | 237 | QFont f; |
239 | f.setPixelSize( 20 ); | 238 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 239 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 240 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 241 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 242 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 243 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 244 | if ( v > i ) { |
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 245 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 246 | } else { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 247 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 248 | } |
250 | } | 249 | } |
251 | } else { | 250 | } else { |
252 | w = videoUI->width(); | 251 | w = videoUI()->width(); |
253 | h = videoUI->height(); | 252 | h = videoUI()->height(); |
254 | 253 | ||
255 | if ( drawnOnScreenDisplay ) { | 254 | if ( drawnOnScreenDisplay ) { |
256 | if ( onScreenDisplayVolume > v ) { | 255 | if ( onScreenDisplayVolume > v ) { |
257 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 256 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
258 | } | 257 | } |
259 | } | 258 | } |
260 | drawnOnScreenDisplay = TRUE; | 259 | drawnOnScreenDisplay = TRUE; |
261 | onScreenDisplayVolume = v; | 260 | onScreenDisplayVolume = v; |
262 | QPainter p( videoUI ); | 261 | QPainter p( videoUI() ); |
263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 262 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
265 | 264 | ||
266 | QFont f; | 265 | QFont f; |
267 | f.setPixelSize( 20 ); | 266 | f.setPixelSize( 20 ); |
268 | f.setBold( TRUE ); | 267 | f.setBold( TRUE ); |
269 | p.setFont( f ); | 268 | p.setFont( f ); |
270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 269 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
271 | 270 | ||
272 | for ( unsigned int i = 0; i < 10; i++ ) { | 271 | for ( unsigned int i = 0; i < 10; i++ ) { |
273 | if ( v > i ) { | 272 | if ( v > i ) { |
274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 273 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
275 | } else { | 274 | } else { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 275 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
277 | } | 276 | } |
278 | } | 277 | } |
279 | } | 278 | } |
280 | } | 279 | } |
281 | 280 | ||
282 | 281 | ||
283 | void MediaPlayer::blank( bool b ) { | 282 | void MediaPlayer::blank( bool b ) { |
284 | fd=open("/dev/fb0",O_RDWR); | 283 | fd=open("/dev/fb0",O_RDWR); |
285 | #ifdef QT_QWS_EBX | 284 | #ifdef QT_QWS_EBX |
286 | fl= open( "/dev/fl", O_RDWR ); | 285 | fl= open( "/dev/fl", O_RDWR ); |
287 | #endif | 286 | #endif |
288 | if (fd != -1) { | 287 | if (fd != -1) { |
289 | if ( b ) { | 288 | if ( b ) { |
290 | qDebug("do blanking"); | 289 | qDebug("do blanking"); |
291 | #ifdef QT_QWS_EBX | 290 | #ifdef QT_QWS_EBX |
292 | ioctl( fd, FBIOBLANK, 1 ); | 291 | ioctl( fd, FBIOBLANK, 1 ); |
293 | if(fl !=-1) { | 292 | if(fl !=-1) { |
294 | ioctl( fl, 2 ); | 293 | ioctl( fl, 2 ); |
295 | ::close(fl); | 294 | ::close(fl); |
296 | } | 295 | } |
297 | #else | 296 | #else |
298 | ioctl( fd, FBIOBLANK, 3 ); | 297 | ioctl( fd, FBIOBLANK, 3 ); |
299 | #endif | 298 | #endif |
300 | isBlanked = TRUE; | 299 | isBlanked = TRUE; |
301 | } else { | 300 | } else { |
302 | qDebug("do unblanking"); | 301 | qDebug("do unblanking"); |
303 | ioctl( fd, FBIOBLANK, 0); | 302 | ioctl( fd, FBIOBLANK, 0); |
304 | #ifdef QT_QWS_EBX | 303 | #ifdef QT_QWS_EBX |
305 | if(fl != -1) { | 304 | if(fl != -1) { |
306 | ioctl( fl, 1); | 305 | ioctl( fl, 1); |
307 | ::close(fl); | 306 | ::close(fl); |
308 | } | 307 | } |
309 | #endif | 308 | #endif |
310 | isBlanked = FALSE; | 309 | isBlanked = FALSE; |
311 | } | 310 | } |
312 | close( fd ); | 311 | close( fd ); |
313 | } else { | 312 | } else { |
314 | qDebug("<< /dev/fb0 could not be opened >>"); | 313 | qDebug("<< /dev/fb0 could not be opened >>"); |
315 | } | 314 | } |
316 | } | 315 | } |
317 | 316 | ||
318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 317 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
319 | switch ( e->key() ) { | 318 | switch ( e->key() ) { |
320 | ////////////////////////////// Zaurus keys | 319 | ////////////////////////////// Zaurus keys |
321 | case Key_Home: | 320 | case Key_Home: |
322 | break; | 321 | break; |
323 | case Key_F9: //activity | 322 | case Key_F9: //activity |
324 | break; | 323 | break; |
325 | case Key_F10: //contacts | 324 | case Key_F10: //contacts |
326 | break; | 325 | break; |
327 | case Key_F11: //menu | 326 | case Key_F11: //menu |
328 | break; | 327 | break; |
329 | case Key_F12: //home | 328 | case Key_F12: //home |
330 | qDebug("Blank here"); | 329 | qDebug("Blank here"); |
331 | // mediaPlayerState->toggleBlank(); | 330 | // mediaPlayerState->toggleBlank(); |
332 | break; | 331 | break; |
333 | case Key_F13: //mail | 332 | case Key_F13: //mail |
334 | qDebug("Blank here"); | 333 | qDebug("Blank here"); |
335 | // mediaPlayerState->toggleBlank(); | 334 | // mediaPlayerState->toggleBlank(); |
336 | break; | 335 | break; |
337 | } | 336 | } |
338 | } | 337 | } |
339 | 338 | ||
340 | void MediaPlayer::cleanUp() {// this happens on closing | 339 | void MediaPlayer::cleanUp() {// this happens on closing |
341 | Config cfg( "OpiePlayer" ); | 340 | Config cfg( "OpiePlayer" ); |
342 | mediaPlayerState.writeConfig( cfg ); | 341 | mediaPlayerState.writeConfig( cfg ); |
343 | playList.writeDefaultPlaylist( ); | 342 | playList.writeDefaultPlaylist( ); |
344 | 343 | ||
345 | // QPEApplication::grabKeyboard(); | 344 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 345 | // QPEApplication::ungrabKeyboard(); |
347 | } | 346 | } |
348 | 347 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() | 348 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
350 | { | 349 | { |
351 | delete xineControl; | 350 | delete m_xineControl; |
352 | delete audioUI; | 351 | delete m_audioUI; |
353 | delete videoUI; | 352 | delete m_videoUI; |
354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 353 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 354 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 355 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 356 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 357 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 358 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 360 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 361 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 362 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 363 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 365 | ||
367 | xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); | 366 | m_xineControl = new XineControl( m_videoUI->vidWidget(), mediaPlayerState ); |
368 | connect( xineControl, SIGNAL( initialized() ), | 367 | } |
369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); | 368 | |
369 | AudioWidget *MediaPlayer::audioUI() const | ||
370 | { | ||
371 | if ( !m_audioUI ) | ||
372 | recreateAudioAndVideoWidgets(); | ||
373 | return m_audioUI; | ||
374 | } | ||
375 | |||
376 | VideoWidget *MediaPlayer::videoUI() const | ||
377 | { | ||
378 | if ( !m_videoUI ) | ||
379 | recreateAudioAndVideoWidgets(); | ||
380 | return m_videoUI; | ||
381 | } | ||
382 | |||
383 | XineControl *MediaPlayer::xineControl() const | ||
384 | { | ||
385 | if ( !m_xineControl ) | ||
386 | recreateAudioAndVideoWidgets(); | ||
387 | return m_xineControl; | ||
370 | } | 388 | } |
371 | 389 | ||
372 | void MediaPlayer::reloadSkins() | 390 | void MediaPlayer::reloadSkins() |
373 | { | 391 | { |
374 | audioUI->loadSkin(); | 392 | audioUI()->loadSkin(); |
375 | videoUI->loadSkin(); | 393 | videoUI()->loadSkin(); |
376 | } | 394 | } |
377 | 395 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 6b316f6..5975731 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h | |||
@@ -1,90 +1,96 @@ | |||
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 MEDIA_PLAYER_H | 34 | #ifndef MEDIA_PLAYER_H |
35 | #define MEDIA_PLAYER_H | 35 | #define MEDIA_PLAYER_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qframe.h> | 38 | #include <qframe.h> |
39 | 39 | ||
40 | #include "xinecontrol.h" | 40 | #include "xinecontrol.h" |
41 | 41 | ||
42 | #include "playlistwidget.h" | 42 | #include "playlistwidget.h" |
43 | 43 | ||
44 | class DocLnk; | 44 | class DocLnk; |
45 | class VolumeControl; | 45 | class VolumeControl; |
46 | class MediaPlayerState; | 46 | class MediaPlayerState; |
47 | class AudioWidget; | 47 | class AudioWidget; |
48 | class VideoWidget; | 48 | class VideoWidget; |
49 | 49 | ||
50 | class MediaPlayer : public QObject { | 50 | class MediaPlayer : public QObject { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); | 53 | MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ); |
54 | ~MediaPlayer(); | 54 | ~MediaPlayer(); |
55 | 55 | ||
56 | public slots: | 56 | public slots: |
57 | void recreateAudioAndVideoWidgets(); | ||
58 | void reloadSkins(); | 57 | void reloadSkins(); |
59 | 58 | ||
60 | private slots: | 59 | private slots: |
61 | void setPlaying( bool ); | 60 | void setPlaying( bool ); |
62 | void pauseCheck( bool ); | 61 | void pauseCheck( bool ); |
63 | void play(); | 62 | void play(); |
64 | void next(); | 63 | void next(); |
65 | void prev(); | 64 | void prev(); |
66 | void startIncreasingVolume(); | 65 | void startIncreasingVolume(); |
67 | void startDecreasingVolume(); | 66 | void startDecreasingVolume(); |
68 | void stopChangingVolume(); | 67 | void stopChangingVolume(); |
69 | void cleanUp(); | 68 | void cleanUp(); |
70 | void blank( bool ); | 69 | void blank( bool ); |
71 | 70 | ||
72 | protected: | 71 | protected: |
73 | void timerEvent( QTimerEvent *e ); | 72 | void timerEvent( QTimerEvent *e ); |
74 | void keyReleaseEvent( QKeyEvent *e); | 73 | void keyReleaseEvent( QKeyEvent *e); |
74 | |||
75 | private: | 75 | private: |
76 | AudioWidget *audioUI() const; | ||
77 | VideoWidget *videoUI() const; | ||
78 | XineControl *xineControl() const; | ||
76 | 79 | ||
77 | bool isBlanked, l, r; | 80 | bool isBlanked, l, r; |
78 | int fd, fl; | 81 | int fd, fl; |
79 | int volumeDirection; | 82 | int volumeDirection; |
80 | XineControl *xineControl; | ||
81 | VolumeControl *volControl; | 83 | VolumeControl *volControl; |
82 | MediaPlayerState &mediaPlayerState; | 84 | MediaPlayerState &mediaPlayerState; |
83 | PlayListWidget &playList; | 85 | PlayListWidget &playList; |
84 | AudioWidget *audioUI; | 86 | |
85 | VideoWidget *videoUI; | 87 | void recreateAudioAndVideoWidgets() const; |
88 | |||
89 | mutable XineControl *m_xineControl; | ||
90 | mutable AudioWidget *m_audioUI; | ||
91 | mutable VideoWidget *m_videoUI; | ||
86 | }; | 92 | }; |
87 | 93 | ||
88 | 94 | ||
89 | #endif // MEDIA_PLAYER_H | 95 | #endif // MEDIA_PLAYER_H |
90 | 96 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index d54d870..40fa1a4 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,277 +1,264 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/qlibrary.h> | 37 | #include <qpe/qlibrary.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include "mediaplayerstate.h" | 42 | #include "mediaplayerstate.h" |
43 | 43 | ||
44 | #include <assert.h> | 44 | #include <assert.h> |
45 | 45 | ||
46 | //#define MediaPlayerDebug(x) qDebug x | 46 | //#define MediaPlayerDebug(x) qDebug x |
47 | #define MediaPlayerDebug(x) | 47 | #define MediaPlayerDebug(x) |
48 | 48 | ||
49 | 49 | ||
50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
51 | : QObject( parent, name ) { | 51 | : QObject( parent, name ) { |
52 | Config cfg( "OpiePlayer" ); | 52 | Config cfg( "OpiePlayer" ); |
53 | readConfig( cfg ); | 53 | readConfig( cfg ); |
54 | streaming = false; | 54 | streaming = false; |
55 | seekable = true; | 55 | seekable = true; |
56 | backendInitialized = false; | ||
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | MediaPlayerState::~MediaPlayerState() { | 59 | MediaPlayerState::~MediaPlayerState() { |
61 | } | 60 | } |
62 | 61 | ||
63 | 62 | ||
64 | void MediaPlayerState::readConfig( Config& cfg ) { | 63 | void MediaPlayerState::readConfig( Config& cfg ) { |
65 | cfg.setGroup("Options"); | 64 | cfg.setGroup("Options"); |
66 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
67 | scaled = cfg.readBoolEntry( "Scaling" ); | 66 | scaled = cfg.readBoolEntry( "Scaling" ); |
68 | looping = cfg.readBoolEntry( "Looping" ); | 67 | looping = cfg.readBoolEntry( "Looping" ); |
69 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 68 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
70 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
71 | playing = FALSE; | 70 | playing = FALSE; |
72 | streaming = FALSE; | 71 | streaming = FALSE; |
73 | paused = FALSE; | 72 | paused = FALSE; |
74 | curPosition = 0; | 73 | curPosition = 0; |
75 | curLength = 0; | 74 | curLength = 0; |
76 | m_displayType = MediaSelection; | 75 | m_displayType = MediaSelection; |
77 | } | 76 | } |
78 | 77 | ||
79 | 78 | ||
80 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 79 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
81 | cfg.setGroup( "Options" ); | 80 | cfg.setGroup( "Options" ); |
82 | cfg.writeEntry( "FullScreen", fullscreen ); | 81 | cfg.writeEntry( "FullScreen", fullscreen ); |
83 | cfg.writeEntry( "Scaling", scaled ); | 82 | cfg.writeEntry( "Scaling", scaled ); |
84 | cfg.writeEntry( "Looping", looping ); | 83 | cfg.writeEntry( "Looping", looping ); |
85 | cfg.writeEntry( "Shuffle", shuffled ); | 84 | cfg.writeEntry( "Shuffle", shuffled ); |
86 | cfg.writeEntry( "VideoGamma", videoGamma ); | 85 | cfg.writeEntry( "VideoGamma", videoGamma ); |
87 | } | 86 | } |
88 | 87 | ||
89 | bool MediaPlayerState::isInitialized() const | ||
90 | { | ||
91 | return backendInitialized; // for now, more to come (skin stuff) | ||
92 | } | ||
93 | |||
94 | void MediaPlayerState::setBackendInitialized() | ||
95 | { | ||
96 | assert( backendInitialized == false ); | ||
97 | backendInitialized = true; | ||
98 | emit initialized(); | ||
99 | } | ||
100 | |||
101 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const | 88 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const |
102 | { | 89 | { |
103 | return m_displayType; | 90 | return m_displayType; |
104 | } | 91 | } |
105 | 92 | ||
106 | // slots | 93 | // slots |
107 | void MediaPlayerState::setIsStreaming( bool b ) { | 94 | void MediaPlayerState::setIsStreaming( bool b ) { |
108 | streaming = b; | 95 | streaming = b; |
109 | } | 96 | } |
110 | 97 | ||
111 | void MediaPlayerState::setIsSeekable( bool b ) { | 98 | void MediaPlayerState::setIsSeekable( bool b ) { |
112 | seekable = b; | 99 | seekable = b; |
113 | emit isSeekableToggled(b); | 100 | emit isSeekableToggled(b); |
114 | } | 101 | } |
115 | 102 | ||
116 | 103 | ||
117 | void MediaPlayerState::setFullscreen( bool b ) { | 104 | void MediaPlayerState::setFullscreen( bool b ) { |
118 | if ( fullscreen == b ) { | 105 | if ( fullscreen == b ) { |
119 | return; | 106 | return; |
120 | } | 107 | } |
121 | fullscreen = b; | 108 | fullscreen = b; |
122 | emit fullscreenToggled(b); | 109 | emit fullscreenToggled(b); |
123 | } | 110 | } |
124 | 111 | ||
125 | 112 | ||
126 | void MediaPlayerState::setBlanked( bool b ) { | 113 | void MediaPlayerState::setBlanked( bool b ) { |
127 | if ( blanked == b ) { | 114 | if ( blanked == b ) { |
128 | return; | 115 | return; |
129 | } | 116 | } |
130 | blanked = b; | 117 | blanked = b; |
131 | emit blankToggled(b); | 118 | emit blankToggled(b); |
132 | } | 119 | } |
133 | 120 | ||
134 | 121 | ||
135 | void MediaPlayerState::setScaled( bool b ) { | 122 | void MediaPlayerState::setScaled( bool b ) { |
136 | if ( scaled == b ) { | 123 | if ( scaled == b ) { |
137 | return; | 124 | return; |
138 | } | 125 | } |
139 | scaled = b; | 126 | scaled = b; |
140 | emit scaledToggled(b); | 127 | emit scaledToggled(b); |
141 | } | 128 | } |
142 | 129 | ||
143 | void MediaPlayerState::setLooping( bool b ) { | 130 | void MediaPlayerState::setLooping( bool b ) { |
144 | if ( looping == b ) { | 131 | if ( looping == b ) { |
145 | return; | 132 | return; |
146 | } | 133 | } |
147 | looping = b; | 134 | looping = b; |
148 | emit loopingToggled(b); | 135 | emit loopingToggled(b); |
149 | } | 136 | } |
150 | 137 | ||
151 | void MediaPlayerState::setShuffled( bool b ) { | 138 | void MediaPlayerState::setShuffled( bool b ) { |
152 | if ( shuffled == b ) { | 139 | if ( shuffled == b ) { |
153 | return; | 140 | return; |
154 | } | 141 | } |
155 | shuffled = b; | 142 | shuffled = b; |
156 | emit shuffledToggled(b); | 143 | emit shuffledToggled(b); |
157 | } | 144 | } |
158 | 145 | ||
159 | void MediaPlayerState::setPaused( bool b ) { | 146 | void MediaPlayerState::setPaused( bool b ) { |
160 | if ( paused == b ) { | 147 | if ( paused == b ) { |
161 | paused = FALSE; | 148 | paused = FALSE; |
162 | emit pausedToggled(FALSE); | 149 | emit pausedToggled(FALSE); |
163 | return; | 150 | return; |
164 | } | 151 | } |
165 | paused = b; | 152 | paused = b; |
166 | emit pausedToggled(b); | 153 | emit pausedToggled(b); |
167 | } | 154 | } |
168 | 155 | ||
169 | void MediaPlayerState::setPlaying( bool b ) { | 156 | void MediaPlayerState::setPlaying( bool b ) { |
170 | if ( playing == b ) { | 157 | if ( playing == b ) { |
171 | return; | 158 | return; |
172 | } | 159 | } |
173 | playing = b; | 160 | playing = b; |
174 | stopped = !b; | 161 | stopped = !b; |
175 | emit playingToggled(b); | 162 | emit playingToggled(b); |
176 | } | 163 | } |
177 | 164 | ||
178 | void MediaPlayerState::setStopped( bool b ) { | 165 | void MediaPlayerState::setStopped( bool b ) { |
179 | if ( stopped == b ) { | 166 | if ( stopped == b ) { |
180 | return; | 167 | return; |
181 | } | 168 | } |
182 | stopped = b; | 169 | stopped = b; |
183 | emit stopToggled(b); | 170 | emit stopToggled(b); |
184 | } | 171 | } |
185 | 172 | ||
186 | void MediaPlayerState::setPosition( long p ) { | 173 | void MediaPlayerState::setPosition( long p ) { |
187 | if ( curPosition == p ) { | 174 | if ( curPosition == p ) { |
188 | return; | 175 | return; |
189 | } | 176 | } |
190 | curPosition = p; | 177 | curPosition = p; |
191 | emit positionChanged(p); | 178 | emit positionChanged(p); |
192 | } | 179 | } |
193 | 180 | ||
194 | void MediaPlayerState::updatePosition( long p ){ | 181 | void MediaPlayerState::updatePosition( long p ){ |
195 | if ( curPosition == p ) { | 182 | if ( curPosition == p ) { |
196 | return; | 183 | return; |
197 | } | 184 | } |
198 | curPosition = p; | 185 | curPosition = p; |
199 | emit positionUpdated(p); | 186 | emit positionUpdated(p); |
200 | } | 187 | } |
201 | 188 | ||
202 | void MediaPlayerState::setVideoGamma( int v ){ | 189 | void MediaPlayerState::setVideoGamma( int v ){ |
203 | if ( videoGamma == v ) { | 190 | if ( videoGamma == v ) { |
204 | return; | 191 | return; |
205 | } | 192 | } |
206 | videoGamma = v; | 193 | videoGamma = v; |
207 | emit videoGammaChanged( v ); | 194 | emit videoGammaChanged( v ); |
208 | } | 195 | } |
209 | 196 | ||
210 | void MediaPlayerState::setLength( long l ) { | 197 | void MediaPlayerState::setLength( long l ) { |
211 | if ( curLength == l ) { | 198 | if ( curLength == l ) { |
212 | return; | 199 | return; |
213 | } | 200 | } |
214 | curLength = l; | 201 | curLength = l; |
215 | emit lengthChanged(l); | 202 | emit lengthChanged(l); |
216 | } | 203 | } |
217 | 204 | ||
218 | void MediaPlayerState::setDisplayType( DisplayType displayType ) | 205 | void MediaPlayerState::setDisplayType( DisplayType displayType ) |
219 | { | 206 | { |
220 | if ( m_displayType == displayType ) | 207 | if ( m_displayType == displayType ) |
221 | return; | 208 | return; |
222 | 209 | ||
223 | m_displayType = displayType; | 210 | m_displayType = displayType; |
224 | emit displayTypeChanged( m_displayType ); | 211 | emit displayTypeChanged( m_displayType ); |
225 | } | 212 | } |
226 | 213 | ||
227 | void MediaPlayerState::setPrev(){ | 214 | void MediaPlayerState::setPrev(){ |
228 | emit prev(); | 215 | emit prev(); |
229 | } | 216 | } |
230 | 217 | ||
231 | void MediaPlayerState::setNext() { | 218 | void MediaPlayerState::setNext() { |
232 | emit next(); | 219 | emit next(); |
233 | } | 220 | } |
234 | 221 | ||
235 | void MediaPlayerState::setList() { | 222 | void MediaPlayerState::setList() { |
236 | setPlaying( FALSE ); | 223 | setPlaying( FALSE ); |
237 | setDisplayType( MediaSelection ); | 224 | setDisplayType( MediaSelection ); |
238 | } | 225 | } |
239 | 226 | ||
240 | void MediaPlayerState::setVideo() { | 227 | void MediaPlayerState::setVideo() { |
241 | setDisplayType( Video ); | 228 | setDisplayType( Video ); |
242 | } | 229 | } |
243 | 230 | ||
244 | void MediaPlayerState::setAudio() { | 231 | void MediaPlayerState::setAudio() { |
245 | setDisplayType( Audio ); | 232 | setDisplayType( Audio ); |
246 | } | 233 | } |
247 | 234 | ||
248 | void MediaPlayerState::toggleFullscreen() { | 235 | void MediaPlayerState::toggleFullscreen() { |
249 | setFullscreen( !fullscreen ); | 236 | setFullscreen( !fullscreen ); |
250 | } | 237 | } |
251 | 238 | ||
252 | void MediaPlayerState::toggleScaled() { | 239 | void MediaPlayerState::toggleScaled() { |
253 | setScaled( !scaled); | 240 | setScaled( !scaled); |
254 | } | 241 | } |
255 | 242 | ||
256 | void MediaPlayerState::toggleLooping() { | 243 | void MediaPlayerState::toggleLooping() { |
257 | setLooping( !looping); | 244 | setLooping( !looping); |
258 | } | 245 | } |
259 | 246 | ||
260 | void MediaPlayerState::toggleShuffled() { | 247 | void MediaPlayerState::toggleShuffled() { |
261 | setShuffled( !shuffled); | 248 | setShuffled( !shuffled); |
262 | } | 249 | } |
263 | 250 | ||
264 | void MediaPlayerState::togglePaused() { | 251 | void MediaPlayerState::togglePaused() { |
265 | setPaused( !paused); | 252 | setPaused( !paused); |
266 | } | 253 | } |
267 | 254 | ||
268 | void MediaPlayerState::togglePlaying() { | 255 | void MediaPlayerState::togglePlaying() { |
269 | setPlaying( !playing); | 256 | setPlaying( !playing); |
270 | } | 257 | } |
271 | 258 | ||
272 | void MediaPlayerState::toggleBlank() { | 259 | void MediaPlayerState::toggleBlank() { |
273 | setBlanked( !blanked); | 260 | setBlanked( !blanked); |
274 | } | 261 | } |
275 | 262 | ||
276 | 263 | ||
277 | 264 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 6fe6d76..7408fdc 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,146 +1,140 @@ | |||
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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #ifndef MEDIA_PLAYER_STATE_H | 36 | #ifndef MEDIA_PLAYER_STATE_H |
37 | #define MEDIA_PLAYER_STATE_H | 37 | #define MEDIA_PLAYER_STATE_H |
38 | 38 | ||
39 | 39 | ||
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | 41 | ||
42 | 42 | ||
43 | class MediaPlayerDecoder; | 43 | class MediaPlayerDecoder; |
44 | class Config; | 44 | class Config; |
45 | 45 | ||
46 | 46 | ||
47 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | enum DisplayType { Audio, Video, MediaSelection }; | 50 | enum DisplayType { Audio, Video, MediaSelection }; |
51 | 51 | ||
52 | MediaPlayerState( QObject *parent, const char *name ); | 52 | MediaPlayerState( QObject *parent, const char *name ); |
53 | ~MediaPlayerState(); | 53 | ~MediaPlayerState(); |
54 | 54 | ||
55 | bool isStreaming() const { return streaming; } | 55 | bool isStreaming() const { return streaming; } |
56 | bool isSeekable() const { return seekable; } | 56 | bool isSeekable() const { return seekable; } |
57 | bool isFullscreen() const { return fullscreen; } | 57 | bool isFullscreen() const { return fullscreen; } |
58 | bool isScaled() const { return scaled; } | 58 | bool isScaled() const { return scaled; } |
59 | bool isLooping() const { return looping; } | 59 | bool isLooping() const { return looping; } |
60 | bool isShuffled() const { return shuffled; } | 60 | bool isShuffled() const { return shuffled; } |
61 | bool isPaused() const { return paused; } | 61 | bool isPaused() const { return paused; } |
62 | bool isPlaying() const { return playing; } | 62 | bool isPlaying() const { return playing; } |
63 | bool isStopped() const { return stopped; } | 63 | bool isStopped() const { return stopped; } |
64 | bool isInitialized() const; | ||
65 | long position() const { return curPosition; } | 64 | long position() const { return curPosition; } |
66 | long length() const { return curLength; } | 65 | long length() const { return curLength; } |
67 | DisplayType displayType() const; | 66 | DisplayType displayType() const; |
68 | 67 | ||
69 | public slots: | 68 | public slots: |
70 | void setIsStreaming( bool b ); | 69 | void setIsStreaming( bool b ); |
71 | void setIsSeekable( bool b ); | 70 | void setIsSeekable( bool b ); |
72 | void setFullscreen( bool b ); | 71 | void setFullscreen( bool b ); |
73 | void setScaled( bool b ); | 72 | void setScaled( bool b ); |
74 | void setLooping( bool b ); | 73 | void setLooping( bool b ); |
75 | void setShuffled( bool b ); | 74 | void setShuffled( bool b ); |
76 | void setPaused( bool b ); | 75 | void setPaused( bool b ); |
77 | void setPlaying( bool b ); | 76 | void setPlaying( bool b ); |
78 | void setStopped( bool b ); | 77 | void setStopped( bool b ); |
79 | void setPosition( long p ); | 78 | void setPosition( long p ); |
80 | void updatePosition( long p ); | 79 | void updatePosition( long p ); |
81 | void setLength( long l ); | 80 | void setLength( long l ); |
82 | void setDisplayType( MediaPlayerState::DisplayType displayType ); | 81 | void setDisplayType( MediaPlayerState::DisplayType displayType ); |
83 | void setBlanked( bool b ); | 82 | void setBlanked( bool b ); |
84 | void setVideoGamma( int v ); | 83 | void setVideoGamma( int v ); |
85 | 84 | ||
86 | void setPrev(); | 85 | void setPrev(); |
87 | void setNext(); | 86 | void setNext(); |
88 | void setList(); | 87 | void setList(); |
89 | void setVideo(); | 88 | void setVideo(); |
90 | void setAudio(); | 89 | void setAudio(); |
91 | 90 | ||
92 | void toggleFullscreen(); | 91 | void toggleFullscreen(); |
93 | void toggleScaled(); | 92 | void toggleScaled(); |
94 | void toggleLooping(); | 93 | void toggleLooping(); |
95 | void toggleShuffled(); | 94 | void toggleShuffled(); |
96 | void togglePaused(); | 95 | void togglePaused(); |
97 | void togglePlaying(); | 96 | void togglePlaying(); |
98 | void toggleBlank(); | 97 | void toggleBlank(); |
99 | void writeConfig( Config& cfg ) const; | 98 | void writeConfig( Config& cfg ) const; |
100 | 99 | ||
101 | void setBackendInitialized(); | ||
102 | |||
103 | signals: | 100 | signals: |
104 | void fullscreenToggled( bool ); | 101 | void fullscreenToggled( bool ); |
105 | void scaledToggled( bool ); | 102 | void scaledToggled( bool ); |
106 | void loopingToggled( bool ); | 103 | void loopingToggled( bool ); |
107 | void shuffledToggled( bool ); | 104 | void shuffledToggled( bool ); |
108 | void pausedToggled( bool ); | 105 | void pausedToggled( bool ); |
109 | void playingToggled( bool ); | 106 | void playingToggled( bool ); |
110 | void stopToggled( bool ); | 107 | void stopToggled( bool ); |
111 | void positionChanged( long ); // When the slider is moved | 108 | void positionChanged( long ); // When the slider is moved |
112 | void positionUpdated( long ); // When the media file progresses | 109 | void positionUpdated( long ); // When the media file progresses |
113 | void lengthChanged( long ); | 110 | void lengthChanged( long ); |
114 | void displayTypeChanged( MediaPlayerState::DisplayType type ); | 111 | void displayTypeChanged( MediaPlayerState::DisplayType type ); |
115 | void isSeekableToggled( bool ); | 112 | void isSeekableToggled( bool ); |
116 | void blankToggled( bool ); | 113 | void blankToggled( bool ); |
117 | void videoGammaChanged( int ); | 114 | void videoGammaChanged( int ); |
118 | void prev(); | 115 | void prev(); |
119 | void next(); | 116 | void next(); |
120 | 117 | ||
121 | void initialized(); | ||
122 | |||
123 | private: | 118 | private: |
124 | bool streaming : 1; | 119 | bool streaming : 1; |
125 | bool seekable : 1; | 120 | bool seekable : 1; |
126 | bool fullscreen: 1; | 121 | bool fullscreen: 1; |
127 | bool scaled : 1; | 122 | bool scaled : 1; |
128 | bool blanked : 1; | 123 | bool blanked : 1; |
129 | bool looping : 1; | 124 | bool looping : 1; |
130 | bool shuffled : 1; | 125 | bool shuffled : 1; |
131 | bool usePlaylist : 1; | 126 | bool usePlaylist : 1; |
132 | bool paused : 1; | 127 | bool paused : 1; |
133 | bool playing : 1; | 128 | bool playing : 1; |
134 | bool stopped : 1; | 129 | bool stopped : 1; |
135 | bool backendInitialized : 1; | ||
136 | long curPosition; | 130 | long curPosition; |
137 | long curLength; | 131 | long curLength; |
138 | DisplayType m_displayType; | 132 | DisplayType m_displayType; |
139 | int videoGamma; | 133 | int videoGamma; |
140 | void readConfig( Config& cfg ); | 134 | void readConfig( Config& cfg ); |
141 | 135 | ||
142 | }; | 136 | }; |
143 | 137 | ||
144 | 138 | ||
145 | #endif // MEDIA_PLAYER_STATE_H | 139 | #endif // MEDIA_PLAYER_STATE_H |
146 | 140 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 8e4f56d..c35e03d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,324 +1,324 @@ | |||
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 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | #include "playlistfileview.h" | 52 | #include "playlistfileview.h" |
53 | 53 | ||
54 | //only needed for the random play | 54 | //only needed for the random play |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <assert.h> | 56 | #include <assert.h> |
57 | 57 | ||
58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 58 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) | 59 | : PlayListWidgetGui( mediaPlayerState, parent, name ) , currentFileListView( 0 ) |
60 | { | 60 | { |
61 | 61 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new PlayButton( mediaPlayerState, bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
69 | this , SLOT( btnPlay( bool) ), TRUE ); | 69 | this , SLOT( btnPlay( bool) ), TRUE ); |
70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 71 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 73 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
74 | 74 | ||
75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
77 | this, SLOT( addAllMusicToList() ) ); | 77 | this, SLOT( addAllMusicToList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
79 | this, SLOT( addAllVideoToList() ) ); | 79 | this, SLOT( addAllVideoToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
81 | this, SLOT( addAllToList() ) ); | 81 | this, SLOT( addAllToList() ) ); |
82 | pmPlayList->insertSeparator(-1); | 82 | pmPlayList->insertSeparator(-1); |
83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 83 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
84 | // this, SLOT( saveList() ) ); | 84 | // this, SLOT( saveList() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
89 | this,SLOT( openFile() ) ); | 89 | this,SLOT( openFile() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 92 | audioView, SLOT( scanFiles() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
94 | videoView, SLOT( scanFiles() ) ); | 94 | videoView, SLOT( scanFiles() ) ); |
95 | 95 | ||
96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
98 | 98 | ||
99 | Config cfg( "OpiePlayer" ); | 99 | Config cfg( "OpiePlayer" ); |
100 | bool b= cfg.readBoolEntry("FullScreen", 0); | 100 | bool b= cfg.readBoolEntry("FullScreen", 0); |
101 | mediaPlayerState.setFullscreen( b ); | 101 | mediaPlayerState.setFullscreen( b ); |
102 | pmView->setItemChecked( -16, b ); | 102 | pmView->setItemChecked( -16, b ); |
103 | 103 | ||
104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
107 | d->selectedFiles, SLOT(removeSelected() ) ); | 107 | d->selectedFiles, SLOT(removeSelected() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
110 | // QVBox *stretch2 = new QVBox( vbox1 ); | 110 | // QVBox *stretch2 = new QVBox( vbox1 ); |
111 | 111 | ||
112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
113 | SLOT( deletePlaylist() ) ); | 113 | SLOT( deletePlaylist() ) ); |
114 | connect( pmView, SIGNAL( activated( int ) ), | 114 | connect( pmView, SIGNAL( activated( int ) ), |
115 | this, SLOT( pmViewActivated( int ) ) ); | 115 | this, SLOT( pmViewActivated( int ) ) ); |
116 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 116 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
117 | this, SLOT( skinsMenuActivated( int ) ) ); | 117 | this, SLOT( skinsMenuActivated( int ) ) ); |
118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 119 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 120 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 121 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 122 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
123 | this,SLOT( playIt( QListViewItem *) ) ); | 123 | this,SLOT( playIt( QListViewItem *) ) ); |
124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 124 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
125 | this, SLOT( addToSelection( QListViewItem *) ) ); | 125 | this, SLOT( addToSelection( QListViewItem *) ) ); |
126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 132 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
133 | this, SLOT( loadList( const DocLnk & ) ) ); | 133 | this, SLOT( loadList( const DocLnk & ) ) ); |
134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
135 | this, SLOT( tabChanged( QWidget* ) ) ); | 135 | this, SLOT( tabChanged( QWidget* ) ) ); |
136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 136 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
137 | d->tbPlay, SLOT( setOn( bool ) ) ); | 137 | d->tbPlay, SLOT( setOn( bool ) ) ); |
138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 138 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
139 | d->tbLoop, SLOT( setOn( bool ) ) ); | 139 | d->tbLoop, SLOT( setOn( bool ) ) ); |
140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 140 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
141 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 141 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
143 | this, SLOT( playIt( QListViewItem *) ) ); | 143 | this, SLOT( playIt( QListViewItem *) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 145 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
146 | 146 | ||
147 | // see which skins are installed | 147 | // see which skins are installed |
148 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
149 | initializeStates(); | 149 | initializeStates(); |
150 | 150 | ||
151 | cfg.setGroup("PlayList"); | 151 | cfg.setGroup("PlayList"); |
152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 152 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
153 | loadList(DocLnk( currentPlaylist ) ); | 153 | loadList(DocLnk( currentPlaylist ) ); |
154 | 154 | ||
155 | tabWidget->showPage( playListTab ); | 155 | tabWidget->showPage( playListTab ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | PlayListWidget::~PlayListWidget() { | 159 | PlayListWidget::~PlayListWidget() { |
160 | delete d; | 160 | delete d; |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | void PlayListWidget::initializeStates() { | 164 | void PlayListWidget::initializeStates() { |
165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
168 | d->playListFrame->show(); | 168 | d->playListFrame->show(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void PlayListWidget::writeDefaultPlaylist() { | 171 | void PlayListWidget::writeDefaultPlaylist() { |
172 | 172 | ||
173 | Config config( "OpiePlayer" ); | 173 | Config config( "OpiePlayer" ); |
174 | config.setGroup( "PlayList" ); | 174 | config.setGroup( "PlayList" ); |
175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
177 | if( currentString == filename) { | 177 | if( currentString == filename) { |
178 | Om3u *m3uList; | 178 | Om3u *m3uList; |
179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
180 | if( d->selectedFiles->first() ) { | 180 | if( d->selectedFiles->first() ) { |
181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
182 | do { | 182 | do { |
183 | // qDebug(d->selectedFiles->current()->file()); | 183 | // qDebug(d->selectedFiles->current()->file()); |
184 | m3uList->add( d->selectedFiles->current()->file() ); | 184 | m3uList->add( d->selectedFiles->current()->file() ); |
185 | } | 185 | } |
186 | while ( d->selectedFiles->next() ); | 186 | while ( d->selectedFiles->next() ); |
187 | 187 | ||
188 | m3uList->write(); | 188 | m3uList->write(); |
189 | m3uList->close(); | 189 | m3uList->close(); |
190 | delete m3uList; | 190 | delete m3uList; |
191 | 191 | ||
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
197 | d->setDocumentUsed = FALSE; | 197 | d->setDocumentUsed = FALSE; |
198 | if( QFileInfo( lnk.file() ).exists() || | 198 | if( QFileInfo( lnk.file() ).exists() || |
199 | lnk.file().left(4) == "http" ) { | 199 | lnk.file().left(4) == "http" ) { |
200 | d->selectedFiles->addToSelection( lnk ); | 200 | d->selectedFiles->addToSelection( lnk ); |
201 | } | 201 | } |
202 | // writeCurrentM3u(); | 202 | // writeCurrentM3u(); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void PlayListWidget::clearList() { | 206 | void PlayListWidget::clearList() { |
207 | while ( first() ) { | 207 | while ( first() ) { |
208 | d->selectedFiles->removeSelected(); | 208 | d->selectedFiles->removeSelected(); |
209 | } | 209 | } |
210 | Config cfg( "OpiePlayer" ); | 210 | Config cfg( "OpiePlayer" ); |
211 | cfg.setGroup("PlayList"); | 211 | cfg.setGroup("PlayList"); |
212 | cfg.writeEntry("CurrentPlaylist","default"); | 212 | cfg.writeEntry("CurrentPlaylist","default"); |
213 | setCaption("OpiePlayer"); | 213 | setCaption("OpiePlayer"); |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case LeftButton: | 218 | case LeftButton: |
219 | break; | 219 | break; |
220 | case RightButton: | 220 | case RightButton: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case LeftButton: | 234 | case LeftButton: |
235 | break; | 235 | break; |
236 | case RightButton: | 236 | case RightButton: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
292 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
293 | // } | 293 | // } |
294 | // } | 294 | // } |
295 | 295 | ||
296 | // qDebug("elapsed time %d", t.elapsed() ); | 296 | // qDebug("elapsed time %d", t.elapsed() ); |
297 | 297 | ||
298 | tabWidget->setCurrentPage(0); | 298 | tabWidget->setCurrentPage(0); |
299 | 299 | ||
300 | writeCurrentM3u(); | 300 | writeCurrentM3u(); |
301 | d->selectedFiles->first(); | 301 | d->selectedFiles->first(); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void PlayListWidget::addAllMusicToList() { | 305 | void PlayListWidget::addAllMusicToList() { |
306 | 306 | ||
307 | audioView->populateView(); | 307 | audioView->populateView(); |
308 | 308 | ||
309 | QListViewItemIterator audioIt( audioView ); | 309 | QListViewItemIterator audioIt( audioView ); |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | QString filename; | 311 | QString filename; |
312 | // iterate through all items of the listview | 312 | // iterate through all items of the listview |
313 | for ( ; audioIt.current(); ++audioIt ) { | 313 | for ( ; audioIt.current(); ++audioIt ) { |
314 | filename = audioIt.current()->text(3); | 314 | filename = audioIt.current()->text(3); |
315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
316 | lnk.setFile( filename ); //sets file name | 316 | lnk.setFile( filename ); //sets file name |
317 | d->selectedFiles->addToSelection( lnk); | 317 | d->selectedFiles->addToSelection( lnk); |
318 | } | 318 | } |
319 | 319 | ||
320 | /* if(!audioScan) | 320 | /* if(!audioScan) |
321 | scanForAudio(); | 321 | scanForAudio(); |
322 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
323 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 23b7a70..5fc0c39 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,228 +1,206 @@ | |||
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 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
39 | #include <qpe/mimetype.h> | 39 | #include <qpe/mimetype.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qcursor.h> | 46 | #include <qcursor.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | 49 | ||
50 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
54 | #include "playlistfileview.h" | 54 | #include "playlistfileview.h" |
55 | 55 | ||
56 | //only needed for the random play | 56 | //only needed for the random play |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) | 61 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) |
62 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { | 62 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { |
63 | 63 | ||
64 | d = new PlayListWidgetPrivate; | 64 | d = new PlayListWidgetPrivate; |
65 | d->setDocumentUsed = FALSE; | 65 | d->setDocumentUsed = FALSE; |
66 | 66 | ||
67 | setBackgroundMode( PaletteButton ); | 67 | setBackgroundMode( PaletteButton ); |
68 | setToolBarsMovable( FALSE ); | 68 | setToolBarsMovable( FALSE ); |
69 | 69 | ||
70 | // Create Toolbar | 70 | // Create Toolbar |
71 | QPEToolBar *toolbar = new QPEToolBar( this ); | 71 | QPEToolBar *toolbar = new QPEToolBar( this ); |
72 | toolbar->setHorizontalStretchable( TRUE ); | 72 | toolbar->setHorizontalStretchable( TRUE ); |
73 | 73 | ||
74 | // Create Menubar | 74 | // Create Menubar |
75 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 75 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
76 | menu->setMargin( 0 ); | 76 | menu->setMargin( 0 ); |
77 | 77 | ||
78 | bar = new QPEToolBar( this ); | 78 | bar = new QPEToolBar( this ); |
79 | bar->setLabel( tr( "Play Operations" ) ); | 79 | bar->setLabel( tr( "Play Operations" ) ); |
80 | 80 | ||
81 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 81 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
82 | tbDeletePlaylist->setFlat( TRUE ); | 82 | tbDeletePlaylist->setFlat( TRUE ); |
83 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 83 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
84 | 84 | ||
85 | tbDeletePlaylist->hide(); | 85 | tbDeletePlaylist->hide(); |
86 | 86 | ||
87 | pmPlayList = new QPopupMenu( this ); | 87 | pmPlayList = new QPopupMenu( this ); |
88 | menu->insertItem( tr( "File" ), pmPlayList ); | 88 | menu->insertItem( tr( "File" ), pmPlayList ); |
89 | 89 | ||
90 | pmView = new QPopupMenu( this ); | 90 | pmView = new QPopupMenu( this ); |
91 | menu->insertItem( tr( "View" ), pmView ); | 91 | menu->insertItem( tr( "View" ), pmView ); |
92 | pmView->isCheckable(); | 92 | pmView->isCheckable(); |
93 | 93 | ||
94 | skinsMenu = new QPopupMenu( this ); | 94 | skinsMenu = new QPopupMenu( this ); |
95 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 95 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
96 | skinsMenu->isCheckable(); | 96 | skinsMenu->isCheckable(); |
97 | 97 | ||
98 | gammaMenu = new QPopupMenu( this ); | 98 | gammaMenu = new QPopupMenu( this ); |
99 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 99 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
100 | 100 | ||
101 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 101 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
102 | gammaSlider->setRange( -40, 40 ); | 102 | gammaSlider->setRange( -40, 40 ); |
103 | gammaSlider->setTickmarks( QSlider::Left ); | 103 | gammaSlider->setTickmarks( QSlider::Left ); |
104 | gammaSlider->setTickInterval( 20 ); | 104 | gammaSlider->setTickInterval( 20 ); |
105 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 105 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
106 | gammaSlider->setValue( 0 ); | 106 | gammaSlider->setValue( 0 ); |
107 | gammaSlider->setMinimumHeight( 50 ); | 107 | gammaSlider->setMinimumHeight( 50 ); |
108 | 108 | ||
109 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 109 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
110 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 110 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
111 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 111 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
112 | 112 | ||
113 | gammaMenu->insertItem( gammaSlider ); | 113 | gammaMenu->insertItem( gammaSlider ); |
114 | gammaMenu->insertItem( gammaLCD ); | 114 | gammaMenu->insertItem( gammaLCD ); |
115 | 115 | ||
116 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 116 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); |
117 | 117 | ||
118 | vbox5 = new QVBox( this ); | 118 | vbox5 = new QVBox( this ); |
119 | QVBox *vbox4 = new QVBox( vbox5 ); | 119 | QVBox *vbox4 = new QVBox( vbox5 ); |
120 | QHBox *hbox6 = new QHBox( vbox4 ); | 120 | QHBox *hbox6 = new QHBox( vbox4 ); |
121 | 121 | ||
122 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 122 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
123 | 123 | ||
124 | playListTab = new QWidget( tabWidget, "PlayListTab" ); | 124 | playListTab = new QWidget( tabWidget, "PlayListTab" ); |
125 | tabWidget->insertTab( playListTab, "Playlist"); | 125 | tabWidget->insertTab( playListTab, "Playlist"); |
126 | 126 | ||
127 | QGridLayout *Playout = new QGridLayout( playListTab ); | 127 | QGridLayout *Playout = new QGridLayout( playListTab ); |
128 | Playout->setSpacing( 2); | 128 | Playout->setSpacing( 2); |
129 | Playout->setMargin( 2); | 129 | Playout->setMargin( 2); |
130 | 130 | ||
131 | // Add the playlist area | 131 | // Add the playlist area |
132 | QVBox *vbox3 = new QVBox( playListTab ); | 132 | QVBox *vbox3 = new QVBox( playListTab ); |
133 | d->playListFrame = vbox3; | 133 | d->playListFrame = vbox3; |
134 | 134 | ||
135 | QHBox *hbox2 = new QHBox( vbox3 ); | 135 | QHBox *hbox2 = new QHBox( vbox3 ); |
136 | d->selectedFiles = new PlayListSelection( hbox2 ); | 136 | d->selectedFiles = new PlayListSelection( hbox2 ); |
137 | 137 | ||
138 | vbox1 = new QVBox( hbox2 ); | 138 | vbox1 = new QVBox( hbox2 ); |
139 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 139 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
140 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 140 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
141 | 141 | ||
142 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 142 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
143 | 143 | ||
144 | QWidget *aTab; | 144 | QWidget *aTab; |
145 | aTab = new QWidget( tabWidget, "aTab" ); | 145 | aTab = new QWidget( tabWidget, "aTab" ); |
146 | 146 | ||
147 | QGridLayout *Alayout = new QGridLayout( aTab ); | 147 | QGridLayout *Alayout = new QGridLayout( aTab ); |
148 | Alayout->setSpacing( 2 ); | 148 | Alayout->setSpacing( 2 ); |
149 | Alayout->setMargin( 2 ); | 149 | Alayout->setMargin( 2 ); |
150 | // no m3u's here please | 150 | // no m3u's here please |
151 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); | 151 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;audio/x-ogg", "opieplayer2/musicfile", aTab, "Audioview" ); |
152 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 152 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
153 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 153 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
154 | 154 | ||
155 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 155 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
156 | 156 | ||
157 | QWidget *vTab; | 157 | QWidget *vTab; |
158 | vTab = new QWidget( tabWidget, "vTab" ); | 158 | vTab = new QWidget( tabWidget, "vTab" ); |
159 | 159 | ||
160 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 160 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
161 | Vlayout->setSpacing( 2 ); | 161 | Vlayout->setSpacing( 2 ); |
162 | Vlayout->setMargin( 2 ); | 162 | Vlayout->setMargin( 2 ); |
163 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); | 163 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); |
164 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 164 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
165 | 165 | ||
166 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 166 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
167 | 167 | ||
168 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 168 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
169 | 169 | ||
170 | //playlists list | 170 | //playlists list |
171 | QWidget *LTab; | 171 | QWidget *LTab; |
172 | LTab = new QWidget( tabWidget, "LTab" ); | 172 | LTab = new QWidget( tabWidget, "LTab" ); |
173 | QGridLayout *Llayout = new QGridLayout( LTab ); | 173 | QGridLayout *Llayout = new QGridLayout( LTab ); |
174 | Llayout->setSpacing( 2 ); | 174 | Llayout->setSpacing( 2 ); |
175 | Llayout->setMargin( 2 ); | 175 | Llayout->setMargin( 2 ); |
176 | 176 | ||
177 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 177 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
178 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 178 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
179 | 179 | ||
180 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 180 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
181 | 181 | ||
182 | setCentralWidget( vbox5 ); | 182 | setCentralWidget( vbox5 ); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | 186 | ||
187 | PlayListWidgetGui::~PlayListWidgetGui() { | 187 | PlayListWidgetGui::~PlayListWidgetGui() { |
188 | } | 188 | } |
189 | 189 | ||
190 | void PlayListWidgetGui::setView( char view ) { | 190 | void PlayListWidgetGui::setView( char view ) { |
191 | if ( view == 'l' ) | 191 | if ( view == 'l' ) |
192 | showMaximized(); | 192 | showMaximized(); |
193 | else | 193 | else |
194 | hide(); | 194 | hide(); |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | void PlayListWidgetGui::setActiveWindow() { | 198 | void PlayListWidgetGui::setActiveWindow() { |
199 | // qDebug("SETTING active window"); | 199 | // qDebug("SETTING active window"); |
200 | // When we get raised we need to ensure that it switches views | 200 | // When we get raised we need to ensure that it switches views |
201 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); | 201 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); |
202 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 202 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
203 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back | 203 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back |
204 | } | 204 | } |
205 | 205 | ||
206 | PlayButton::PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, | ||
207 | const QString &icon, QObject *handler, const QString &slot, bool t ) | ||
208 | : ToolButton( parent, name, icon, handler, slot, t ), mediaPlayerState( _mediaPlayerState ), | ||
209 | m_lastEnableStatus( true ) | ||
210 | { | ||
211 | connect( &mediaPlayerState, SIGNAL( initialized() ), | ||
212 | this, SLOT( checkInitializationStatus() ) ); | ||
213 | } | ||
214 | |||
215 | void PlayButton::setEnabled( bool enable ) | ||
216 | { | ||
217 | m_lastEnableStatus = enable; | ||
218 | |||
219 | enable &= mediaPlayerState.isInitialized(); | ||
220 | |||
221 | ToolButton::setEnabled( enable ); | ||
222 | } | ||
223 | |||
224 | void PlayButton::checkInitializationStatus() | ||
225 | { | ||
226 | setEnabled( m_lastEnableStatus ); | ||
227 | } | ||
228 | 206 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 1aa8ac8..c965b0d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h | |||
@@ -1,151 +1,133 @@ | |||
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 PLAY_LIST_WIDGET_GUI_H | 34 | #ifndef PLAY_LIST_WIDGET_GUI_H |
35 | #define PLAY_LIST_WIDGET_GUI_H | 35 | #define PLAY_LIST_WIDGET_GUI_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
41 | 41 | ||
42 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
43 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qslider.h> | 47 | #include <qslider.h> |
48 | #include <qlcdnumber.h> | 48 | #include <qlcdnumber.h> |
49 | 49 | ||
50 | class PlayListWidgetPrivate; | 50 | class PlayListWidgetPrivate; |
51 | class PlayListSelection; | 51 | class PlayListSelection; |
52 | class MediaPlayerState; | 52 | class MediaPlayerState; |
53 | class PlayListFileView; | 53 | class PlayListFileView; |
54 | 54 | ||
55 | class Config; | 55 | class Config; |
56 | class QPEToolBar; | 56 | class QPEToolBar; |
57 | class QListViewItem; | 57 | class QListViewItem; |
58 | class QListView; | 58 | class QListView; |
59 | class QPoint; | 59 | class QPoint; |
60 | class QAction; | 60 | class QAction; |
61 | class QLabel; | 61 | class QLabel; |
62 | 62 | ||
63 | class PlayListWidgetPrivate { | 63 | class PlayListWidgetPrivate { |
64 | public: | 64 | public: |
65 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 65 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
66 | QFrame *playListFrame; | 66 | QFrame *playListFrame; |
67 | PlayListSelection *selectedFiles; | 67 | PlayListSelection *selectedFiles; |
68 | bool setDocumentUsed; | 68 | bool setDocumentUsed; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | class ToolButton : public QToolButton { | 72 | class ToolButton : public QToolButton { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | public: | 74 | public: |
75 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 75 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
76 | : QToolButton( parent, name ) { | 76 | : QToolButton( parent, name ) { |
77 | setTextLabel( name ); | 77 | setTextLabel( name ); |
78 | setPixmap( Resource::loadPixmap( icon ) ); | 78 | setPixmap( Resource::loadPixmap( icon ) ); |
79 | setAutoRaise( TRUE ); | 79 | setAutoRaise( TRUE ); |
80 | setFocusPolicy( QWidget::NoFocus ); | 80 | setFocusPolicy( QWidget::NoFocus ); |
81 | setToggleButton( t ); | 81 | setToggleButton( t ); |
82 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 82 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
83 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 83 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
84 | } | 84 | } |
85 | }; | 85 | }; |
86 | 86 | ||
87 | class PlayButton : public ToolButton | ||
88 | { | ||
89 | Q_OBJECT | ||
90 | public: | ||
91 | PlayButton( MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name, | ||
92 | const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ); | ||
93 | |||
94 | protected: | ||
95 | virtual void setEnabled( bool enable ); | ||
96 | |||
97 | private slots: | ||
98 | void checkInitializationStatus(); | ||
99 | |||
100 | private: | ||
101 | MediaPlayerState &mediaPlayerState; | ||
102 | bool m_lastEnableStatus : 1; | ||
103 | }; | ||
104 | |||
105 | class MenuItem : public QAction { | 87 | class MenuItem : public QAction { |
106 | 88 | ||
107 | public: | 89 | public: |
108 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 90 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
109 | : QAction( text, QString::null, 0, 0 ) { | 91 | : QAction( text, QString::null, 0, 0 ) { |
110 | connect( this, SIGNAL( activated() ), handler, slot ); | 92 | connect( this, SIGNAL( activated() ), handler, slot ); |
111 | addTo( parent ); | 93 | addTo( parent ); |
112 | } | 94 | } |
113 | }; | 95 | }; |
114 | 96 | ||
115 | class PlayListWidgetGui : public QMainWindow { | 97 | class PlayListWidgetGui : public QMainWindow { |
116 | Q_OBJECT | 98 | Q_OBJECT |
117 | public: | 99 | public: |
118 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 100 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
119 | ~PlayListWidgetGui(); | 101 | ~PlayListWidgetGui(); |
120 | 102 | ||
121 | protected: | 103 | protected: |
122 | QTabWidget * tabWidget; | 104 | QTabWidget * tabWidget; |
123 | PlayListFileView *audioView, *videoView; | 105 | PlayListFileView *audioView, *videoView; |
124 | QListView *playlistView; | 106 | QListView *playlistView; |
125 | QLabel *libString; | 107 | QLabel *libString; |
126 | QPopupMenu *pmView ; | 108 | QPopupMenu *pmView ; |
127 | QPopupMenu *gammaMenu; | 109 | QPopupMenu *gammaMenu; |
128 | QSlider *gammaSlider; | 110 | QSlider *gammaSlider; |
129 | QLCDNumber *gammaLCD; | 111 | QLCDNumber *gammaLCD; |
130 | bool fromSetDocument; | 112 | bool fromSetDocument; |
131 | bool insanityBool; | 113 | bool insanityBool; |
132 | QString setDocFileRef; | 114 | QString setDocFileRef; |
133 | // retrieve the current playlist entry (media file link) | 115 | // retrieve the current playlist entry (media file link) |
134 | QPushButton *tbDeletePlaylist; | 116 | QPushButton *tbDeletePlaylist; |
135 | int selected; | 117 | int selected; |
136 | QPopupMenu *pmPlayList; | 118 | QPopupMenu *pmPlayList; |
137 | FileSelector* playLists; | 119 | FileSelector* playLists; |
138 | QPopupMenu *skinsMenu; | 120 | QPopupMenu *skinsMenu; |
139 | PlayListWidgetPrivate *d; // Private implementation data | 121 | PlayListWidgetPrivate *d; // Private implementation data |
140 | QVBox *vbox1; | 122 | QVBox *vbox1; |
141 | QVBox *vbox5; | 123 | QVBox *vbox5; |
142 | QPEToolBar *bar; | 124 | QPEToolBar *bar; |
143 | QWidget *playListTab; | 125 | QWidget *playListTab; |
144 | void setActiveWindow(); // need to handle this to show the right view | 126 | void setActiveWindow(); // need to handle this to show the right view |
145 | void setView( char ); | 127 | void setView( char ); |
146 | 128 | ||
147 | MediaPlayerState &mediaPlayerState; | 129 | MediaPlayerState &mediaPlayerState; |
148 | }; | 130 | }; |
149 | 131 | ||
150 | #endif | 132 | #endif |
151 | 133 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index e791c3b..ee2cd83 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,264 +1,256 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include "xinecontrol.h" | 39 | #include "xinecontrol.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | #include "xinevideowidget.h" | 41 | #include "xinevideowidget.h" |
42 | 42 | ||
43 | XineControl::XineControl( XineVideoWidget *xineWidget, | 43 | XineControl::XineControl( XineVideoWidget *xineWidget, |
44 | MediaPlayerState &_mediaPlayerState, | 44 | MediaPlayerState &_mediaPlayerState, |
45 | QObject *parent, const char *name ) | 45 | QObject *parent, const char *name ) |
46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
47 | { | 47 | { |
48 | 48 | ||
49 | libXine = new XINE::Lib( xineWidget ); | 49 | libXine = new XINE::Lib( xineWidget ); |
50 | 50 | ||
51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); | 52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); |
53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
58 | connect( libXine, SIGNAL( initialized() ), this, SLOT( xineInitialized() ) ); | 58 | connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); |
59 | 59 | ||
60 | disabledSuspendScreenSaver = FALSE; | 60 | disabledSuspendScreenSaver = FALSE; |
61 | } | 61 | } |
62 | 62 | ||
63 | XineControl::~XineControl() { | 63 | XineControl::~XineControl() { |
64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
65 | if ( disabledSuspendScreenSaver ) { | 65 | if ( disabledSuspendScreenSaver ) { |
66 | disabledSuspendScreenSaver = FALSE; | 66 | disabledSuspendScreenSaver = FALSE; |
67 | // Re-enable the suspend mode | 67 | // Re-enable the suspend mode |
68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
69 | } | 69 | } |
70 | #endif | 70 | #endif |
71 | delete libXine; | 71 | delete libXine; |
72 | } | 72 | } |
73 | 73 | ||
74 | void XineControl::play( const QString& fileName ) { | 74 | void XineControl::play( const QString& fileName ) { |
75 | hasVideoChannel = FALSE; | 75 | hasVideoChannel = FALSE; |
76 | hasAudioChannel = FALSE; | 76 | hasAudioChannel = FALSE; |
77 | m_fileName = fileName; | 77 | m_fileName = fileName; |
78 | 78 | ||
79 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 79 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
80 | 80 | ||
81 | if ( !libXine->play( fileName, 0, 0 ) ) { | 81 | if ( !libXine->play( fileName, 0, 0 ) ) { |
82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
83 | // toggle stop so the the play button is reset | 83 | // toggle stop so the the play button is reset |
84 | mediaPlayerState.setPlaying( false ); | 84 | mediaPlayerState.setPlaying( false ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | mediaPlayerState.setPlaying( true ); | 87 | mediaPlayerState.setPlaying( true ); |
88 | 88 | ||
89 | MediaPlayerState::DisplayType displayType; | 89 | MediaPlayerState::DisplayType displayType; |
90 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); | 90 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); |
91 | if ( !libXine->hasVideo() ) { | 91 | if ( !libXine->hasVideo() ) { |
92 | displayType = MediaPlayerState::Audio; | 92 | displayType = MediaPlayerState::Audio; |
93 | qDebug("HAS AUDIO"); | 93 | qDebug("HAS AUDIO"); |
94 | libXine->setShowVideo( false ); | 94 | libXine->setShowVideo( false ); |
95 | hasAudioChannel = TRUE; | 95 | hasAudioChannel = TRUE; |
96 | } else { | 96 | } else { |
97 | displayType = MediaPlayerState::Video; | 97 | displayType = MediaPlayerState::Video; |
98 | qDebug("HAS VIDEO"); | 98 | qDebug("HAS VIDEO"); |
99 | libXine->setShowVideo( true ); | 99 | libXine->setShowVideo( true ); |
100 | hasVideoChannel = TRUE; | 100 | hasVideoChannel = TRUE; |
101 | } | 101 | } |
102 | // determine if slider is shown | 102 | // determine if slider is shown |
103 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 103 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
104 | 104 | ||
105 | // which gui (video / audio) | 105 | // which gui (video / audio) |
106 | mediaPlayerState.setDisplayType( displayType ); | 106 | mediaPlayerState.setDisplayType( displayType ); |
107 | 107 | ||
108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
109 | if ( !disabledSuspendScreenSaver ) { | 109 | if ( !disabledSuspendScreenSaver ) { |
110 | disabledSuspendScreenSaver = TRUE; | 110 | disabledSuspendScreenSaver = TRUE; |
111 | // Stop the screen from blanking and power saving state | 111 | // Stop the screen from blanking and power saving state |
112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
114 | } | 114 | } |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | length(); | 117 | length(); |
118 | position(); | 118 | position(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void XineControl::nextMedia() { | 121 | void XineControl::nextMedia() { |
122 | mediaPlayerState.setNext(); | 122 | mediaPlayerState.setNext(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void XineControl::setGamma( int value ) { | 125 | void XineControl::setGamma( int value ) { |
126 | libXine->setGamma( value ); | 126 | libXine->setGamma( value ); |
127 | } | 127 | } |
128 | 128 | ||
129 | void XineControl::xineInitialized() | ||
130 | { | ||
131 | connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); | ||
132 | libXine->resize( xineVideoWidget->videoSize() ); | ||
133 | |||
134 | emit initialized(); | ||
135 | } | ||
136 | |||
137 | void XineControl::stop( bool isSet ) { | 129 | void XineControl::stop( bool isSet ) { |
138 | if ( !isSet ) { | 130 | if ( !isSet ) { |
139 | libXine->stop(); | 131 | libXine->stop(); |
140 | 132 | ||
141 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 133 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
142 | if ( disabledSuspendScreenSaver ) { | 134 | if ( disabledSuspendScreenSaver ) { |
143 | disabledSuspendScreenSaver = FALSE; | 135 | disabledSuspendScreenSaver = FALSE; |
144 | // Re-enable the suspend mode | 136 | // Re-enable the suspend mode |
145 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 137 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
146 | } | 138 | } |
147 | #endif | 139 | #endif |
148 | } | 140 | } |
149 | } | 141 | } |
150 | 142 | ||
151 | /** | 143 | /** |
152 | * Pause playback | 144 | * Pause playback |
153 | * @isSet | 145 | * @isSet |
154 | */ | 146 | */ |
155 | void XineControl::pause( bool isSet) { | 147 | void XineControl::pause( bool isSet) { |
156 | libXine->pause( isSet ); | 148 | libXine->pause( isSet ); |
157 | } | 149 | } |
158 | 150 | ||
159 | 151 | ||
160 | /** | 152 | /** |
161 | * get current time in playback | 153 | * get current time in playback |
162 | */ | 154 | */ |
163 | long XineControl::currentTime() { | 155 | long XineControl::currentTime() { |
164 | // todo: jede sekunde überprüfen | 156 | // todo: jede sekunde überprüfen |
165 | m_currentTime = libXine->currentTime(); | 157 | m_currentTime = libXine->currentTime(); |
166 | return m_currentTime; | 158 | return m_currentTime; |
167 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 159 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
168 | } | 160 | } |
169 | 161 | ||
170 | /** | 162 | /** |
171 | * Set the length of the media file | 163 | * Set the length of the media file |
172 | */ | 164 | */ |
173 | void XineControl::length() { | 165 | void XineControl::length() { |
174 | m_length = libXine->length(); | 166 | m_length = libXine->length(); |
175 | mediaPlayerState.setLength( m_length ); | 167 | mediaPlayerState.setLength( m_length ); |
176 | } | 168 | } |
177 | 169 | ||
178 | 170 | ||
179 | /** | 171 | /** |
180 | * Reports the position the xine backend is at right now | 172 | * Reports the position the xine backend is at right now |
181 | * @return long the postion in seconds | 173 | * @return long the postion in seconds |
182 | */ | 174 | */ |
183 | long XineControl::position() { | 175 | long XineControl::position() { |
184 | m_position = ( currentTime() ); | 176 | m_position = ( currentTime() ); |
185 | mediaPlayerState.updatePosition( m_position ); | 177 | mediaPlayerState.updatePosition( m_position ); |
186 | long emitPos = (long)m_position; | 178 | long emitPos = (long)m_position; |
187 | emit positionChanged( emitPos ); | 179 | emit positionChanged( emitPos ); |
188 | if( mediaPlayerState.isPlaying() ) { | 180 | if( mediaPlayerState.isPlaying() ) { |
189 | // needs to be stopped the media is stopped | 181 | // needs to be stopped the media is stopped |
190 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 182 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
191 | } | 183 | } |
192 | // qDebug("POSITION : %d", m_position); | 184 | // qDebug("POSITION : %d", m_position); |
193 | return m_position; | 185 | return m_position; |
194 | } | 186 | } |
195 | 187 | ||
196 | /** | 188 | /** |
197 | * Set videoplayback to fullscreen | 189 | * Set videoplayback to fullscreen |
198 | * @param isSet | 190 | * @param isSet |
199 | */ | 191 | */ |
200 | void XineControl::setFullscreen( bool isSet ) { | 192 | void XineControl::setFullscreen( bool isSet ) { |
201 | libXine->showVideoFullScreen( isSet ); | 193 | libXine->showVideoFullScreen( isSet ); |
202 | } | 194 | } |
203 | 195 | ||
204 | 196 | ||
205 | QString XineControl::getMetaInfo() { | 197 | QString XineControl::getMetaInfo() { |
206 | 198 | ||
207 | QString returnString; | 199 | QString returnString; |
208 | 200 | ||
209 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 201 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
210 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 202 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
211 | } | 203 | } |
212 | 204 | ||
213 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 205 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
214 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 206 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
215 | } | 207 | } |
216 | 208 | ||
217 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 209 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
218 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 210 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
219 | } | 211 | } |
220 | 212 | ||
221 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 213 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
222 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 214 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
223 | } | 215 | } |
224 | 216 | ||
225 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 217 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
226 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 218 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
227 | } | 219 | } |
228 | 220 | ||
229 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 221 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
230 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 222 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
231 | } | 223 | } |
232 | return returnString; | 224 | return returnString; |
233 | } | 225 | } |
234 | 226 | ||
235 | QString XineControl::getErrorCode() { | 227 | QString XineControl::getErrorCode() { |
236 | 228 | ||
237 | int errorCode = libXine->error(); | 229 | int errorCode = libXine->error(); |
238 | 230 | ||
239 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 231 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
240 | 232 | ||
241 | if ( errorCode == 1 ) { | 233 | if ( errorCode == 1 ) { |
242 | return tr( "No input plugin found for this media type" ); | 234 | return tr( "No input plugin found for this media type" ); |
243 | } else if ( errorCode == 2 ) { | 235 | } else if ( errorCode == 2 ) { |
244 | return tr( "No demux plugin found for this media type" ); | 236 | return tr( "No demux plugin found for this media type" ); |
245 | } else if ( errorCode == 3 ) { | 237 | } else if ( errorCode == 3 ) { |
246 | return tr( "Demuxing failed for this media type" ); | 238 | return tr( "Demuxing failed for this media type" ); |
247 | } else if ( errorCode == 4 ) { | 239 | } else if ( errorCode == 4 ) { |
248 | return tr( "Malformed MRL" ); | 240 | return tr( "Malformed MRL" ); |
249 | } else { | 241 | } else { |
250 | return tr( "Some other error" ); | 242 | return tr( "Some other error" ); |
251 | } | 243 | } |
252 | } | 244 | } |
253 | 245 | ||
254 | /** | 246 | /** |
255 | * Seek to a position in the track | 247 | * Seek to a position in the track |
256 | * @param second the second to jump to | 248 | * @param second the second to jump to |
257 | */ | 249 | */ |
258 | void XineControl::seekTo( long second ) { | 250 | void XineControl::seekTo( long second ) { |
259 | libXine->seekTo( (int)second ); | 251 | libXine->seekTo( (int)second ); |
260 | } | 252 | } |
261 | 253 | ||
262 | void XineControl::videoResized ( const QSize &s ) { | 254 | void XineControl::videoResized ( const QSize &s ) { |
263 | libXine->resize( s ); | 255 | libXine->resize( s ); |
264 | } | 256 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 085de3f..fdc5d2b 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,126 +1,120 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | class XineControl : public QObject { | 42 | class XineControl : public QObject { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | XineControl( XineVideoWidget *xineWidget, | 45 | XineControl( XineVideoWidget *xineWidget, |
46 | MediaPlayerState &_mediaPlayerState, | 46 | MediaPlayerState &_mediaPlayerState, |
47 | QObject *parent = 0, const char *name =0 ); | 47 | QObject *parent = 0, const char *name =0 ); |
48 | ~XineControl(); | 48 | ~XineControl(); |
49 | 49 | ||
50 | bool hasVideo() const { return hasVideoChannel; } | 50 | bool hasVideo() const { return hasVideoChannel; } |
51 | bool hasAudio() const { return hasAudioChannel; } | 51 | bool hasAudio() const { return hasAudioChannel; } |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void play( const QString& fileName ); | 54 | void play( const QString& fileName ); |
55 | void stop( bool ); | 55 | void stop( bool ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Pause the media stream | 58 | * Pause the media stream |
59 | * @param if pause or not | 59 | * @param if pause or not |
60 | */ | 60 | */ |
61 | void pause( bool ); | 61 | void pause( bool ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Set videos fullscreen | 64 | * Set videos fullscreen |
65 | * @param yes or no | 65 | * @param yes or no |
66 | */ | 66 | */ |
67 | void setFullscreen( bool ); | 67 | void setFullscreen( bool ); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * | 70 | * |
71 | */ | 71 | */ |
72 | long currentTime(); | 72 | long currentTime(); |
73 | void seekTo( long ); | 73 | void seekTo( long ); |
74 | // get length of media file and set it | 74 | // get length of media file and set it |
75 | void length(); | 75 | void length(); |
76 | long position(); | 76 | long position(); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Proceed to the next media file in playlist | 79 | * Proceed to the next media file in playlist |
80 | */ | 80 | */ |
81 | void nextMedia(); | 81 | void nextMedia(); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get as much info about the stream from xine as possible | 84 | * Get as much info about the stream from xine as possible |
85 | */ | 85 | */ |
86 | QString getMetaInfo(); | 86 | QString getMetaInfo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * get the error code and "translate" it for the user | 89 | * get the error code and "translate" it for the user |
90 | * | 90 | * |
91 | */ | 91 | */ |
92 | QString getErrorCode(); | 92 | QString getErrorCode(); |
93 | 93 | ||
94 | 94 | ||
95 | void videoResized ( const QSize &s ); | 95 | void videoResized ( const QSize &s ); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Set the gamma value of the video output | 98 | * Set the gamma value of the video output |
99 | * @param int value between -100 and 100, 0 is original | 99 | * @param int value between -100 and 100, 0 is original |
100 | */ | 100 | */ |
101 | void setGamma( int ); | 101 | void setGamma( int ); |
102 | 102 | ||
103 | |||
104 | private slots: | ||
105 | void xineInitialized(); | ||
106 | |||
107 | private: | 103 | private: |
108 | XINE::Lib *libXine; | 104 | XINE::Lib *libXine; |
109 | long m_currentTime; | 105 | long m_currentTime; |
110 | long m_position; | 106 | long m_position; |
111 | int m_length; | 107 | int m_length; |
112 | QString m_fileName; | 108 | QString m_fileName; |
113 | bool disabledSuspendScreenSaver : 1; | 109 | bool disabledSuspendScreenSaver : 1; |
114 | bool hasVideoChannel : 1; | 110 | bool hasVideoChannel : 1; |
115 | bool hasAudioChannel : 1; | 111 | bool hasAudioChannel : 1; |
116 | MediaPlayerState &mediaPlayerState; | 112 | MediaPlayerState &mediaPlayerState; |
117 | XineVideoWidget *xineVideoWidget; | 113 | XineVideoWidget *xineVideoWidget; |
118 | 114 | ||
119 | signals: | 115 | signals: |
120 | void positionChanged( long ); | 116 | void positionChanged( long ); |
121 | |||
122 | void initialized(); | ||
123 | }; | 117 | }; |
124 | 118 | ||
125 | 119 | ||
126 | #endif | 120 | #endif |