author | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
commit | 9237a75548f9b932fbb1900d8ea28dbee9da81ac (patch) (unidiff) | |
tree | a0249408df5ce581af8bcee5b6f58bcee1db461a | |
parent | 11d754ffa429875b526c49f125d8a844c5cda3d8 (diff) | |
download | opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.zip opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.gz opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.bz2 |
bug fix
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/mpeg3io.c | 132 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.h | 6 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 250 |
6 files changed, 236 insertions, 187 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9f8ba65..8ede537 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -1,578 +1,583 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <stdarg.h> | 21 | #include <stdarg.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <ctype.h> | 28 | #include <ctype.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #include <locale.h> | 31 | #include <locale.h> |
32 | #include <math.h> | 32 | #include <math.h> |
33 | #include <assert.h> | 33 | #include <assert.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpe/config.h> | ||
35 | 36 | ||
36 | //#define HAVE_MMAP | 37 | //#define HAVE_MMAP |
37 | 38 | ||
38 | #if defined(HAVE_MMAP) | 39 | #if defined(HAVE_MMAP) |
39 | # include <sys/mman.h> | 40 | # include <sys/mman.h> |
40 | #endif | 41 | #endif |
41 | #include "libmadplugin.h" | 42 | #include "libmadplugin.h" |
42 | 43 | ||
43 | 44 | ||
44 | extern "C" { | 45 | extern "C" { |
45 | #include "mad.h" | 46 | #include "mad.h" |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | #define MPEG_BUFFER_SIZE 65536 | 50 | #define MPEG_BUFFER_SIZE 65536 |
51 | //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 | ||
50 | //#define debugMsg(a) qDebug(a) | 52 | //#define debugMsg(a) qDebug(a) |
51 | #define debugMsg(a) | 53 | #define debugMsg(a) |
52 | 54 | ||
53 | 55 | ||
54 | class Input { | 56 | class Input { |
55 | public: | 57 | public: |
56 | char const *path; | 58 | char const *path; |
57 | int fd; | 59 | int fd; |
58 | #if defined(HAVE_MMAP) | 60 | #if defined(HAVE_MMAP) |
59 | void *fdm; | 61 | void *fdm; |
60 | #endif | 62 | #endif |
61 | unsigned char *data; | 63 | unsigned char *data; |
62 | unsigned long length; | 64 | unsigned long length; |
63 | int eof; | 65 | int eof; |
64 | }; | 66 | }; |
65 | 67 | ||
66 | 68 | ||
67 | class Output { | 69 | class Output { |
68 | public: | 70 | public: |
69 | mad_fixed_t attenuate; | 71 | mad_fixed_t attenuate; |
70 | struct filter *filters; | 72 | struct filter *filters; |
71 | unsigned int channels_in; | 73 | unsigned int channels_in; |
72 | unsigned int channels_out; | 74 | unsigned int channels_out; |
73 | unsigned int speed_in; | 75 | unsigned int speed_in; |
74 | unsigned int speed_out; | 76 | unsigned int speed_out; |
75 | const char *path; | 77 | const char *path; |
76 | }; | 78 | }; |
77 | 79 | ||
78 | 80 | ||
79 | # if defined(HAVE_MMAP) | 81 | # if defined(HAVE_MMAP) |
80 | static void *map_file(int fd, unsigned long *length) | 82 | static void *map_file(int fd, unsigned long *length) |
81 | { | 83 | { |
82 | void *fdm; | 84 | void *fdm; |
83 | 85 | ||
84 | *length += MAD_BUFFER_GUARD; | 86 | *length += MAD_BUFFER_GUARD; |
85 | 87 | ||
86 | fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0); | 88 | fdm = mmap(0, *length, PROT_READ, MAP_SHARED, fd, 0); |
87 | if (fdm == MAP_FAILED) | 89 | if (fdm == MAP_FAILED) |
88 | return 0; | 90 | return 0; |
89 | 91 | ||
90 | # if defined(HAVE_MADVISE) | 92 | # if defined(HAVE_MADVISE) |
91 | madvise(fdm, *length, MADV_SEQUENTIAL); | 93 | madvise(fdm, *length, MADV_SEQUENTIAL); |
92 | # endif | 94 | # endif |
93 | 95 | ||
94 | return fdm; | 96 | return fdm; |
95 | } | 97 | } |
96 | 98 | ||
97 | 99 | ||
98 | static int unmap_file(void *fdm, unsigned long length) | 100 | static int unmap_file(void *fdm, unsigned long length) |
99 | { | 101 | { |
100 | if (munmap(fdm, length) == -1) | 102 | if (munmap(fdm, length) == -1) |
101 | return -1; | 103 | return -1; |
102 | 104 | ||
103 | return 0; | 105 | return 0; |
104 | } | 106 | } |
105 | # endif | 107 | # endif |
106 | 108 | ||
107 | 109 | ||
108 | static inline QString tr( const char *str ) { | 110 | static inline QString tr( const char *str ) { |
109 | // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin | 111 | // Apparently this is okay from a plugin as it runs in the process space of the owner of the plugin |
110 | return qApp->translate( "MediaPlayer", str, "libmad strings for mp3 file info" ); | 112 | return qApp->translate( "MediaPlayer", str, "libmad strings for mp3 file info" ); |
111 | } | 113 | } |
112 | 114 | ||
113 | 115 | ||
114 | class LibMadPluginData { | 116 | class LibMadPluginData { |
115 | public: | 117 | public: |
116 | Input input; | 118 | Input input; |
117 | Output output; | 119 | Output output; |
118 | int bad_last_frame; | 120 | int bad_last_frame; |
119 | struct mad_stream stream; | 121 | struct mad_stream stream; |
120 | struct mad_frame frame; | 122 | struct mad_frame frame; |
121 | struct mad_synth synth; | 123 | struct mad_synth synth; |
122 | bool flush; | 124 | bool flush; |
123 | }; | 125 | }; |
124 | 126 | ||
125 | 127 | ||
126 | LibMadPlugin::LibMadPlugin() { | 128 | LibMadPlugin::LibMadPlugin() { |
127 | d = new LibMadPluginData; | 129 | d = new LibMadPluginData; |
128 | d->input.fd = 0; | 130 | d->input.fd = 0; |
129 | #if defined(HAVE_MMAP) | 131 | #if defined(HAVE_MMAP) |
130 | d->input.fdm = 0; | 132 | d->input.fdm = 0; |
131 | #endif | 133 | #endif |
132 | d->input.data = 0; | 134 | d->input.data = 0; |
133 | d->flush = TRUE; | 135 | d->flush = TRUE; |
134 | info = tr( "No Song Open" ); | 136 | info = tr( "No Song Open" ); |
135 | } | 137 | } |
136 | 138 | ||
137 | 139 | ||
138 | LibMadPlugin::~LibMadPlugin() { | 140 | LibMadPlugin::~LibMadPlugin() { |
139 | close(); | 141 | close(); |
140 | delete d; | 142 | delete d; |
141 | } | 143 | } |
142 | 144 | ||
143 | 145 | ||
144 | bool LibMadPlugin::isFileSupported( const QString& path ) { | 146 | bool LibMadPlugin::isFileSupported( const QString& path ) { |
145 | debugMsg( "LibMadPlugin::isFileSupported" ); | 147 | debugMsg( "LibMadPlugin::isFileSupported" ); |
146 | 148 | ||
147 | // Mpeg file extensions | 149 | // Mpeg file extensions |
148 | // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3" | 150 | // "mp2","mp3","m1v","m2v","m2s","mpg","vob","mpeg","ac3" |
149 | // Other media extensions | 151 | // Other media extensions |
150 | // "wav","mid","mod","s3m","ogg","avi","mov","sid" | 152 | // "wav","mid","mod","s3m","ogg","avi","mov","sid" |
151 | 153 | ||
152 | char *ext = strrchr( path.latin1(), '.' ); | 154 | char *ext = strrchr( path.latin1(), '.' ); |
153 | 155 | ||
154 | // Test file extension | 156 | // Test file extension |
155 | if ( ext ) { | 157 | if ( ext ) { |
156 | if ( strncasecmp(ext, ".mp2", 4) == 0 ) | 158 | if ( strncasecmp(ext, ".mp2", 4) == 0 ) |
157 | return TRUE; | 159 | return TRUE; |
158 | if ( strncasecmp(ext, ".mp3", 4) == 0 ) | 160 | if ( strncasecmp(ext, ".mp3", 4) == 0 ) |
159 | return TRUE; | 161 | return TRUE; |
160 | } | 162 | } |
161 | 163 | ||
162 | return FALSE; | 164 | return FALSE; |
163 | } | 165 | } |
164 | 166 | ||
165 | 167 | ||
166 | bool LibMadPlugin::open( const QString& path ) { | 168 | bool LibMadPlugin::open( const QString& path ) { |
167 | debugMsg( "LibMadPlugin::open" ); | 169 | debugMsg( "LibMadPlugin::open" ); |
168 | 170 | Config cfg("MediaPlayer"); | |
171 | cfg.setGroup("Options"); | ||
172 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); | ||
173 | qDebug("buffer size is %d", bufferSize); | ||
169 | d->bad_last_frame = 0; | 174 | d->bad_last_frame = 0; |
170 | d->flush = TRUE; | 175 | d->flush = TRUE; |
171 | info = QString( "" ); | 176 | info = QString( "" ); |
172 | 177 | ||
173 | //qDebug( "Opening %s", path.latin1() ); | 178 | //qDebug( "Opening %s", path.latin1() ); |
174 | 179 | ||
175 | d->input.path = path.latin1(); | 180 | d->input.path = path.latin1(); |
176 | d->input.fd = ::open( d->input.path, O_RDONLY ); | 181 | d->input.fd = ::open( d->input.path, O_RDONLY ); |
177 | if (d->input.fd == -1) { | 182 | if (d->input.fd == -1) { |
178 | qDebug("error opening %s", d->input.path ); | 183 | qDebug("error opening %s", d->input.path ); |
179 | return FALSE; | 184 | return FALSE; |
180 | } | 185 | } |
181 | 186 | ||
182 | printID3Tags(); | 187 | printID3Tags(); |
183 | 188 | ||
184 | #if defined(HAVE_MMAP) | 189 | #if defined(HAVE_MMAP) |
185 | struct stat stat; | 190 | struct stat stat; |
186 | if (fstat(d->input.fd, &stat) == -1) { | 191 | if (fstat(d->input.fd, &stat) == -1) { |
187 | qDebug("error calling fstat"); return FALSE; | 192 | qDebug("error calling fstat"); return FALSE; |
188 | } | 193 | } |
189 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { | 194 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { |
190 | d->input.length = stat.st_size; | 195 | d->input.length = stat.st_size; |
191 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 196 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
192 | if (d->input.fdm == 0) { | 197 | if (d->input.fdm == 0) { |
193 | qDebug("error mmapping file"); return FALSE; | 198 | qDebug("error mmapping file"); return FALSE; |
194 | } | 199 | } |
195 | d->input.data = (unsigned char *)d->input.fdm; | 200 | d->input.data = (unsigned char *)d->input.fdm; |
196 | } | 201 | } |
197 | #endif | 202 | #endif |
198 | 203 | ||
199 | if (d->input.data == 0) { | 204 | if (d->input.data == 0) { |
200 | d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); | 205 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); |
201 | if (d->input.data == 0) { | 206 | if (d->input.data == 0) { |
202 | qDebug("error allocating input buffer"); | 207 | qDebug("error allocating input buffer"); |
203 | return FALSE; | 208 | return FALSE; |
204 | } | 209 | } |
205 | d->input.length = 0; | 210 | d->input.length = 0; |
206 | } | 211 | } |
207 | 212 | ||
208 | d->input.eof = 0; | 213 | d->input.eof = 0; |
209 | 214 | ||
210 | mad_stream_init(&d->stream); | 215 | mad_stream_init(&d->stream); |
211 | mad_frame_init(&d->frame); | 216 | mad_frame_init(&d->frame); |
212 | mad_synth_init(&d->synth); | 217 | mad_synth_init(&d->synth); |
213 | 218 | ||
214 | return TRUE; | 219 | return TRUE; |
215 | } | 220 | } |
216 | 221 | ||
217 | 222 | ||
218 | bool LibMadPlugin::close() { | 223 | bool LibMadPlugin::close() { |
219 | debugMsg( "LibMadPlugin::close" ); | 224 | debugMsg( "LibMadPlugin::close" ); |
220 | 225 | ||
221 | int result = TRUE; | 226 | int result = TRUE; |
222 | 227 | ||
223 | mad_synth_finish(&d->synth); | 228 | mad_synth_finish(&d->synth); |
224 | mad_frame_finish(&d->frame); | 229 | mad_frame_finish(&d->frame); |
225 | mad_stream_finish(&d->stream); | 230 | mad_stream_finish(&d->stream); |
226 | 231 | ||
227 | #if defined(HAVE_MMAP) | 232 | #if defined(HAVE_MMAP) |
228 | if (d->input.fdm) { | 233 | if (d->input.fdm) { |
229 | if (unmap_file(d->input.fdm, d->input.length) == -1) { | 234 | if (unmap_file(d->input.fdm, d->input.length) == -1) { |
230 | qDebug("error munmapping file"); | 235 | qDebug("error munmapping file"); |
231 | result = FALSE; | 236 | result = FALSE; |
232 | } | 237 | } |
233 | d->input.fdm = 0; | 238 | d->input.fdm = 0; |
234 | d->input.data = 0; | 239 | d->input.data = 0; |
235 | } | 240 | } |
236 | #endif | 241 | #endif |
237 | 242 | ||
238 | if (d->input.data) { | 243 | if (d->input.data) { |
239 | free(d->input.data); | 244 | free(d->input.data); |
240 | d->input.data = 0; | 245 | d->input.data = 0; |
241 | } | 246 | } |
242 | 247 | ||
243 | if (::close(d->input.fd) == -1) { | 248 | if (::close(d->input.fd) == -1) { |
244 | qDebug("error closing file %s", d->input.path); | 249 | qDebug("error closing file %s", d->input.path); |
245 | result = FALSE; | 250 | result = FALSE; |
246 | } | 251 | } |
247 | 252 | ||
248 | d->input.fd = 0; | 253 | d->input.fd = 0; |
249 | 254 | ||
250 | return result; | 255 | return result; |
251 | } | 256 | } |
252 | 257 | ||
253 | 258 | ||
254 | bool LibMadPlugin::isOpen() { | 259 | bool LibMadPlugin::isOpen() { |
255 | debugMsg( "LibMadPlugin::isOpen" ); | 260 | debugMsg( "LibMadPlugin::isOpen" ); |
256 | return ( d->input.fd != 0 ); | 261 | return ( d->input.fd != 0 ); |
257 | } | 262 | } |
258 | 263 | ||
259 | 264 | ||
260 | int LibMadPlugin::audioStreams() { | 265 | int LibMadPlugin::audioStreams() { |
261 | debugMsg( "LibMadPlugin::audioStreams" ); | 266 | debugMsg( "LibMadPlugin::audioStreams" ); |
262 | return 1; | 267 | return 1; |
263 | } | 268 | } |
264 | 269 | ||
265 | 270 | ||
266 | int LibMadPlugin::audioChannels( int ) { | 271 | int LibMadPlugin::audioChannels( int ) { |
267 | debugMsg( "LibMadPlugin::audioChannels" ); | 272 | debugMsg( "LibMadPlugin::audioChannels" ); |
268 | /* | 273 | /* |
269 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 274 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
270 | qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); | 275 | qDebug( "LibMadPlugin::audioChannels: %i", d->frame.header.mode > 0 ? 2 : 1 ); |
271 | return d->frame.header.mode > 0 ? 2 : 1; | 276 | return d->frame.header.mode > 0 ? 2 : 1; |
272 | */ | 277 | */ |
273 | return 2; | 278 | return 2; |
274 | } | 279 | } |
275 | 280 | ||
276 | 281 | ||
277 | int LibMadPlugin::audioFrequency( int ) { | 282 | int LibMadPlugin::audioFrequency( int ) { |
278 | debugMsg( "LibMadPlugin::audioFrequency" ); | 283 | debugMsg( "LibMadPlugin::audioFrequency" ); |
279 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 284 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
280 | qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); | 285 | qDebug( "LibMadPlugin::audioFrequency: %i", d->frame.header.samplerate ); |
281 | return d->frame.header.samplerate; | 286 | return d->frame.header.samplerate; |
282 | } | 287 | } |
283 | 288 | ||
284 | 289 | ||
285 | int LibMadPlugin::audioSamples( int ) { | 290 | int LibMadPlugin::audioSamples( int ) { |
286 | debugMsg( "LibMadPlugin::audioSamples" ); | 291 | debugMsg( "LibMadPlugin::audioSamples" ); |
287 | /* | 292 | /* |
288 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 293 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
289 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); | 294 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); |
290 | qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); | 295 | qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); |
291 | return d->frame.header.duration.seconds * d->frame.header.samplerate; | 296 | return d->frame.header.duration.seconds * d->frame.header.samplerate; |
292 | */ | 297 | */ |
293 | return 10000000; | 298 | return 10000000; |
294 | } | 299 | } |
295 | 300 | ||
296 | 301 | ||
297 | bool LibMadPlugin::audioSetSample( long, int ) { | 302 | bool LibMadPlugin::audioSetSample( long, int ) { |
298 | debugMsg( "LibMadPlugin::audioSetSample" ); | 303 | debugMsg( "LibMadPlugin::audioSetSample" ); |
299 | return FALSE; | 304 | return FALSE; |
300 | } | 305 | } |
301 | 306 | ||
302 | 307 | ||
303 | long LibMadPlugin::audioGetSample( int ) { | 308 | long LibMadPlugin::audioGetSample( int ) { |
304 | debugMsg( "LibMadPlugin::audioGetSample" ); | 309 | debugMsg( "LibMadPlugin::audioGetSample" ); |
305 | return 0; | 310 | return 0; |
306 | } | 311 | } |
307 | 312 | ||
308 | /* | 313 | /* |
309 | bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { | 314 | bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { |
310 | debugMsg( "LibMadPlugin::audioReadSamples" ); | 315 | debugMsg( "LibMadPlugin::audioReadSamples" ); |
311 | return FALSE; | 316 | return FALSE; |
312 | } | 317 | } |
313 | 318 | ||
314 | 319 | ||
315 | bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { | 320 | bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { |
316 | debugMsg( "LibMadPlugin::audioReReadSamples" ); | 321 | debugMsg( "LibMadPlugin::audioReReadSamples" ); |
317 | return FALSE; | 322 | return FALSE; |
318 | } | 323 | } |
319 | */ | 324 | */ |
320 | 325 | ||
321 | bool LibMadPlugin::read() { | 326 | bool LibMadPlugin::read() { |
322 | debugMsg( "LibMadPlugin::read" ); | 327 | debugMsg( "LibMadPlugin::read" ); |
323 | int len; | 328 | int len; |
324 | 329 | ||
325 | if (d->input.eof) | 330 | if (d->input.eof) |
326 | return FALSE; | 331 | return FALSE; |
327 | 332 | ||
328 | #if defined(HAVE_MMAP) | 333 | #if defined(HAVE_MMAP) |
329 | if (d->input.fdm) { | 334 | if (d->input.fdm) { |
330 | unsigned long skip = 0; | 335 | unsigned long skip = 0; |
331 | 336 | ||
332 | if (d->stream.next_frame) { | 337 | if (d->stream.next_frame) { |
333 | struct stat stat; | 338 | struct stat stat; |
334 | 339 | ||
335 | if (fstat(d->input.fd, &stat) == -1) | 340 | if (fstat(d->input.fd, &stat) == -1) |
336 | return FALSE; | 341 | return FALSE; |
337 | 342 | ||
338 | if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) | 343 | if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) |
339 | return FALSE; | 344 | return FALSE; |
340 | 345 | ||
341 | // file size changed; update memory map | 346 | // file size changed; update memory map |
342 | skip = d->stream.next_frame - d->input.data; | 347 | skip = d->stream.next_frame - d->input.data; |
343 | 348 | ||
344 | if (unmap_file(d->input.fdm, d->input.length) == -1) { | 349 | if (unmap_file(d->input.fdm, d->input.length) == -1) { |
345 | d->input.fdm = 0; | 350 | d->input.fdm = 0; |
346 | d->input.data = 0; | 351 | d->input.data = 0; |
347 | return FALSE; | 352 | return FALSE; |
348 | } | 353 | } |
349 | 354 | ||
350 | d->input.length = stat.st_size; | 355 | d->input.length = stat.st_size; |
351 | 356 | ||
352 | d->input.fdm = map_file(d->input.fd, &d->input.length); | 357 | d->input.fdm = map_file(d->input.fd, &d->input.length); |
353 | if (d->input.fdm == 0) { | 358 | if (d->input.fdm == 0) { |
354 | d->input.data = 0; | 359 | d->input.data = 0; |
355 | return FALSE; | 360 | return FALSE; |
356 | } | 361 | } |
357 | 362 | ||
358 | d->input.data = (unsigned char *)d->input.fdm; | 363 | d->input.data = (unsigned char *)d->input.fdm; |
359 | } | 364 | } |
360 | 365 | ||
361 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); | 366 | mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); |
362 | 367 | ||
363 | } else | 368 | } else |
364 | #endif | 369 | #endif |
365 | { | 370 | { |
366 | if (d->stream.next_frame) { | 371 | if (d->stream.next_frame) { |
367 | memmove(d->input.data, d->stream.next_frame, | 372 | memmove(d->input.data, d->stream.next_frame, |
368 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); | 373 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |
369 | } | 374 | } |
370 | 375 | ||
371 | do { | 376 | do { |
372 | len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); | 377 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); |
373 | } | 378 | } |
374 | while (len == -1 && errno == EINTR); | 379 | while (len == -1 && errno == EINTR); |
375 | 380 | ||
376 | if (len == -1) { | 381 | if (len == -1) { |
377 | qDebug("error reading audio"); | 382 | qDebug("error reading audio"); |
378 | return FALSE; | 383 | return FALSE; |
379 | } | 384 | } |
380 | else if (len == 0) { | 385 | else if (len == 0) { |
381 | d->input.eof = 1; | 386 | d->input.eof = 1; |
382 | 387 | ||
383 | assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); | 388 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); |
384 | 389 | ||
385 | while (len < MAD_BUFFER_GUARD) | 390 | while (len < MAD_BUFFER_GUARD) |
386 | d->input.data[d->input.length + len++] = 0; | 391 | d->input.data[d->input.length + len++] = 0; |
387 | } | 392 | } |
388 | 393 | ||
389 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); | 394 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); |
390 | } | 395 | } |
391 | 396 | ||
392 | return TRUE; | 397 | return TRUE; |
393 | } | 398 | } |
394 | 399 | ||
395 | 400 | ||
396 | static mad_fixed_t left_err, right_err; | 401 | static mad_fixed_t left_err, right_err; |
397 | static const int bits = 16; | 402 | static const int bits = 16; |
398 | static const int shift = MAD_F_FRACBITS + 1 - bits; | 403 | static const int shift = MAD_F_FRACBITS + 1 - bits; |
399 | 404 | ||
400 | 405 | ||
401 | inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error ) | 406 | inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error ) |
402 | { | 407 | { |
403 | sample += error; | 408 | sample += error; |
404 | mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample ); | 409 | mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample ); |
405 | quantized &= ~((1L << shift) - 1); | 410 | quantized &= ~((1L << shift) - 1); |
406 | error = sample - quantized; | 411 | error = sample - quantized; |
407 | return quantized >> shift; | 412 | return quantized >> shift; |
408 | } | 413 | } |
409 | 414 | ||
410 | 415 | ||
411 | inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right ) | 416 | inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right ) |
412 | { | 417 | { |
413 | if ( right ) { | 418 | if ( right ) { |
414 | while (nsamples--) { | 419 | while (nsamples--) { |
415 | data[0] = audio_linear_dither( *left++, left_err ); | 420 | data[0] = audio_linear_dither( *left++, left_err ); |
416 | data[1] = audio_linear_dither( *right++, right_err ); | 421 | data[1] = audio_linear_dither( *right++, right_err ); |
417 | data += 2; | 422 | data += 2; |
418 | } | 423 | } |
419 | } else { | 424 | } else { |
420 | while (nsamples--) { | 425 | while (nsamples--) { |
421 | data[0] = data[1] = audio_linear_dither( *left++, left_err ); | 426 | data[0] = data[1] = audio_linear_dither( *left++, left_err ); |
422 | data += 2; | 427 | data += 2; |
423 | } | 428 | } |
424 | } | 429 | } |
425 | } | 430 | } |
426 | 431 | ||
427 | 432 | ||
428 | bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { | 433 | bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { |
429 | debugMsg( "LibMadPlugin::decode" ); | 434 | debugMsg( "LibMadPlugin::decode" ); |
430 | 435 | ||
431 | static int buffered = 0; | 436 | static int buffered = 0; |
432 | static mad_fixed_t buffer[2][65536 * 2]; | 437 | static mad_fixed_t buffer[2][65536 * 2]; |
433 | int offset = buffered; | 438 | int offset = buffered; |
434 | samplesMade = 0; | 439 | samplesMade = 0; |
435 | 440 | ||
436 | static int maxBuffered = 8000; // 65536; | 441 | static int maxBuffered = 8000; // 65536; |
437 | 442 | ||
438 | if ( samples > maxBuffered ) | 443 | if ( samples > maxBuffered ) |
439 | samples = maxBuffered; | 444 | samples = maxBuffered; |
440 | 445 | ||
441 | if ( d->flush ) { | 446 | if ( d->flush ) { |
442 | buffered = 0; | 447 | buffered = 0; |
443 | offset = 0; | 448 | offset = 0; |
444 | d->flush = FALSE; | 449 | d->flush = FALSE; |
445 | } | 450 | } |
446 | 451 | ||
447 | while ( buffered < maxBuffered ) { | 452 | while ( buffered < maxBuffered ) { |
448 | 453 | ||
449 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { | 454 | while (mad_frame_decode(&d->frame, &d->stream) == -1) { |
450 | if (!MAD_RECOVERABLE(d->stream.error)) { | 455 | if (!MAD_RECOVERABLE(d->stream.error)) { |
451 | debugMsg( "feed me" ); | 456 | debugMsg( "feed me" ); |
452 | return FALSE; // Feed me | 457 | return FALSE; // Feed me |
453 | } | 458 | } |
454 | if ( d->stream.error == MAD_ERROR_BADCRC ) { | 459 | if ( d->stream.error == MAD_ERROR_BADCRC ) { |
455 | mad_frame_mute(&d->frame); | 460 | mad_frame_mute(&d->frame); |
456 | qDebug( "error decoding, bad crc" ); | 461 | qDebug( "error decoding, bad crc" ); |
457 | } | 462 | } |
458 | } | 463 | } |
459 | 464 | ||
460 | mad_synth_frame(&d->synth, &d->frame); | 465 | mad_synth_frame(&d->synth, &d->frame); |
461 | int decodedSamples = d->synth.pcm.length; | 466 | int decodedSamples = d->synth.pcm.length; |
462 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); | 467 | memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); |
463 | if ( d->synth.pcm.channels == 2 ) | 468 | if ( d->synth.pcm.channels == 2 ) |
464 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); | 469 | memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); |
465 | offset += decodedSamples; | 470 | offset += decodedSamples; |
466 | buffered += decodedSamples; | 471 | buffered += decodedSamples; |
467 | } | 472 | } |
468 | //qApp->processEvents(); | 473 | //qApp->processEvents(); |
469 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); | 474 | audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); |
470 | // audio_pcm( output, samples, buffer[1], buffer[0] ); | 475 | // audio_pcm( output, samples, buffer[1], buffer[0] ); |
471 | // audio_pcm( output, samples, buffer[0], buffer[1] ); | 476 | // audio_pcm( output, samples, buffer[0], buffer[1] ); |
472 | samplesMade = samples; | 477 | samplesMade = samples; |
473 | memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); | 478 | memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); |
474 | if ( d->synth.pcm.channels == 2 ) | 479 | if ( d->synth.pcm.channels == 2 ) |
475 | memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); | 480 | memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); |
476 | buffered -= samples; | 481 | buffered -= samples; |
477 | 482 | ||
478 | return TRUE; | 483 | return TRUE; |
479 | } | 484 | } |
480 | 485 | ||
481 | /* | 486 | /* |
482 | bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { | 487 | bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { |
483 | debugMsg( "LibMadPlugin::audioReadMonoSamples" ); | 488 | debugMsg( "LibMadPlugin::audioReadMonoSamples" ); |
484 | return FALSE; | 489 | return FALSE; |
485 | } | 490 | } |
486 | 491 | ||
487 | 492 | ||
488 | bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 493 | bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
489 | */ | 494 | */ |
490 | bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { | 495 | bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { |
491 | debugMsg( "LibMadPlugin::audioReadStereoSamples" ); | 496 | debugMsg( "LibMadPlugin::audioReadStereoSamples" ); |
492 | 497 | ||
493 | static bool needInput = TRUE; | 498 | static bool needInput = TRUE; |
494 | 499 | ||
495 | if ( samples == 0 ) | 500 | if ( samples == 0 ) |
496 | return FALSE; | 501 | return FALSE; |
497 | 502 | ||
498 | do { | 503 | do { |
499 | if ( needInput ) | 504 | if ( needInput ) |
500 | if ( !read() ) { | 505 | if ( !read() ) { |
501 | // if ( d->input.eof ) | 506 | // if ( d->input.eof ) |
502 | // needInput = FALSE; | 507 | // needInput = FALSE; |
503 | // else | 508 | // else |
504 | return FALSE; | 509 | return FALSE; |
505 | } | 510 | } |
506 | 511 | ||
507 | needInput = FALSE; | 512 | needInput = FALSE; |
508 | 513 | ||
509 | if ( decode( output, samples, samplesMade ) ) | 514 | if ( decode( output, samples, samplesMade ) ) |
510 | return TRUE; | 515 | return TRUE; |
511 | else | 516 | else |
512 | needInput = TRUE; | 517 | needInput = TRUE; |
513 | } | 518 | } |
514 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); | 519 | while ( ( samplesMade < samples ) && ( !d->input.eof ) ); |
515 | /* | 520 | /* |
516 | static bool firstTimeThru = TRUE; | 521 | static bool firstTimeThru = TRUE; |
517 | 522 | ||
518 | if ( firstTimeThru ) { | 523 | if ( firstTimeThru ) { |
519 | firstTimeThru = FALSE; | 524 | firstTimeThru = FALSE; |
520 | decode( output, samples, samplesMade ); | 525 | decode( output, samples, samplesMade ); |
521 | return FALSE; | 526 | return FALSE; |
522 | } else | 527 | } else |
523 | */ | 528 | */ |
524 | return FALSE; | 529 | return FALSE; |
525 | } | 530 | } |
526 | 531 | ||
527 | 532 | ||
528 | double LibMadPlugin::getTime() { | 533 | double LibMadPlugin::getTime() { |
529 | debugMsg( "LibMadPlugin::getTime" ); | 534 | debugMsg( "LibMadPlugin::getTime" ); |
530 | return 0.0; | 535 | return 0.0; |
531 | } | 536 | } |
532 | 537 | ||
533 | 538 | ||
534 | void LibMadPlugin::printID3Tags() { | 539 | void LibMadPlugin::printID3Tags() { |
535 | debugMsg( "LibMadPlugin::printID3Tags" ); | 540 | debugMsg( "LibMadPlugin::printID3Tags" ); |
536 | 541 | ||
537 | char id3v1[128 + 1]; | 542 | char id3v1[128 + 1]; |
538 | 543 | ||
539 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { | 544 | if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { |
540 | qDebug( "error seeking to id3 tags" ); | 545 | qDebug( "error seeking to id3 tags" ); |
541 | return; | 546 | return; |
542 | } | 547 | } |
543 | 548 | ||
544 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { | 549 | if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { |
545 | qDebug( "error reading in id3 tags" ); | 550 | qDebug( "error reading in id3 tags" ); |
546 | return; | 551 | return; |
547 | } | 552 | } |
548 | 553 | ||
549 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { | 554 | if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { |
550 | debugMsg( "sorry, no id3 tags" ); | 555 | debugMsg( "sorry, no id3 tags" ); |
551 | } else { | 556 | } else { |
552 | int len[5] = { 30, 30, 30, 4, 30 }; | 557 | int len[5] = { 30, 30, 30, 4, 30 }; |
553 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; | 558 | QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; |
554 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; | 559 | char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; |
555 | qDebug( "ID3 tags in file:" ); | 560 | qDebug( "ID3 tags in file:" ); |
556 | info = ""; | 561 | info = ""; |
557 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { | 562 | for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { |
558 | char push = *ptr2; | 563 | char push = *ptr2; |
559 | *ptr2 = '\0'; | 564 | *ptr2 = '\0'; |
560 | char *ptr3 = ptr2; | 565 | char *ptr3 = ptr2; |
561 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; | 566 | while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; |
562 | char push2 = *ptr3; *ptr3 = '\0'; | 567 | char push2 = *ptr3; *ptr3 = '\0'; |
563 | if ( strcmp( ptr, "" ) ) | 568 | if ( strcmp( ptr, "" ) ) |
564 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; | 569 | info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; |
565 | //qDebug( info.latin1() ); | 570 | //qDebug( info.latin1() ); |
566 | *ptr3 = push2; | 571 | *ptr3 = push2; |
567 | *ptr2 = push; | 572 | *ptr2 = push; |
568 | } | 573 | } |
569 | if (id3v1[126] == 0 && id3v1[127] != 0) | 574 | if (id3v1[126] == 0 && id3v1[127] != 0) |
570 | info += tr( ", Track: " ) + id3v1[127]; | 575 | info += tr( ", Track: " ) + id3v1[127]; |
571 | } | 576 | } |
572 | 577 | ||
573 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { | 578 | if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { |
574 | qDebug( "error seeking back to beginning" ); | 579 | qDebug( "error seeking back to beginning" ); |
575 | return; | 580 | return; |
576 | } | 581 | } |
577 | } | 582 | } |
578 | 583 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index b240b77..46cd4a1 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -1,110 +1,110 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_H | 20 | #ifndef LIBMAD_PLUGIN_H |
21 | #define LIBMAD_PLUGIN_H | 21 | #define LIBMAD_PLUGIN_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qpe/mediaplayerplugininterface.h> | 24 | #include <qpe/mediaplayerplugininterface.h> |
25 | /* #include "../mediaplayerplugininterface.h" */ | 25 | /* #include "../mediaplayerplugininterface.h" */ |
26 | 26 | ||
27 | 27 | ||
28 | // #define OLD_MEDIAPLAYER_API | 28 | // #define OLD_MEDIAPLAYER_API |
29 | 29 | ||
30 | 30 | ||
31 | class LibMadPluginData; | 31 | class LibMadPluginData; |
32 | 32 | ||
33 | 33 | ||
34 | class LibMadPlugin : public MediaPlayerDecoder { | 34 | class LibMadPlugin : public MediaPlayerDecoder { |
35 | 35 | ||
36 | public: | 36 | public: |
37 | LibMadPlugin(); | 37 | LibMadPlugin(); |
38 | ~LibMadPlugin(); | 38 | ~LibMadPlugin(); |
39 | 39 | ||
40 | const char *pluginName() { return "LibMadPlugin"; } | 40 | const char *pluginName() { return "LibMadPlugin"; } |
41 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } | 41 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } |
42 | double pluginVersion() { return 1.0; } | 42 | double pluginVersion() { return 1.0; } |
43 | 43 | ||
44 | bool isFileSupported( const QString& ); | 44 | bool isFileSupported( const QString& ); |
45 | bool open( const QString& ); | 45 | bool open( const QString& ); |
46 | bool close(); | 46 | bool close(); |
47 | bool isOpen(); | 47 | bool isOpen(); |
48 | const QString &fileInfo() { return info; } | 48 | const QString &fileInfo() { return info; } |
49 | 49 | ||
50 | // If decoder doesn't support audio then return 0 here | 50 | // If decoder doesn't support audio then return 0 here |
51 | int audioStreams(); | 51 | int audioStreams(); |
52 | int audioChannels( int stream ); | 52 | int audioChannels( int stream ); |
53 | int audioFrequency( int stream ); | 53 | int audioFrequency( int stream ); |
54 | int audioSamples( int stream ); | 54 | int audioSamples( int stream ); |
55 | bool audioSetSample( long sample, int stream ); | 55 | bool audioSetSample( long sample, int stream ); |
56 | /* int audioBitsPerSample(int) {return 0;} */ | 56 | /* int audioBitsPerSample(int) {return 0;} */ |
57 | long audioGetSample( int stream ); | 57 | long audioGetSample( int stream ); |
58 | #ifdef OLD_MEDIAPLAYER_API | 58 | #ifdef OLD_MEDIAPLAYER_API |
59 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
60 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 61 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
62 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 62 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
63 | #else | 63 | #else |
64 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 64 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
68 | bool read(); | 68 | bool read(); |
69 | bool decode( short *output, long samples, long& samplesRead ); | 69 | bool decode( short *output, long samples, long& samplesRead ); |
70 | void printID3Tags(); | 70 | void printID3Tags(); |
71 | 71 | ||
72 | 72 | ||
73 | // If decoder doesn't support video then return 0 here | 73 | // If decoder doesn't support video then return 0 here |
74 | int videoStreams() { return 0; } | 74 | int videoStreams() { return 0; } |
75 | int videoWidth( int ) { return 0; } | 75 | int videoWidth( int ) { return 0; } |
76 | int videoHeight( int ) { return 0; } | 76 | int videoHeight( int ) { return 0; } |
77 | double videoFrameRate( int ) { return 0.0; } | 77 | double videoFrameRate( int ) { return 0.0; } |
78 | int videoFrames( int ) { return 0; } | 78 | int videoFrames( int ) { return 0; } |
79 | bool videoSetFrame( long, int ) { return FALSE; } | 79 | bool videoSetFrame( long, int ) { return FALSE; } |
80 | long videoGetFrame( int ) { return 0; } | 80 | long videoGetFrame( int ) { return 0; } |
81 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 81 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
82 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 82 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
83 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 83 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
84 | 84 | ||
85 | // Profiling | 85 | // Profiling |
86 | double getTime(); | 86 | double getTime(); |
87 | 87 | ||
88 | // Ignore if these aren't supported | 88 | // Ignore if these aren't supported |
89 | bool setSMP( int ) { return FALSE; } | 89 | bool setSMP( int ) { return FALSE; } |
90 | bool setMMX( bool ) { return FALSE; } | 90 | bool setMMX( bool ) { return FALSE; } |
91 | 91 | ||
92 | // Capabilities | 92 | // Capabilities |
93 | bool supportsAudio() { return TRUE; } | 93 | bool supportsAudio() { return TRUE; } |
94 | bool supportsVideo() { return FALSE; } | 94 | bool supportsVideo() { return FALSE; } |
95 | bool supportsYUV() { return FALSE; } | 95 | bool supportsYUV() { return FALSE; } |
96 | bool supportsMMX() { return TRUE; } | 96 | bool supportsMMX() { return TRUE; } |
97 | bool supportsSMP() { return FALSE; } | 97 | bool supportsSMP() { return FALSE; } |
98 | bool supportsStereo() { return TRUE; } | 98 | bool supportsStereo() { return TRUE; } |
99 | bool supportsScaling() { return FALSE; } | 99 | bool supportsScaling() { return FALSE; } |
100 | 100 | ||
101 | long getPlayTime() { return -1; } | 101 | long getPlayTime() { return -1; } |
102 | 102 | ||
103 | private: | 103 | private: |
104 | LibMadPluginData *d; | 104 | LibMadPluginData *d; |
105 | QString info; | 105 | QString info; |
106 | 106 | int bufferSize; | |
107 | }; | 107 | }; |
108 | 108 | ||
109 | 109 | ||
110 | #endif | 110 | #endif |
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c index c5807a7..c5cae00 100644 --- a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c +++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c | |||
@@ -1,127 +1,127 @@ | |||
1 | #include "mpeg3private.h" | 1 | #include "mpeg3private.h" |
2 | #include "mpeg3protos.h" | 2 | #include "mpeg3protos.h" |
3 | 3 | ||
4 | #ifndef _WIN32 | 4 | #ifndef _WIN32 |
5 | #include <mntent.h> | 5 | #include <mntent.h> |
6 | #else | 6 | #else |
7 | 7 | ||
8 | #endif | 8 | #endif |
9 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | mpeg3_fs_t* mpeg3_new_fs(char *path) | 13 | mpeg3_fs_t* mpeg3_new_fs(char *path) |
14 | { | 14 | { |
15 | mpeg3_fs_t *fs = (mpeg3_fs_t*)calloc(1, sizeof(mpeg3_fs_t)); | 15 | mpeg3_fs_t *fs = (mpeg3_fs_t*)calloc(1, sizeof(mpeg3_fs_t)); |
16 | fs->css = mpeg3_new_css(); | 16 | fs->css = mpeg3_new_css(); |
17 | strcpy(fs->path, path); | 17 | strcpy(fs->path, path); |
18 | return fs; | 18 | return fs; |
19 | } | 19 | } |
20 | 20 | ||
21 | int mpeg3_delete_fs(mpeg3_fs_t *fs) | 21 | int mpeg3_delete_fs(mpeg3_fs_t *fs) |
22 | { | 22 | { |
23 | mpeg3_delete_css(fs->css); | 23 | mpeg3_delete_css(fs->css); |
24 | free(fs); | 24 | free(fs); |
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
27 | 27 | ||
28 | int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) | 28 | int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) |
29 | { | 29 | { |
30 | strcpy(dst->path, src->path); | 30 | strcpy(dst->path, src->path); |
31 | dst->current_byte = 0; | 31 | dst->current_byte = 0; |
32 | return 0; | 32 | return 0; |
33 | } | 33 | } |
34 | 34 | ||
35 | long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) | 35 | long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) |
36 | { | 36 | { |
37 | /* | 37 | |
38 | * struct stat st; | 38 | struct stat st; |
39 | * if(stat(fs->path, &st) < 0) return 0; | 39 | if(stat(fs->path, &st) < 0) return 0; |
40 | * return (long)st.st_size; | 40 | return (long)st.st_size; |
41 | */ | 41 | |
42 | 42 | ||
43 | fseek(fs->fd, 0, SEEK_END); | 43 | /* fseek(fs->fd, 0, SEEK_END); */ |
44 | fs->total_bytes = ftell(fs->fd); | 44 | /* fs->total_bytes = ftell(fs->fd); */ |
45 | fseek(fs->fd, 0, SEEK_SET); | 45 | /* fseek(fs->fd, 0, SEEK_SET); */ |
46 | return fs->total_bytes; | 46 | /* return fs->total_bytes; */ |
47 | } | 47 | } |
48 | 48 | ||
49 | int mpeg3io_open_file(mpeg3_fs_t *fs) | 49 | int mpeg3io_open_file(mpeg3_fs_t *fs) |
50 | { | 50 | { |
51 | /* Need to perform authentication before reading a single byte. */ | 51 | /* Need to perform authentication before reading a single byte. */ |
52 | mpeg3_get_keys(fs->css, fs->path); | 52 | mpeg3_get_keys(fs->css, fs->path); |
53 | 53 | ||
54 | if(!(fs->fd = fopen(fs->path, "rb"))) | 54 | if(!(fs->fd = fopen(fs->path, "rb"))) |
55 | { | 55 | { |
56 | perror("mpeg3io_open_file"); | 56 | perror("mpeg3io_open_file"); |
57 | return 1; | 57 | return 1; |
58 | } | 58 | } |
59 | 59 | ||
60 | fs->total_bytes = mpeg3io_get_total_bytes(fs); | 60 | fs->total_bytes = mpeg3io_get_total_bytes(fs); |
61 | 61 | ||
62 | if(!fs->total_bytes) | 62 | if(!fs->total_bytes) |
63 | { | 63 | { |
64 | fclose(fs->fd); | 64 | fclose(fs->fd); |
65 | return 1; | 65 | return 1; |
66 | } | 66 | } |
67 | fs->current_byte = 0; | 67 | fs->current_byte = 0; |
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | int mpeg3io_close_file(mpeg3_fs_t *fs) | 71 | int mpeg3io_close_file(mpeg3_fs_t *fs) |
72 | { | 72 | { |
73 | if(fs->fd) fclose(fs->fd); | 73 | if(fs->fd) fclose(fs->fd); |
74 | fs->fd = 0; | 74 | fs->fd = 0; |
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | 77 | ||
78 | int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs) | 78 | int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs) |
79 | { | 79 | { |
80 | int result = 0; | 80 | int result = 0; |
81 | //printf("read %d bytes\n",bytes); | 81 | //printf("read %d bytes\n",bytes); |
82 | result = !fread(buffer, 1, bytes, fs->fd); | 82 | result = !fread(buffer, 1, bytes, fs->fd); |
83 | fs->current_byte += bytes; | 83 | fs->current_byte += bytes; |
84 | return (result && bytes); | 84 | return (result && bytes); |
85 | } | 85 | } |
86 | 86 | ||
87 | int mpeg3io_device(char *path, char *device) | 87 | int mpeg3io_device(char *path, char *device) |
88 | { | 88 | { |
89 | struct stat file_st, device_st; | 89 | struct stat file_st, device_st; |
90 | struct mntent *mnt; | 90 | struct mntent *mnt; |
91 | FILE *fp; | 91 | FILE *fp; |
92 | 92 | ||
93 | if(stat(path, &file_st) < 0) | 93 | if(stat(path, &file_st) < 0) |
94 | { | 94 | { |
95 | perror("mpeg3io_device"); | 95 | perror("mpeg3io_device"); |
96 | return 1; | 96 | return 1; |
97 | } | 97 | } |
98 | 98 | ||
99 | #ifndef _WIN32 | 99 | #ifndef _WIN32 |
100 | fp = setmntent(MOUNTED, "r"); | 100 | fp = setmntent(MOUNTED, "r"); |
101 | while(fp && (mnt = getmntent(fp))) | 101 | while(fp && (mnt = getmntent(fp))) |
102 | { | 102 | { |
103 | if(stat(mnt->mnt_fsname, &device_st) < 0) continue; | 103 | if(stat(mnt->mnt_fsname, &device_st) < 0) continue; |
104 | if(device_st.st_rdev == file_st.st_dev) | 104 | if(device_st.st_rdev == file_st.st_dev) |
105 | { | 105 | { |
106 | strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN); | 106 | strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | endmntent(fp); | 110 | endmntent(fp); |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | return 0; | 113 | return 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | int mpeg3io_seek(mpeg3_fs_t *fs, long byte) | 116 | int mpeg3io_seek(mpeg3_fs_t *fs, long byte) |
117 | { | 117 | { |
118 | fs->current_byte = byte; | 118 | fs->current_byte = byte; |
119 | return fseek(fs->fd, byte, SEEK_SET); | 119 | return fseek(fs->fd, byte, SEEK_SET); |
120 | } | 120 | } |
121 | 121 | ||
122 | int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes) | 122 | int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes) |
123 | { | 123 | { |
124 | fs->current_byte += bytes; | 124 | fs->current_byte += bytes; |
125 | return fseek(fs->fd, fs->current_byte, SEEK_SET); | 125 | return fseek(fs->fd, fs->current_byte, SEEK_SET); |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 6259b3f..8f3711a 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,187 +1,203 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/config.h> | ||
23 | |||
22 | #include <qpainter.h> | 24 | #include <qpainter.h> |
23 | #include <qimage.h> | 25 | #include <qimage.h> |
24 | #include <qheader.h> | 26 | #include <qheader.h> |
25 | #include <qlistview.h> | 27 | #include <qlistview.h> |
26 | #include <qlist.h> | 28 | #include <qlist.h> |
27 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
28 | 30 | ||
29 | #include "playlistselection.h" | 31 | #include "playlistselection.h" |
30 | 32 | ||
31 | #include <stdlib.h> | 33 | #include <stdlib.h> |
32 | 34 | ||
33 | class PlayListSelectionItem : public QListViewItem { | 35 | class PlayListSelectionItem : public QListViewItem { |
34 | public: | 36 | public: |
35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
36 | setText( 0, f->name() ); | 38 | setText( 0, f->name() ); |
37 | setPixmap( 0, f->pixmap() ); | 39 | setPixmap( 0, f->pixmap() ); |
38 | } | 40 | } |
39 | 41 | ||
40 | ~PlayListSelectionItem() { | 42 | ~PlayListSelectionItem() { |
41 | }; | 43 | }; |
42 | 44 | ||
43 | const DocLnk *file() const { return fl; } | 45 | const DocLnk *file() const { return fl; } |
44 | 46 | ||
45 | private: | 47 | private: |
46 | const DocLnk *fl; | 48 | const DocLnk *fl; |
47 | }; | 49 | }; |
48 | 50 | ||
49 | 51 | ||
50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
51 | : QListView( parent, name ) | 53 | : QListView( parent, name ) |
52 | { | 54 | { |
53 | qDebug("starting playlistselector"); | 55 | // qDebug("starting playlistselector"); |
54 | // #ifdef USE_PLAYLIST_BACKGROUND | 56 | // #ifdef USE_PLAYLIST_BACKGROUND |
55 | // setStaticBackground( TRUE ); | 57 | // setStaticBackground( TRUE ); |
56 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 58 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
57 | 59 | ||
58 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
59 | // #endif | 61 | // #endif |
60 | // addColumn("Title",236); | 62 | // addColumn("Title",236); |
61 | // setAllColumnsShowFocus( TRUE ); | 63 | // setAllColumnsShowFocus( TRUE ); |
62 | addColumn( tr( "Playlist Selection" ) ); | 64 | addColumn( tr( "Playlist Selection" ) ); |
63 | header()->hide(); | 65 | header()->hide(); |
64 | setSorting( -1, FALSE ); | 66 | setSorting( -1, FALSE ); |
65 | } | 67 | } |
66 | 68 | ||
67 | 69 | ||
68 | PlayListSelection::~PlayListSelection() { | 70 | PlayListSelection::~PlayListSelection() { |
69 | } | 71 | } |
70 | 72 | ||
71 | 73 | ||
72 | // #ifdef USE_PLAYLIST_BACKGROUND | 74 | // #ifdef USE_PLAYLIST_BACKGROUND |
73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
74 | // qDebug("drawBackground"); | 76 | // qDebug("drawBackground"); |
75 | p->fillRect( r, QBrush( white ) ); | 77 | p->fillRect( r, QBrush( white ) ); |
76 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
77 | // if ( !logo.isNull() ) | 79 | // if ( !logo.isNull() ) |
78 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
79 | } | 81 | } |
80 | // #endif | 82 | // #endif |
81 | 83 | ||
82 | 84 | ||
83 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
84 | if ( event->state() == QMouseEvent::LeftButton ) { | 86 | if ( event->state() == QMouseEvent::LeftButton ) { |
85 | QListViewItem *currentItem = selectedItem(); | 87 | QListViewItem *currentItem = selectedItem(); |
86 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
87 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
88 | moveSelectedUp(); | 90 | moveSelectedUp(); |
89 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
90 | moveSelectedDown(); | 92 | moveSelectedDown(); |
91 | } | 93 | } |
92 | } | 94 | } |
93 | 95 | ||
94 | 96 | ||
95 | const DocLnk *PlayListSelection::current() { | 97 | const DocLnk *PlayListSelection::current() { |
96 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
97 | if ( item ) | 99 | if ( item ) |
98 | return item->file(); | 100 | return item->file(); |
99 | return NULL; | 101 | return NULL; |
100 | } | 102 | } |
101 | 103 | ||
102 | 104 | ||
103 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
104 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
105 | QListViewItem *current = selectedItem(); | 107 | QListViewItem *current = selectedItem(); |
106 | if ( current ) | 108 | if ( current ) |
107 | item->moveItem( current ); | 109 | item->moveItem( current ); |
108 | setSelected( item, TRUE ); | 110 | setSelected( item, TRUE ); |
109 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
110 | } | 112 | } |
111 | 113 | ||
112 | 114 | ||
113 | void PlayListSelection::removeSelected() { | 115 | void PlayListSelection::removeSelected() { |
114 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
115 | if ( item ) | 117 | if ( item ) |
116 | delete item; | 118 | delete item; |
117 | setSelected( currentItem(), TRUE ); | 119 | setSelected( currentItem(), TRUE ); |
118 | ensureItemVisible( selectedItem() ); | 120 | ensureItemVisible( selectedItem() ); |
119 | } | 121 | } |
120 | 122 | ||
121 | 123 | ||
122 | void PlayListSelection::moveSelectedUp() { | 124 | void PlayListSelection::moveSelectedUp() { |
123 | QListViewItem *item = selectedItem(); | 125 | QListViewItem *item = selectedItem(); |
124 | if ( item && item->itemAbove() ) | 126 | if ( item && item->itemAbove() ) |
125 | item->itemAbove()->moveItem( item ); | 127 | item->itemAbove()->moveItem( item ); |
126 | ensureItemVisible( selectedItem() ); | 128 | ensureItemVisible( selectedItem() ); |
127 | } | 129 | } |
128 | 130 | ||
129 | 131 | ||
130 | void PlayListSelection::moveSelectedDown() { | 132 | void PlayListSelection::moveSelectedDown() { |
131 | QListViewItem *item = selectedItem(); | 133 | QListViewItem *item = selectedItem(); |
132 | if ( item && item->itemBelow() ) | 134 | if ( item && item->itemBelow() ) |
133 | item->moveItem( item->itemBelow() ); | 135 | item->moveItem( item->itemBelow() ); |
134 | ensureItemVisible( selectedItem() ); | 136 | ensureItemVisible( selectedItem() ); |
135 | } | 137 | } |
136 | 138 | ||
137 | 139 | ||
138 | bool PlayListSelection::prev() { | 140 | bool PlayListSelection::prev() { |
139 | QListViewItem *item = selectedItem(); | 141 | QListViewItem *item = selectedItem(); |
140 | if ( item && item->itemAbove() ) | 142 | if ( item && item->itemAbove() ) |
141 | setSelected( item->itemAbove(), TRUE ); | 143 | setSelected( item->itemAbove(), TRUE ); |
142 | else | 144 | else |
143 | return FALSE; | 145 | return FALSE; |
144 | ensureItemVisible( selectedItem() ); | 146 | ensureItemVisible( selectedItem() ); |
145 | return TRUE; | 147 | return TRUE; |
146 | } | 148 | } |
147 | 149 | ||
148 | bool PlayListSelection::next() { | 150 | bool PlayListSelection::next() { |
149 | QListViewItem *item = selectedItem(); | 151 | QListViewItem *item = selectedItem(); |
150 | if ( item && item->itemBelow() ) | 152 | if ( item && item->itemBelow() ) |
151 | setSelected( item->itemBelow(), TRUE ); | 153 | setSelected( item->itemBelow(), TRUE ); |
152 | else | 154 | else |
153 | return FALSE; | 155 | return FALSE; |
154 | ensureItemVisible( selectedItem() ); | 156 | ensureItemVisible( selectedItem() ); |
155 | return TRUE; | 157 | return TRUE; |
156 | } | 158 | } |
157 | 159 | ||
158 | 160 | ||
159 | bool PlayListSelection::first() { | 161 | bool PlayListSelection::first() { |
160 | QListViewItem *item = firstChild(); | 162 | QListViewItem *item = firstChild(); |
161 | if ( item ) | 163 | if ( item ) |
162 | setSelected( item, TRUE ); | 164 | setSelected( item, TRUE ); |
163 | else | 165 | else |
164 | return FALSE; | 166 | return FALSE; |
165 | ensureItemVisible( selectedItem() ); | 167 | ensureItemVisible( selectedItem() ); |
166 | return TRUE; | 168 | return TRUE; |
167 | } | 169 | } |
168 | 170 | ||
169 | 171 | ||
170 | bool PlayListSelection::last() { | 172 | bool PlayListSelection::last() { |
171 | QListViewItem *prevItem = NULL; | 173 | QListViewItem *prevItem = NULL; |
172 | QListViewItem *item = firstChild(); | 174 | QListViewItem *item = firstChild(); |
173 | while ( ( item = item->nextSibling() ) ) | 175 | while ( ( item = item->nextSibling() ) ) |
174 | prevItem = item; | 176 | prevItem = item; |
175 | if ( prevItem ) | 177 | if ( prevItem ) |
176 | setSelected( prevItem, TRUE ); | 178 | setSelected( prevItem, TRUE ); |
177 | else | 179 | else |
178 | return FALSE; | 180 | return FALSE; |
179 | ensureItemVisible( selectedItem() ); | 181 | ensureItemVisible( selectedItem() ); |
180 | return TRUE; | 182 | return TRUE; |
181 | } | 183 | } |
182 | 184 | ||
183 | void PlayListSelection::unSelect() | 185 | void PlayListSelection::unSelect() |
184 | { | 186 | { |
185 | QListViewItem *item = selectedItem(); | 187 | QListViewItem *item = selectedItem(); |
186 | setSelected( currentItem(), FALSE); | 188 | setSelected( currentItem(), FALSE); |
187 | } \ No newline at end of file | 189 | } |
190 | |||
191 | void PlayListSelection::writeCurrent( Config& cfg ) { | ||
192 | cfg.setGroup("PlayList"); | ||
193 | QListViewItem *item = selectedItem(); | ||
194 | if ( item ) | ||
195 | cfg.writeEntry("current", item->text(0) ); | ||
196 | qDebug(item->text(0)); | ||
197 | |||
198 | } | ||
199 | |||
200 | void PlayListSelection::setSelectedItem(const QString &strk ) { | ||
201 | // setSelected( item, TRUE ); | ||
202 | // ensureItemVisible( selectedItem() ); | ||
203 | } | ||
diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index ba37271..d10bc82 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h | |||
@@ -1,61 +1,63 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | #include <qlist.h> | 23 | #include <qlist.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | #include <qpe/config.h> | |
27 | 27 | ||
28 | class PlayListSelection : public QListView { | 28 | class PlayListSelection : public QListView { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | PlayListSelection( QWidget *parent, const char *name=0 ); | 31 | PlayListSelection( QWidget *parent, const char *name=0 ); |
32 | ~PlayListSelection(); | 32 | ~PlayListSelection(); |
33 | 33 | ||
34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) | 34 | const DocLnk *current(); // retrieve the current playlist entry (media file link) |
35 | public slots: | 35 | public slots: |
36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 36 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
37 | void removeSelected(); // Remove a media file from the playlist | 37 | void removeSelected(); // Remove a media file from the playlist |
38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 38 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 39 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
40 | void unSelect(); | 40 | void unSelect(); |
41 | void writeCurrent( Config &); | ||
42 | void setSelectedItem( const QString & ); | ||
41 | bool prev(); | 43 | bool prev(); |
42 | bool next(); | 44 | bool next(); |
43 | bool first(); | 45 | bool first(); |
44 | bool last(); | 46 | bool last(); |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 49 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
48 | /* #ifdef USE_PLAYLIST_BACKGROUND */ | 50 | /* #ifdef USE_PLAYLIST_BACKGROUND */ |
49 | virtual void drawBackground( QPainter *p, const QRect &r ); | 51 | virtual void drawBackground( QPainter *p, const QRect &r ); |
50 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 52 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
51 | /* #endif */ | 53 | /* #endif */ |
52 | 54 | ||
53 | private: | 55 | private: |
54 | QList<DocLnk> selectedList; | 56 | QList<DocLnk> selectedList; |
55 | const DocLnk *lnk; | 57 | const DocLnk *lnk; |
56 | }; | 58 | }; |
57 | 59 | ||
58 | 60 | ||
59 | #endif // PLAY_LIST_SELECTION_H | 61 | #endif // PLAY_LIST_SELECTION_H |
60 | 62 | ||
61 | 63 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3b8f6d7..63df715 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,941 +1,967 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | #include <qpe/qpetoolbar.h> |
25 | #include <qpe/fileselector.h> | 25 | #include <qpe/fileselector.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/lnkproperties.h> | 27 | #include <qpe/lnkproperties.h> |
28 | #include <qpe/storage.h> | ||
28 | 29 | ||
29 | #include <qpe/applnk.h> | 30 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
32 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
33 | #include <qaction.h> | 34 | #include <qaction.h> |
34 | #include <qimage.h> | 35 | #include <qimage.h> |
35 | #include <qfile.h> | 36 | #include <qfile.h> |
36 | #include <qdir.h> | 37 | #include <qdir.h> |
37 | #include <qlayout.h> | 38 | #include <qlayout.h> |
38 | #include <qlabel.h> | 39 | #include <qlabel.h> |
39 | #include <qlist.h> | 40 | #include <qlist.h> |
40 | #include <qlistbox.h> | 41 | #include <qlistbox.h> |
41 | #include <qmainwindow.h> | 42 | #include <qmainwindow.h> |
42 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
43 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
44 | #include <qtabwidget.h> | 45 | #include <qtabwidget.h> |
45 | #include <qlistview.h> | 46 | #include <qlistview.h> |
46 | #include <qpoint.h> | 47 | #include <qpoint.h> |
47 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
48 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
49 | 50 | ||
50 | //#include <qtimer.h> | 51 | //#include <qtimer.h> |
51 | 52 | ||
52 | #include "playlistselection.h" | 53 | #include "playlistselection.h" |
53 | #include "playlistwidget.h" | 54 | #include "playlistwidget.h" |
54 | #include "mediaplayerstate.h" | 55 | #include "mediaplayerstate.h" |
55 | 56 | ||
56 | #include "inputDialog.h" | 57 | #include "inputDialog.h" |
57 | 58 | ||
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
59 | 60 | ||
60 | #define BUTTONS_ON_TOOLBAR | 61 | #define BUTTONS_ON_TOOLBAR |
61 | #define SIDE_BUTTONS | 62 | #define SIDE_BUTTONS |
62 | #define CAN_SAVE_LOAD_PLAYLISTS | 63 | #define CAN_SAVE_LOAD_PLAYLISTS |
63 | 64 | ||
64 | extern MediaPlayerState *mediaPlayerState; | 65 | extern MediaPlayerState *mediaPlayerState; |
65 | 66 | ||
66 | // class myFileSelector { | 67 | // class myFileSelector { |
67 | 68 | ||
68 | // }; | 69 | // }; |
69 | class PlayListWidgetPrivate { | 70 | class PlayListWidgetPrivate { |
70 | public: | 71 | public: |
71 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
72 | QFrame *playListFrame; | 73 | QFrame *playListFrame; |
73 | FileSelector *files; | 74 | FileSelector *files; |
74 | PlayListSelection *selectedFiles; | 75 | PlayListSelection *selectedFiles; |
75 | bool setDocumentUsed; | 76 | bool setDocumentUsed; |
76 | DocLnk *current; | 77 | DocLnk *current; |
77 | }; | 78 | }; |
78 | 79 | ||
79 | 80 | ||
80 | class ToolButton : public QToolButton { | 81 | class ToolButton : public QToolButton { |
81 | public: | 82 | public: |
82 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
83 | : QToolButton( parent, name ) { | 84 | : QToolButton( parent, name ) { |
84 | setTextLabel( name ); | 85 | setTextLabel( name ); |
85 | setPixmap( Resource::loadPixmap( icon ) ); | 86 | setPixmap( Resource::loadPixmap( icon ) ); |
86 | setAutoRaise( TRUE ); | 87 | setAutoRaise( TRUE ); |
87 | setFocusPolicy( QWidget::NoFocus ); | 88 | setFocusPolicy( QWidget::NoFocus ); |
88 | setToggleButton( t ); | 89 | setToggleButton( t ); |
89 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
90 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 91 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
91 | } | 92 | } |
92 | }; | 93 | }; |
93 | 94 | ||
94 | 95 | ||
95 | class MenuItem : public QAction { | 96 | class MenuItem : public QAction { |
96 | public: | 97 | public: |
97 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
98 | : QAction( text, QString::null, 0, 0 ) { | 99 | : QAction( text, QString::null, 0, 0 ) { |
99 | connect( this, SIGNAL( activated() ), handler, slot ); | 100 | connect( this, SIGNAL( activated() ), handler, slot ); |
100 | addTo( parent ); | 101 | addTo( parent ); |
101 | } | 102 | } |
102 | }; | 103 | }; |
103 | 104 | ||
104 | 105 | ||
105 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
106 | : QMainWindow( parent, name, fl ) { | 107 | : QMainWindow( parent, name, fl ) { |
107 | 108 | ||
108 | d = new PlayListWidgetPrivate; | 109 | d = new PlayListWidgetPrivate; |
109 | d->setDocumentUsed = FALSE; | 110 | d->setDocumentUsed = FALSE; |
110 | d->current = NULL; | 111 | d->current = NULL; |
111 | fromSetDocument = FALSE; | 112 | fromSetDocument = FALSE; |
112 | insanityBool=FALSE; | 113 | insanityBool=FALSE; |
113 | // menuTimer = new QTimer( this ,"menu timer"), | 114 | // menuTimer = new QTimer( this ,"menu timer"), |
114 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
115 | 116 | ||
116 | setBackgroundMode( PaletteButton ); | 117 | setBackgroundMode( PaletteButton ); |
117 | 118 | ||
118 | setCaption( tr("OpiePlayer") ); | 119 | setCaption( tr("OpiePlayer") ); |
119 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
120 | 121 | ||
121 | setToolBarsMovable( FALSE ); | 122 | setToolBarsMovable( FALSE ); |
122 | 123 | ||
123 | // Create Toolbar | 124 | // Create Toolbar |
124 | QPEToolBar *toolbar = new QPEToolBar( this ); | 125 | QPEToolBar *toolbar = new QPEToolBar( this ); |
125 | toolbar->setHorizontalStretchable( TRUE ); | 126 | toolbar->setHorizontalStretchable( TRUE ); |
126 | 127 | ||
127 | // Create Menubar | 128 | // Create Menubar |
128 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
129 | menu->setMargin( 0 ); | 130 | menu->setMargin( 0 ); |
130 | 131 | ||
131 | QPEToolBar *bar = new QPEToolBar( this ); | 132 | QPEToolBar *bar = new QPEToolBar( this ); |
132 | bar->setLabel( tr( "Play Operations" ) ); | 133 | bar->setLabel( tr( "Play Operations" ) ); |
133 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", | 134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
134 | // this , SLOT( addSelected()) ); | 135 | // this , SLOT( addSelected()) ); |
135 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
136 | tbDeletePlaylist->setFlat(TRUE); | 137 | tbDeletePlaylist->setFlat(TRUE); |
137 | tbDeletePlaylist->setFixedSize(20,20); | 138 | tbDeletePlaylist->setFixedSize(20,20); |
138 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
139 | 140 | ||
140 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
141 | this , SLOT(addSelected()) ); | 142 | this , SLOT(addSelected()) ); |
142 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
143 | this , SLOT(removeSelected()) ); | 144 | this , SLOT(removeSelected()) ); |
144 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
145 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
146 | this , SLOT( btnPlay(bool) ), TRUE ); | 147 | this , SLOT( btnPlay(bool) ), TRUE ); |
147 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | 148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", |
148 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
149 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | 150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", |
150 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
151 | tbDeletePlaylist->hide(); | 152 | tbDeletePlaylist->hide(); |
152 | 153 | ||
153 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
154 | menu->insertItem( tr( "File" ), pmPlayList ); | 155 | menu->insertItem( tr( "File" ), pmPlayList ); |
155 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
156 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
157 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
158 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
159 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
160 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
161 | 162 | ||
162 | QPopupMenu *pmView = new QPopupMenu( this ); | 163 | QPopupMenu *pmView = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
164 | 165 | ||
165 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
166 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
167 | fullScreenButton->addTo(pmView); | 168 | fullScreenButton->addTo(pmView); |
168 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
169 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
170 | scaleButton->addTo(pmView); | 171 | scaleButton->addTo(pmView); |
171 | 172 | ||
172 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
173 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
174 | 175 | ||
175 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
176 | 177 | ||
177 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
178 | tabWidget->setTabShape(QTabWidget::Triangular); | 179 | tabWidget->setTabShape(QTabWidget::Triangular); |
179 | 180 | ||
180 | QWidget *pTab; | 181 | QWidget *pTab; |
181 | pTab = new QWidget( tabWidget, "pTab" ); | 182 | pTab = new QWidget( tabWidget, "pTab" ); |
182 | // playlistView = new QListView( pTab, "playlistview" ); | 183 | // playlistView = new QListView( pTab, "playlistview" ); |
183 | // playlistView->setMinimumSize(236,260); | 184 | // playlistView->setMinimumSize(236,260); |
184 | tabWidget->insertTab( pTab,"Playlist"); | 185 | tabWidget->insertTab( pTab,"Playlist"); |
185 | 186 | ||
186 | 187 | ||
187 | // Add the playlist area | 188 | // Add the playlist area |
188 | 189 | ||
189 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
190 | d->playListFrame = vbox3; | 191 | d->playListFrame = vbox3; |
191 | d->playListFrame ->setMinimumSize(235,260); | 192 | d->playListFrame ->setMinimumSize(235,260); |
192 | 193 | ||
193 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
194 | 195 | ||
195 | d->selectedFiles = new PlayListSelection( hbox2); | 196 | d->selectedFiles = new PlayListSelection( hbox2); |
196 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
197 | 198 | ||
198 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
199 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
200 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
201 | 202 | ||
202 | 203 | ||
203 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
204 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
205 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
206 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
207 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
208 | 209 | ||
209 | QWidget *aTab; | 210 | QWidget *aTab; |
210 | aTab = new QWidget( tabWidget, "aTab" ); | 211 | aTab = new QWidget( tabWidget, "aTab" ); |
211 | audioView = new QListView( aTab, "Audioview" ); | 212 | audioView = new QListView( aTab, "Audioview" ); |
212 | audioView->setMinimumSize(233,260); | 213 | audioView->setMinimumSize(233,260); |
213 | audioView->addColumn( tr("Title"),140); | 214 | audioView->addColumn( tr("Title"),140); |
214 | audioView->addColumn(tr("Size"), -1); | 215 | audioView->addColumn(tr("Size"), -1); |
215 | audioView->addColumn(tr("Media"),-1); | 216 | audioView->addColumn(tr("Media"),-1); |
216 | audioView->setColumnAlignment(1, Qt::AlignRight); | 217 | audioView->setColumnAlignment(1, Qt::AlignRight); |
217 | audioView->setColumnAlignment(2, Qt::AlignRight); | 218 | audioView->setColumnAlignment(2, Qt::AlignRight); |
218 | audioView->setAllColumnsShowFocus(TRUE); | 219 | audioView->setAllColumnsShowFocus(TRUE); |
220 | // audioView->setMultiSelection( TRUE ); | ||
221 | // audioView->setSelectionMode( QListView::Extended); | ||
222 | |||
219 | tabWidget->insertTab(aTab,tr("Audio")); | 223 | tabWidget->insertTab(aTab,tr("Audio")); |
220 | 224 | ||
221 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
222 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
223 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
224 | 228 | ||
225 | 229 | ||
226 | // audioView | 230 | // audioView |
227 | populateAudioView(); | 231 | populateAudioView(); |
228 | // videowidget | 232 | // videowidget |
229 | 233 | ||
230 | QWidget *vTab; | 234 | QWidget *vTab; |
231 | vTab = new QWidget( tabWidget, "vTab" ); | 235 | vTab = new QWidget( tabWidget, "vTab" ); |
232 | videoView = new QListView( vTab, "Videoview" ); | 236 | videoView = new QListView( vTab, "Videoview" ); |
233 | videoView->setMinimumSize(233,260); | 237 | videoView->setMinimumSize(233,260); |
234 | 238 | ||
235 | videoView->addColumn(tr("Title"),140); | 239 | videoView->addColumn(tr("Title"),140); |
236 | videoView->addColumn(tr("Size"),-1); | 240 | videoView->addColumn(tr("Size"),-1); |
237 | videoView->addColumn(tr("Media"),-1); | 241 | videoView->addColumn(tr("Media"),-1); |
238 | videoView->setColumnAlignment(1, Qt::AlignRight); | 242 | videoView->setColumnAlignment(1, Qt::AlignRight); |
239 | videoView->setColumnAlignment(2, Qt::AlignRight); | 243 | videoView->setColumnAlignment(2, Qt::AlignRight); |
240 | videoView->setAllColumnsShowFocus(TRUE); | 244 | videoView->setAllColumnsShowFocus(TRUE); |
245 | // videoView->setMultiSelection( TRUE ); | ||
246 | // videoView->setSelectionMode( QListView::Extended); | ||
247 | |||
241 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
242 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
243 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
244 | 251 | ||
245 | tabWidget->insertTab( vTab,tr("Video")); | 252 | tabWidget->insertTab( vTab,tr("Video")); |
246 | 253 | ||
247 | 254 | ||
248 | //playlists list | 255 | //playlists list |
249 | QWidget *LTab; | 256 | QWidget *LTab; |
250 | LTab = new QWidget( tabWidget, "LTab" ); | 257 | LTab = new QWidget( tabWidget, "LTab" ); |
251 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 258 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
252 | playLists->setMinimumSize(233,260);; | 259 | playLists->setMinimumSize(233,260);; |
253 | tabWidget->insertTab(LTab,tr("Lists")); | 260 | tabWidget->insertTab(LTab,tr("Lists")); |
254 | 261 | ||
255 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 262 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
256 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
257 | 264 | ||
258 | 265 | ||
259 | // add the library area | 266 | // add the library area |
260 | 267 | ||
261 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 268 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
262 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 269 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
263 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 270 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
264 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 271 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
265 | 272 | ||
266 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 273 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
267 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 274 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
268 | 275 | ||
269 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 276 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
270 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 277 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
271 | 278 | ||
272 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 279 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
273 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 280 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
274 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 281 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
275 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 282 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
276 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 283 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
277 | 284 | ||
278 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 285 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
279 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 286 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
280 | 287 | ||
281 | setCentralWidget( vbox5 ); | 288 | setCentralWidget( vbox5 ); |
282 | 289 | ||
283 | Config cfg( "MediaPlayer" ); | 290 | Config cfg( "MediaPlayer" ); |
284 | readConfig( cfg ); | 291 | readConfig( cfg ); |
285 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 292 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
286 | // qDebug("currentList is "+currentPlaylist); | 293 | // qDebug("currentList is "+currentPlaylist); |
287 | loadList(DocLnk( currentPlaylist)); | 294 | loadList(DocLnk( currentPlaylist)); |
288 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 295 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
289 | 296 | ||
290 | initializeStates(); | 297 | initializeStates(); |
291 | } | 298 | } |
292 | 299 | ||
293 | 300 | ||
294 | PlayListWidget::~PlayListWidget() { | 301 | PlayListWidget::~PlayListWidget() { |
295 | Config cfg( "MediaPlayer" ); | 302 | Config cfg( "MediaPlayer" ); |
296 | writeConfig( cfg ); | 303 | writeConfig( cfg ); |
297 | 304 | ||
298 | 305 | ||
299 | if ( d->current ) | 306 | if ( d->current ) |
300 | delete d->current; | 307 | delete d->current; |
301 | delete d; | 308 | delete d; |
302 | } | 309 | } |
303 | 310 | ||
304 | 311 | ||
305 | void PlayListWidget::initializeStates() { | 312 | void PlayListWidget::initializeStates() { |
306 | 313 | ||
307 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 314 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
308 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 315 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
309 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 316 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
310 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 317 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
311 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 318 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
312 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 319 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
313 | // setPlaylist( mediaPlayerState->playlist() ); | 320 | // setPlaylist( mediaPlayerState->playlist() ); |
314 | setPlaylist( true); | 321 | setPlaylist( true); |
315 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
316 | } | 323 | } |
317 | 324 | ||
318 | 325 | ||
319 | void PlayListWidget::readConfig( Config& cfg ) { | 326 | void PlayListWidget::readConfig( Config& cfg ) { |
320 | cfg.setGroup("PlayList"); | 327 | cfg.setGroup("PlayList"); |
321 | 328 | QString currentString = cfg.readEntry("current", "" ); | |
322 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 329 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
323 | |||
324 | for ( int i = 0; i < noOfFiles; i++ ) { | 330 | for ( int i = 0; i < noOfFiles; i++ ) { |
325 | QString entryName; | 331 | QString entryName; |
326 | entryName.sprintf( "File%i", i + 1 ); | 332 | entryName.sprintf( "File%i", i + 1 ); |
327 | QString linkFile = cfg.readEntry( entryName ); | 333 | QString linkFile = cfg.readEntry( entryName ); |
328 | DocLnk lnk( linkFile ); | 334 | DocLnk lnk( linkFile ); |
329 | if ( lnk.isValid() ) | 335 | if ( lnk.isValid() ) { |
330 | d->selectedFiles->addToSelection( lnk ); | 336 | d->selectedFiles->addToSelection( lnk ); |
337 | } | ||
331 | } | 338 | } |
339 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | ||
332 | } | 340 | } |
333 | 341 | ||
334 | 342 | ||
335 | void PlayListWidget::writeConfig( Config& cfg ) const { | 343 | void PlayListWidget::writeConfig( Config& cfg ) const { |
336 | cfg.setGroup("PlayList"); | ||
337 | 344 | ||
345 | d->selectedFiles->writeCurrent( cfg); | ||
346 | cfg.setGroup("PlayList"); | ||
338 | int noOfFiles = 0; | 347 | int noOfFiles = 0; |
339 | |||
340 | d->selectedFiles->first(); | 348 | d->selectedFiles->first(); |
341 | do { | 349 | do { |
342 | const DocLnk *lnk = d->selectedFiles->current(); | 350 | const DocLnk *lnk = d->selectedFiles->current(); |
343 | if ( lnk ) { | 351 | if ( lnk ) { |
344 | QString entryName; | 352 | QString entryName; |
345 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 353 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
346 | cfg.writeEntry( entryName, lnk->linkFile() ); | 354 | qDebug(entryName); |
347 | // if this link does exist, add it so we have the file | 355 | cfg.writeEntry( entryName, lnk->linkFile() ); |
348 | // next time... | 356 | // if this link does exist, add it so we have the file |
349 | if ( !QFile::exists( lnk->linkFile() ) ) { | 357 | // next time... |
350 | // the way writing lnks doesn't really check for out | 358 | if ( !QFile::exists( lnk->linkFile() ) ) { |
351 | // of disk space, but check it anyway. | 359 | // the way writing lnks doesn't really check for out |
352 | if ( !lnk->writeLink() ) { | 360 | // of disk space, but check it anyway. |
353 | QMessageBox::critical( 0, tr("Out of space"), | 361 | if ( !lnk->writeLink() ) { |
354 | tr( "There was a problem saving " | 362 | QMessageBox::critical( 0, tr("Out of space"), |
355 | "the playlist.\n" | 363 | tr( "There was a problem saving " |
356 | "Your playlist " | 364 | "the playlist.\n" |
357 | "may be missing some entries\n" | 365 | "Your playlist " |
358 | "the next time you start it." ) | 366 | "may be missing some entries\n" |
359 | ); | 367 | "the next time you start it." ) |
368 | ); | ||
369 | } | ||
370 | } | ||
371 | noOfFiles++; | ||
372 | } | ||
360 | } | 373 | } |
361 | } | 374 | while ( d->selectedFiles->next() ); |
362 | noOfFiles++; | ||
363 | } | ||
364 | } while ( d->selectedFiles->next() ); | ||
365 | |||
366 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 375 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
367 | |||
368 | |||
369 | } | 376 | } |
370 | 377 | ||
371 | 378 | ||
372 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 379 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
373 | // qDebug("add"); | 380 | // qDebug("add"); |
374 | d->setDocumentUsed = FALSE; | 381 | d->setDocumentUsed = FALSE; |
375 | if ( mediaPlayerState->playlist() ) | 382 | if ( mediaPlayerState->playlist() ) |
376 | d->selectedFiles->addToSelection( lnk ); | 383 | d->selectedFiles->addToSelection( lnk ); |
377 | else | 384 | else |
378 | mediaPlayerState->setPlaying( TRUE ); | 385 | mediaPlayerState->setPlaying( TRUE ); |
379 | } | 386 | } |
380 | 387 | ||
381 | 388 | ||
382 | void PlayListWidget::clearList() { | 389 | void PlayListWidget::clearList() { |
383 | while ( first() ) | 390 | while ( first() ) |
384 | d->selectedFiles->removeSelected(); | 391 | d->selectedFiles->removeSelected(); |
385 | } | 392 | } |
386 | 393 | ||
387 | 394 | ||
388 | void PlayListWidget::addAllToList() { | 395 | void PlayListWidget::addAllToList() { |
389 | DocLnkSet files; | 396 | DocLnkSet filesAll; |
390 | Global::findDocuments(&files, "video/*;audio/*"); | 397 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
391 | QListIterator<DocLnk> dit( files.children() ); | 398 | QListIterator<DocLnk> Adit( filesAll.children() ); |
392 | for ( ; dit.current(); ++dit ) | 399 | for ( ; Adit.current(); ++Adit ) |
393 | d->selectedFiles->addToSelection( **dit ); | 400 | d->selectedFiles->addToSelection( **Adit ); |
394 | } | 401 | } |
395 | 402 | ||
396 | 403 | ||
397 | void PlayListWidget::addAllMusicToList() { | 404 | void PlayListWidget::addAllMusicToList() { |
398 | DocLnkSet files; | 405 | // DocLnkSet files; |
399 | Global::findDocuments(&files, "audio/*"); | 406 | // Global::findDocuments(&files, "audio/*"); |
400 | QListIterator<DocLnk> dit( files.children() ); | 407 | QListIterator<DocLnk> dit( files.children() ); |
401 | for ( ; dit.current(); ++dit ) | 408 | for ( ; dit.current(); ++dit ) |
402 | d->selectedFiles->addToSelection( **dit ); | 409 | d->selectedFiles->addToSelection( **dit ); |
403 | } | 410 | } |
404 | 411 | ||
405 | 412 | ||
406 | void PlayListWidget::addAllVideoToList() { | 413 | void PlayListWidget::addAllVideoToList() { |
407 | DocLnkSet files; | 414 | QListIterator<DocLnk> dit( vFiles.children() ); |
408 | Global::findDocuments(&files, "video/*"); | ||
409 | QListIterator<DocLnk> dit( files.children() ); | ||
410 | for ( ; dit.current(); ++dit ) | 415 | for ( ; dit.current(); ++dit ) |
411 | d->selectedFiles->addToSelection( **dit ); | 416 | d->selectedFiles->addToSelection( **dit ); |
412 | } | 417 | } |
413 | 418 | ||
414 | 419 | ||
415 | void PlayListWidget::setDocument(const QString& fileref) { | 420 | void PlayListWidget::setDocument(const QString& fileref) { |
416 | fromSetDocument = TRUE; | 421 | fromSetDocument = TRUE; |
417 | if ( fileref.isNull() ) { | 422 | if ( fileref.isNull() ) { |
418 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 423 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
419 | return; | 424 | return; |
420 | } | 425 | } |
421 | // qDebug("setDocument "+fileref); | 426 | // qDebug("setDocument "+fileref); |
422 | if(fileref.find("playlist",0,TRUE) == -1) { | 427 | if(fileref.find("playlist",0,TRUE) == -1) { |
423 | clearList(); | 428 | clearList(); |
424 | addToSelection( DocLnk( fileref ) ); | 429 | addToSelection( DocLnk( fileref ) ); |
425 | d->setDocumentUsed = TRUE; | 430 | d->setDocumentUsed = TRUE; |
426 | mediaPlayerState->setPlaying( FALSE ); | 431 | mediaPlayerState->setPlaying( FALSE ); |
427 | qApp->processEvents(); | 432 | qApp->processEvents(); |
428 | mediaPlayerState->setPlaying( TRUE ); | 433 | mediaPlayerState->setPlaying( TRUE ); |
429 | qApp->processEvents(); | 434 | qApp->processEvents(); |
430 | setCaption(tr("OpiePlayer")); | 435 | setCaption(tr("OpiePlayer")); |
431 | 436 | ||
432 | } else { //is playlist | 437 | } else { //is playlist |
433 | clearList(); | 438 | clearList(); |
434 | loadList(DocLnk(fileref)); | 439 | loadList(DocLnk(fileref)); |
435 | d->selectedFiles->first(); | 440 | d->selectedFiles->first(); |
436 | } | 441 | } |
437 | } | 442 | } |
438 | 443 | ||
439 | 444 | ||
440 | void PlayListWidget::setActiveWindow() { | 445 | void PlayListWidget::setActiveWindow() { |
441 | // When we get raised we need to ensure that it switches views | 446 | // When we get raised we need to ensure that it switches views |
442 | char origView = mediaPlayerState->view(); | 447 | char origView = mediaPlayerState->view(); |
443 | mediaPlayerState->setView( 'l' ); // invalidate | 448 | mediaPlayerState->setView( 'l' ); // invalidate |
444 | mediaPlayerState->setView( origView ); // now switch back | 449 | mediaPlayerState->setView( origView ); // now switch back |
445 | } | 450 | } |
446 | 451 | ||
447 | 452 | ||
448 | void PlayListWidget::useSelectedDocument() { | 453 | void PlayListWidget::useSelectedDocument() { |
449 | d->setDocumentUsed = FALSE; | 454 | d->setDocumentUsed = FALSE; |
450 | } | 455 | } |
451 | 456 | ||
452 | 457 | ||
453 | const DocLnk *PlayListWidget::current() { // this is fugly | 458 | const DocLnk *PlayListWidget::current() { // this is fugly |
454 | 459 | ||
455 | // if( fromSetDocument) { | 460 | // if( fromSetDocument) { |
456 | // qDebug("from setDoc"); | 461 | // qDebug("from setDoc"); |
457 | // DocLnkSet files; | 462 | // DocLnkSet files; |
458 | // Global::findDocuments(&files, "video/*;audio/*"); | 463 | // Global::findDocuments(&files, "video/*;audio/*"); |
459 | // QListIterator<DocLnk> dit( files.children() ); | 464 | // QListIterator<DocLnk> dit( files.children() ); |
460 | // for ( ; dit.current(); ++dit ) { | 465 | // for ( ; dit.current(); ++dit ) { |
461 | // if(dit.current()->linkFile() == setDocFileRef) { | 466 | // if(dit.current()->linkFile() == setDocFileRef) { |
462 | // qDebug(setDocFileRef); | 467 | // qDebug(setDocFileRef); |
463 | // return dit; | 468 | // return dit; |
464 | // } | 469 | // } |
465 | // } | 470 | // } |
466 | // } else | 471 | // } else |
467 | // qDebug("current"); | 472 | // qDebug("current"); |
468 | // switch (tabWidget->currentPageIndex()) { | 473 | // switch (tabWidget->currentPageIndex()) { |
469 | // case 0: //playlist | 474 | // case 0: //playlist |
470 | // { | 475 | // { |
471 | qDebug("playlist"); | 476 | qDebug("playlist"); |
472 | if ( mediaPlayerState->playlist() ) { | 477 | if ( mediaPlayerState->playlist() ) { |
473 | return d->selectedFiles->current(); | 478 | return d->selectedFiles->current(); |
474 | } | 479 | } |
475 | else if ( d->setDocumentUsed && d->current ) { | 480 | else if ( d->setDocumentUsed && d->current ) { |
476 | return d->current; | 481 | return d->current; |
477 | } else { | 482 | } else { |
478 | return d->files->selected(); | 483 | return d->files->selected(); |
479 | } | 484 | } |
480 | // } | 485 | // } |
481 | // break; | 486 | // break; |
482 | // case 1://audio | 487 | // case 1://audio |
483 | // { | 488 | // { |
484 | // qDebug("audioView"); | 489 | // qDebug("audioView"); |
485 | // Global::findDocuments(&files, "audio/*"); | 490 | // Global::findDocuments(&files, "audio/*"); |
486 | // QListIterator<DocLnk> dit( files.children() ); | 491 | // QListIterator<DocLnk> dit( files.children() ); |
487 | // for ( ; dit.current(); ++dit ) { | 492 | // for ( ; dit.current(); ++dit ) { |
488 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 493 | // if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
489 | // qDebug("here"); | 494 | // qDebug("here"); |
490 | // insanityBool=TRUE; | 495 | // insanityBool=TRUE; |
491 | // return dit; | 496 | // return dit; |
492 | // } | 497 | // } |
493 | // } | 498 | // } |
494 | // } | 499 | // } |
495 | // break; | 500 | // break; |
496 | // case 2: // video | 501 | // case 2: // video |
497 | // { | 502 | // { |
498 | // qDebug("videoView"); | 503 | // qDebug("videoView"); |
499 | // Global::findDocuments(&vFiles, "video/*"); | 504 | // Global::findDocuments(&vFiles, "video/*"); |
500 | // QListIterator<DocLnk> Vdit( vFiles.children() ); | 505 | // QListIterator<DocLnk> Vdit( vFiles.children() ); |
501 | // for ( ; Vdit.current(); ++Vdit ) { | 506 | // for ( ; Vdit.current(); ++Vdit ) { |
502 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 507 | // if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
503 | // insanityBool=TRUE; | 508 | // insanityBool=TRUE; |
504 | // return Vdit; | 509 | // return Vdit; |
505 | // } | 510 | // } |
506 | // } | 511 | // } |
507 | // } | 512 | // } |
508 | // break; | 513 | // break; |
509 | // }; | 514 | // }; |
510 | // return 0; | 515 | // return 0; |
511 | } | 516 | } |
512 | 517 | ||
513 | bool PlayListWidget::prev() { | 518 | bool PlayListWidget::prev() { |
514 | if ( mediaPlayerState->playlist() ) { | 519 | if ( mediaPlayerState->playlist() ) { |
515 | if ( mediaPlayerState->shuffled() ) { | 520 | if ( mediaPlayerState->shuffled() ) { |
516 | const DocLnk *cur = current(); | 521 | const DocLnk *cur = current(); |
517 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 522 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
518 | for ( int i = 0; i < j; i++ ) { | 523 | for ( int i = 0; i < j; i++ ) { |
519 | if ( !d->selectedFiles->next() ) | 524 | if ( !d->selectedFiles->next() ) |
520 | d->selectedFiles->first(); | 525 | d->selectedFiles->first(); |
521 | } | 526 | } |
522 | if ( cur == current() ) | 527 | if ( cur == current() ) |
523 | if ( !d->selectedFiles->next() ) | 528 | if ( !d->selectedFiles->next() ) |
524 | d->selectedFiles->first(); | 529 | d->selectedFiles->first(); |
525 | return TRUE; | 530 | return TRUE; |
526 | } else { | 531 | } else { |
527 | if ( !d->selectedFiles->prev() ) { | 532 | if ( !d->selectedFiles->prev() ) { |
528 | if ( mediaPlayerState->looping() ) { | 533 | if ( mediaPlayerState->looping() ) { |
529 | return d->selectedFiles->last(); | 534 | return d->selectedFiles->last(); |
530 | } else { | 535 | } else { |
531 | return FALSE; | 536 | return FALSE; |
532 | } | 537 | } |
533 | } | 538 | } |
534 | return TRUE; | 539 | return TRUE; |
535 | } | 540 | } |
536 | } else { | 541 | } else { |
537 | return mediaPlayerState->looping(); | 542 | return mediaPlayerState->looping(); |
538 | } | 543 | } |
539 | } | 544 | } |
540 | 545 | ||
541 | 546 | ||
542 | bool PlayListWidget::next() { | 547 | bool PlayListWidget::next() { |
543 | if ( mediaPlayerState->playlist() ) { | 548 | if ( mediaPlayerState->playlist() ) { |
544 | if ( mediaPlayerState->shuffled() ) { | 549 | if ( mediaPlayerState->shuffled() ) { |
545 | return prev(); | 550 | return prev(); |
546 | } else { | 551 | } else { |
547 | if ( !d->selectedFiles->next() ) { | 552 | if ( !d->selectedFiles->next() ) { |
548 | if ( mediaPlayerState->looping() ) { | 553 | if ( mediaPlayerState->looping() ) { |
549 | return d->selectedFiles->first(); | 554 | return d->selectedFiles->first(); |
550 | } else { | 555 | } else { |
551 | return FALSE; | 556 | return FALSE; |
552 | } | 557 | } |
553 | } | 558 | } |
554 | return TRUE; | 559 | return TRUE; |
555 | } | 560 | } |
556 | } else { | 561 | } else { |
557 | return mediaPlayerState->looping(); | 562 | return mediaPlayerState->looping(); |
558 | } | 563 | } |
559 | } | 564 | } |
560 | 565 | ||
561 | 566 | ||
562 | bool PlayListWidget::first() { | 567 | bool PlayListWidget::first() { |
563 | if ( mediaPlayerState->playlist() ) | 568 | if ( mediaPlayerState->playlist() ) |
564 | return d->selectedFiles->first(); | 569 | return d->selectedFiles->first(); |
565 | else | 570 | else |
566 | return mediaPlayerState->looping(); | 571 | return mediaPlayerState->looping(); |
567 | } | 572 | } |
568 | 573 | ||
569 | 574 | ||
570 | bool PlayListWidget::last() { | 575 | bool PlayListWidget::last() { |
571 | if ( mediaPlayerState->playlist() ) | 576 | if ( mediaPlayerState->playlist() ) |
572 | return d->selectedFiles->last(); | 577 | return d->selectedFiles->last(); |
573 | else | 578 | else |
574 | return mediaPlayerState->looping(); | 579 | return mediaPlayerState->looping(); |
575 | } | 580 | } |
576 | 581 | ||
577 | 582 | ||
578 | void PlayListWidget::saveList() { | 583 | void PlayListWidget::saveList() { |
579 | 584 | ||
580 | QString filename; | 585 | QString filename; |
581 | InputDialog *fileDlg; | 586 | InputDialog *fileDlg; |
582 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 587 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
583 | fileDlg->exec(); | 588 | fileDlg->exec(); |
584 | if( fileDlg->result() == 1 ) { | 589 | if( fileDlg->result() == 1 ) { |
585 | if ( d->current ) | 590 | if ( d->current ) |
586 | delete d->current; | 591 | delete d->current; |
587 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 592 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
588 | // qDebug("saving playlist "+filename+".playlist"); | 593 | // qDebug("saving playlist "+filename+".playlist"); |
589 | Config cfg( filename +".playlist"); | 594 | Config cfg( filename +".playlist"); |
590 | writeConfig( cfg ); | 595 | writeConfig( cfg ); |
591 | if( playLists->selected()->name() == filename) { | 596 | |
592 | // qDebug("same name so delete lnk"); | 597 | // qDebug("same name so delete lnk??"); |
593 | QFile().remove(playLists->selected()->file()); | 598 | // if( playLists->selected()->name() == filename) { |
594 | QFile().remove(playLists->selected()->linkFile()); | 599 | |
595 | playLists->reread(); | 600 | // qDebug("same name so delete lnk"); |
596 | } | 601 | // QFile().remove(playLists->selected()->file()); |
597 | 602 | // QFile().remove(playLists->selected()->linkFile()); | |
603 | // playLists->reread(); | ||
604 | // } | ||
605 | // qDebug("new doclnk"); | ||
598 | DocLnk lnk; | 606 | DocLnk lnk; |
599 | // lnk.setComment( ""); | 607 | // lnk.setComment( ""); |
600 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 608 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
601 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 609 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
602 | lnk.setIcon("mpegplayer/playlist2"); | 610 | lnk.setIcon("mpegplayer/playlist2"); |
603 | lnk.setName( filename); //sets file name | 611 | lnk.setName( filename); //sets file name |
612 | qDebug(filename); | ||
604 | if(!lnk.writeLink()) | 613 | if(!lnk.writeLink()) |
605 | qDebug("Writing doclink did not work"); | 614 | qDebug("Writing doclink did not work"); |
606 | } | 615 | } |
607 | Config config( "MediaPlayer" ); | 616 | Config config( "MediaPlayer" ); |
608 | config.writeEntry("CurrentPlaylist",filename); | 617 | config.writeEntry("CurrentPlaylist",filename); |
609 | setCaption(tr("OpiePlayer: ")+filename); | 618 | setCaption(tr("OpiePlayer: ")+filename); |
610 | d->selectedFiles->first(); | 619 | d->selectedFiles->first(); |
611 | if(fileDlg) | 620 | if(fileDlg) |
612 | delete fileDlg; | 621 | delete fileDlg; |
613 | } | 622 | } |
614 | 623 | ||
615 | void PlayListWidget::loadList( const DocLnk & lnk) { | 624 | void PlayListWidget::loadList( const DocLnk & lnk) { |
616 | QString name= lnk.name(); | 625 | QString name= lnk.name(); |
617 | // qDebug("currentList is "+name); | 626 | // qDebug("currentList is "+name); |
618 | if( name.length()>1) { | 627 | if( name.length()>1) { |
619 | setCaption("OpiePlayer: "+name); | 628 | setCaption("OpiePlayer: "+name); |
620 | // qDebug("load list "+ name+".playlist"); | 629 | // qDebug("load list "+ name+".playlist"); |
621 | clearList(); | 630 | clearList(); |
622 | Config cfg( name+".playlist"); | 631 | Config cfg( name+".playlist"); |
623 | readConfig(cfg); | 632 | readConfig(cfg); |
633 | |||
624 | tabWidget->setCurrentPage(0); | 634 | tabWidget->setCurrentPage(0); |
635 | |||
625 | Config config( "MediaPlayer" ); | 636 | Config config( "MediaPlayer" ); |
626 | config.writeEntry("CurrentPlaylist", name); | 637 | config.writeEntry("CurrentPlaylist", name); |
627 | d->selectedFiles->first(); | 638 | // d->selectedFiles->first(); |
628 | } | 639 | } |
640 | |||
629 | } | 641 | } |
630 | 642 | ||
631 | void PlayListWidget::setPlaylist( bool shown ) { | 643 | void PlayListWidget::setPlaylist( bool shown ) { |
632 | if ( shown ) | 644 | if ( shown ) |
633 | d->playListFrame->show(); | 645 | d->playListFrame->show(); |
634 | else | 646 | else |
635 | d->playListFrame->hide(); | 647 | d->playListFrame->hide(); |
636 | } | 648 | } |
637 | 649 | ||
638 | void PlayListWidget::setView( char view ) { | 650 | void PlayListWidget::setView( char view ) { |
639 | if ( view == 'l' ) | 651 | if ( view == 'l' ) |
640 | showMaximized(); | 652 | showMaximized(); |
641 | else | 653 | else |
642 | hide(); | 654 | hide(); |
643 | } | 655 | } |
644 | 656 | ||
645 | void PlayListWidget::addSelected() { | 657 | void PlayListWidget::addSelected() { |
646 | 658 | ||
647 | Config cfg( "MediaPlayer" ); | 659 | Config cfg( "MediaPlayer" ); |
648 | cfg.setGroup("PlayList"); | 660 | cfg.setGroup("PlayList"); |
649 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 661 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
650 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 662 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
651 | 663 | ||
652 | switch (tabWidget->currentPageIndex()) { | 664 | switch (tabWidget->currentPageIndex()) { |
653 | case 0: //playlist | 665 | case 0: //playlist |
654 | break; | 666 | break; |
655 | case 1: { //audio | 667 | case 1: { //audio |
656 | for ( int i = 0; i < noOfFiles; i++ ) { | 668 | for ( int i = 0; i < noOfFiles; i++ ) { |
657 | QString entryName; | 669 | QString entryName; |
658 | entryName.sprintf( "File%i", i + 1 ); | 670 | entryName.sprintf( "File%i", i + 1 ); |
659 | QString linkFile = cfg.readEntry( entryName ); | 671 | QString linkFile = cfg.readEntry( entryName ); |
660 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { | 672 | if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { |
661 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 673 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
662 | tr("This is all ready in your playlist.\nContinue?"), | 674 | tr("This is all ready in your playlist.\nContinue?"), |
663 | tr("Yes"),tr("No"),0,0,1); | 675 | tr("Yes"),tr("No"),0,0,1); |
664 | if (result !=0) | 676 | if (result !=0) |
665 | return; | 677 | return; |
666 | } | 678 | } |
667 | } | 679 | } |
668 | addToSelection( audioView->selectedItem() ); | 680 | addToSelection( audioView->selectedItem() ); |
669 | tabWidget->setCurrentPage(1); | 681 | tabWidget->setCurrentPage(1); |
670 | } | 682 | } |
671 | break; | 683 | break; |
672 | case 2: { // video | 684 | case 2: { // video |
673 | for ( int i = 0; i < noOfFiles; i++ ) { | 685 | for ( int i = 0; i < noOfFiles; i++ ) { |
674 | QString entryName; | 686 | QString entryName; |
675 | entryName.sprintf( "File%i", i + 1 ); | 687 | entryName.sprintf( "File%i", i + 1 ); |
676 | QString linkFile = cfg.readEntry( entryName ); | 688 | QString linkFile = cfg.readEntry( entryName ); |
677 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 689 | if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
678 | int result= QMessageBox::warning(this,tr("OpiePlayer"), | 690 | int result= QMessageBox::warning(this,tr("OpiePlayer"), |
679 | tr("This is all ready in your playlist.\nContinue?"), | 691 | tr("This is all ready in your playlist.\nContinue?"), |
680 | tr("Yes"),tr("No"),0,0,1); | 692 | tr("Yes"),tr("No"),0,0,1); |
681 | if (result !=0) | 693 | if (result !=0) |
682 | return; | 694 | return; |
683 | } | 695 | } |
684 | } | 696 | } |
685 | addToSelection( videoView->selectedItem() ); | 697 | addToSelection( videoView->selectedItem() ); |
686 | tabWidget->setCurrentPage(2); | 698 | tabWidget->setCurrentPage(2); |
687 | } | 699 | } |
688 | break; | 700 | break; |
689 | }; | 701 | }; |
690 | } | 702 | } |
691 | 703 | ||
692 | void PlayListWidget::removeSelected() { | 704 | void PlayListWidget::removeSelected() { |
693 | d->selectedFiles->removeSelected( ); | 705 | d->selectedFiles->removeSelected( ); |
694 | } | 706 | } |
695 | 707 | ||
696 | void PlayListWidget::playIt( QListViewItem *it) { | 708 | void PlayListWidget::playIt( QListViewItem *it) { |
697 | // d->setDocumentUsed = FALSE; | 709 | // d->setDocumentUsed = FALSE; |
698 | mediaPlayerState->setPlaying(TRUE); | 710 | mediaPlayerState->setPlaying(TRUE); |
699 | } | 711 | } |
700 | 712 | ||
701 | void PlayListWidget::addToSelection( QListViewItem *it) { | 713 | void PlayListWidget::addToSelection( QListViewItem *it) { |
702 | d->setDocumentUsed = FALSE; | 714 | d->setDocumentUsed = FALSE; |
703 | 715 | ||
704 | if(it) { | 716 | if(it) { |
705 | switch (tabWidget->currentPageIndex()) { | 717 | switch (tabWidget->currentPageIndex()) { |
706 | case 1: { | 718 | case 1: { |
707 | QListIterator<DocLnk> dit( files.children() ); | 719 | QListIterator<DocLnk> dit( files.children() ); |
708 | for ( ; dit.current(); ++dit ) { | 720 | for ( ; dit.current(); ++dit ) { |
709 | if( dit.current()->name() == it->text(0)) { | 721 | if( dit.current()->name() == it->text(0)) { |
710 | d->selectedFiles->addToSelection( **dit ); | 722 | d->selectedFiles->addToSelection( **dit ); |
711 | } | 723 | } |
712 | } | 724 | } |
713 | } | 725 | } |
714 | break; | 726 | break; |
715 | case 2: { | 727 | case 2: { |
716 | QListIterator<DocLnk> dit( vFiles.children() ); | 728 | QListIterator<DocLnk> dit( vFiles.children() ); |
717 | for ( ; dit.current(); ++dit ) { | 729 | for ( ; dit.current(); ++dit ) { |
718 | if( dit.current()->name() == it->text(0)) { | 730 | if( dit.current()->name() == it->text(0)) { |
719 | d->selectedFiles->addToSelection( **dit ); | 731 | d->selectedFiles->addToSelection( **dit ); |
720 | } | 732 | } |
721 | } | 733 | } |
722 | } | 734 | } |
723 | break; | 735 | break; |
724 | case 0: | 736 | case 0: |
725 | break; | 737 | break; |
726 | }; | 738 | }; |
727 | tabWidget->setCurrentPage(0); | 739 | tabWidget->setCurrentPage(0); |
728 | } | 740 | } |
729 | } | 741 | } |
730 | 742 | ||
731 | void PlayListWidget::tabChanged(QWidget *widg) { | 743 | void PlayListWidget::tabChanged(QWidget *widg) { |
732 | 744 | ||
733 | switch ( tabWidget->currentPageIndex()) { | 745 | switch ( tabWidget->currentPageIndex()) { |
734 | case 0: | 746 | case 0: |
735 | { | 747 | { |
736 | if( !tbDeletePlaylist->isHidden()) | 748 | if( !tbDeletePlaylist->isHidden()) |
737 | tbDeletePlaylist->hide(); | 749 | tbDeletePlaylist->hide(); |
738 | d->tbRemoveFromList->setEnabled(TRUE); | 750 | d->tbRemoveFromList->setEnabled(TRUE); |
739 | d->tbAddToList->setEnabled(FALSE); | 751 | d->tbAddToList->setEnabled(FALSE); |
740 | } | 752 | } |
741 | break; | 753 | break; |
742 | case 1: | 754 | case 1: |
743 | { | 755 | { |
744 | if( !tbDeletePlaylist->isHidden()) | 756 | if( !tbDeletePlaylist->isHidden()) |
745 | tbDeletePlaylist->hide(); | 757 | tbDeletePlaylist->hide(); |
746 | d->tbRemoveFromList->setEnabled(FALSE); | 758 | d->tbRemoveFromList->setEnabled(FALSE); |
747 | d->tbAddToList->setEnabled(TRUE); | 759 | d->tbAddToList->setEnabled(TRUE); |
748 | } | 760 | } |
749 | break; | 761 | break; |
750 | case 2: | 762 | case 2: |
751 | { | 763 | { |
752 | if( !tbDeletePlaylist->isHidden()) | 764 | if( !tbDeletePlaylist->isHidden()) |
753 | tbDeletePlaylist->hide(); | 765 | tbDeletePlaylist->hide(); |
754 | d->tbRemoveFromList->setEnabled(FALSE); | 766 | d->tbRemoveFromList->setEnabled(FALSE); |
755 | d->tbAddToList->setEnabled(TRUE); | 767 | d->tbAddToList->setEnabled(TRUE); |
756 | } | 768 | } |
757 | break; | 769 | break; |
758 | case 3: | 770 | case 3: |
759 | { | 771 | { |
760 | if( tbDeletePlaylist->isHidden()) | 772 | if( tbDeletePlaylist->isHidden()) |
761 | tbDeletePlaylist->show(); | 773 | tbDeletePlaylist->show(); |
762 | playLists->reread(); | 774 | playLists->reread(); |
763 | } | 775 | } |
764 | break; | 776 | break; |
765 | }; | 777 | }; |
766 | } | 778 | } |
767 | 779 | ||
768 | 780 | ||
769 | 781 | ||
770 | void PlayListWidget::btnPlay(bool b) { | 782 | void PlayListWidget::btnPlay(bool b) { |
771 | 783 | ||
772 | // mediaPlayerState->setPlaying(b); | 784 | // mediaPlayerState->setPlaying(b); |
773 | switch ( tabWidget->currentPageIndex()) { | 785 | switch ( tabWidget->currentPageIndex()) { |
774 | case 0: | 786 | case 0: |
775 | { | 787 | { |
776 | mediaPlayerState->setPlaying(b); | 788 | mediaPlayerState->setPlaying(b); |
777 | } | 789 | } |
778 | break; | 790 | break; |
779 | case 1: | 791 | case 1: |
780 | { | 792 | { |
781 | addToSelection( audioView->selectedItem() ); | 793 | addToSelection( audioView->selectedItem() ); |
782 | mediaPlayerState->setPlaying(b); | 794 | mediaPlayerState->setPlaying(b); |
783 | // qApp->processEvents(); | 795 | // qApp->processEvents(); |
784 | d->selectedFiles->removeSelected( ); | 796 | d->selectedFiles->removeSelected( ); |
785 | tabWidget->setCurrentPage(1); | 797 | tabWidget->setCurrentPage(1); |
786 | d->selectedFiles->unSelect(); | 798 | audioView->clearSelection(); |
799 | // d->selectedFiles->unSelect(); | ||
787 | // mediaPlayerState->setPlaying(FALSE); | 800 | // mediaPlayerState->setPlaying(FALSE); |
788 | } | 801 | } |
789 | break; | 802 | break; |
790 | case 2: | 803 | case 2: |
791 | { | 804 | { |
792 | addToSelection( videoView->selectedItem() ); | 805 | addToSelection( videoView->selectedItem() ); |
793 | mediaPlayerState->setPlaying(b); | 806 | mediaPlayerState->setPlaying(b); |
794 | qApp->processEvents(); | 807 | qApp->processEvents(); |
795 | d->selectedFiles->removeSelected( ); | 808 | d->selectedFiles->removeSelected( ); |
796 | tabWidget->setCurrentPage(2); | 809 | tabWidget->setCurrentPage(2); |
797 | d->selectedFiles->unSelect(); | 810 | videoView->clearSelection(); |
811 | // d->selectedFiles->unSelect(); | ||
798 | // mediaPlayerState->setPlaying(FALSE); | 812 | // mediaPlayerState->setPlaying(FALSE); |
799 | } | 813 | } |
800 | break; | 814 | break; |
801 | }; | 815 | }; |
802 | } | 816 | } |
803 | 817 | ||
804 | void PlayListWidget::deletePlaylist() { | 818 | void PlayListWidget::deletePlaylist() { |
805 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 819 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
806 | (tr("You really want to delete\nthis playlist?")), | 820 | (tr("You really want to delete\nthis playlist?")), |
807 | (tr("Yes")), (tr("No")), 0 )){ | 821 | (tr("Yes")), (tr("No")), 0 )){ |
808 | case 0: // Yes clicked, | 822 | case 0: // Yes clicked, |
809 | QFile().remove(playLists->selected()->file()); | 823 | QFile().remove(playLists->selected()->file()); |
810 | QFile().remove(playLists->selected()->linkFile()); | 824 | QFile().remove(playLists->selected()->linkFile()); |
811 | playLists->reread(); | 825 | playLists->reread(); |
812 | break; | 826 | break; |
813 | case 1: // Cancel | 827 | case 1: // Cancel |
814 | break; | 828 | break; |
815 | }; | 829 | }; |
816 | 830 | ||
817 | } | 831 | } |
818 | 832 | ||
819 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 833 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
820 | { | 834 | { |
821 | switch (mouse) { | 835 | switch (mouse) { |
822 | case 1: | 836 | case 1: |
823 | break; | 837 | break; |
824 | case 2:{ | 838 | case 2:{ |
825 | QPopupMenu m; | 839 | QPopupMenu m; |
826 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 840 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
827 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 841 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
828 | m.insertSeparator(); | 842 | m.insertSeparator(); |
829 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 843 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
830 | m.exec( QCursor::pos() ); | 844 | m.exec( QCursor::pos() ); |
831 | } | 845 | } |
832 | break; | 846 | break; |
833 | }; | 847 | }; |
834 | } | 848 | } |
835 | 849 | ||
836 | void PlayListWidget::playSelected() | 850 | void PlayListWidget::playSelected() |
837 | { | 851 | { |
838 | btnPlay( TRUE); | 852 | btnPlay( TRUE); |
839 | } | 853 | } |
840 | 854 | ||
841 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 855 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
842 | { | 856 | { |
843 | switch (mouse) { | 857 | switch (mouse) { |
844 | case 1: | 858 | case 1: |
845 | break; | 859 | break; |
846 | case 2:{ | 860 | case 2:{ |
847 | QPopupMenu m; | 861 | QPopupMenu m; |
848 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 862 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
849 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 863 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
850 | // m.insertSeparator(); | 864 | // m.insertSeparator(); |
851 | m.exec( QCursor::pos() ); | 865 | m.exec( QCursor::pos() ); |
852 | } | 866 | } |
853 | break; | 867 | break; |
854 | }; | 868 | }; |
855 | 869 | ||
856 | } | 870 | } |
857 | 871 | ||
858 | void PlayListWidget::listDelete() { | 872 | void PlayListWidget::listDelete() { |
859 | Config cfg( "MediaPlayer" ); | 873 | Config cfg( "MediaPlayer" ); |
860 | cfg.setGroup("PlayList"); | 874 | cfg.setGroup("PlayList"); |
861 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
862 | QString file; | 876 | QString file; |
863 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
864 | switch ( tabWidget->currentPageIndex()) { | 878 | switch ( tabWidget->currentPageIndex()) { |
865 | case 0: | 879 | case 0: |
866 | break; | 880 | break; |
867 | case 1: | 881 | case 1: |
868 | { | 882 | { |
869 | file = audioView->selectedItem()->text(0); | 883 | file = audioView->selectedItem()->text(0); |
870 | // Global::findDocuments(&files, "audio/*"); | 884 | // Global::findDocuments(&files, "audio/*"); |
871 | // AppLnkSet appFiles; | 885 | // AppLnkSet appFiles; |
872 | QListIterator<DocLnk> dit( files.children() ); | 886 | QListIterator<DocLnk> dit( files.children() ); |
873 | for ( ; dit.current(); ++dit ) { | 887 | for ( ; dit.current(); ++dit ) { |
874 | if( dit.current()->name() == file) { | 888 | if( dit.current()->name() == file) { |
875 | qDebug(file); | 889 | qDebug(file); |
876 | LnkProperties prop( dit.current() ); | 890 | LnkProperties prop( dit.current() ); |
877 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
878 | prop.showMaximized(); | 892 | prop.showMaximized(); |
879 | prop.exec(); | 893 | prop.exec(); |
880 | } | 894 | } |
881 | } | 895 | } |
882 | populateAudioView(); | 896 | populateAudioView(); |
883 | } | 897 | } |
884 | break; | 898 | break; |
885 | case 2: | 899 | case 2: |
886 | { | 900 | { |
887 | // file = videoView->selectedItem()->text(0); | 901 | // file = videoView->selectedItem()->text(0); |
888 | // for ( int i = 0; i < noOfFiles; i++ ) { | 902 | // for ( int i = 0; i < noOfFiles; i++ ) { |
889 | // QString entryName; | 903 | // QString entryName; |
890 | // entryName.sprintf( "File%i", i + 1 ); | 904 | // entryName.sprintf( "File%i", i + 1 ); |
891 | // QString linkFile = cfg.readEntry( entryName ); | 905 | // QString linkFile = cfg.readEntry( entryName ); |
892 | // AppLnk lnk( AppLnk(linkFile)); | 906 | // AppLnk lnk( AppLnk(linkFile)); |
893 | // if( lnk.name() == file ) { | 907 | // if( lnk.name() == file ) { |
894 | // LnkProperties prop( &lnk); | 908 | // LnkProperties prop( &lnk); |
895 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
896 | // prop.showMaximized(); | 910 | // prop.showMaximized(); |
897 | // prop.exec(); | 911 | // prop.exec(); |
898 | // } | 912 | // } |
899 | // } | 913 | // } |
900 | } | 914 | } |
901 | break; | 915 | break; |
902 | }; | 916 | }; |
903 | } | 917 | } |
904 | 918 | ||
905 | void PlayListWidget::populateAudioView() { | 919 | void PlayListWidget::populateAudioView() { |
906 | // if(files) | 920 | // if(files) |
907 | // files.~DocLnkSet(); | 921 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | ||
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
924 | |||
908 | Global::findDocuments(&files, "audio/*"); | 925 | Global::findDocuments(&files, "audio/*"); |
909 | QListIterator<DocLnk> dit( files.children() ); | 926 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | ||
910 | audioView->clear(); | 928 | audioView->clear(); |
911 | QString storage; | 929 | QString storage; |
912 | for ( ; dit.current(); ++dit ) { | 930 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | ||
932 | const QString name = (*it)->name(); | ||
933 | const QString path = (*it)->path(); | ||
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | ||
935 | } | ||
936 | |||
913 | QListViewItem * newItem; | 937 | QListViewItem * newItem; |
914 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | ||
915 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | ||
916 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | ||
917 | else storage=tr("RAM"); | ||
918 | if ( QFile( dit.current()->file()).exists() ) { | 938 | if ( QFile( dit.current()->file()).exists() ) { |
919 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
920 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
921 | } | 941 | } |
922 | } | 942 | } |
923 | } | 943 | } |
924 | 944 | ||
925 | void PlayListWidget::populateVideoView() { | 945 | void PlayListWidget::populateVideoView() { |
946 | StorageInfo storageInfo; | ||
947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
948 | |||
926 | Global::findDocuments(&vFiles, "video/*"); | 949 | Global::findDocuments(&vFiles, "video/*"); |
927 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 950 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
951 | QListIterator<FileSystem> it ( fs ); | ||
928 | videoView->clear(); | 952 | videoView->clear(); |
929 | QString storage; | 953 | QString storage; |
930 | for ( ; Vdit.current(); ++Vdit ) { | 954 | for ( ; Vdit.current(); ++Vdit ) { |
931 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage=tr("CF"); | 955 | for( ; it.current(); ++it ){ |
932 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage=tr("CF"); | 956 | const QString name = (*it)->name(); |
933 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage=tr("SD"); | 957 | const QString path = (*it)->path(); |
934 | else storage=tr("RAM"); | 958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
959 | } | ||
960 | |||
935 | QListViewItem * newItem; | 961 | QListViewItem * newItem; |
936 | if ( QFile( Vdit.current()->file()).exists() ) { | 962 | if ( QFile( Vdit.current()->file()).exists() ) { |
937 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
938 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
939 | } | 965 | } |
940 | } | 966 | } |
941 | } | 967 | } |