-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 8f04d0d..59e06a6 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -132,211 +132,211 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume | |||
132 | 132 | ||
133 | 133 | ||
134 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { | 134 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { |
135 | AudioDevicePrivate::muted = muted; | 135 | AudioDevicePrivate::muted = muted; |
136 | if ( muted ) { | 136 | if ( muted ) { |
137 | AudioDevicePrivate::leftVolume = leftVolume; | 137 | AudioDevicePrivate::leftVolume = leftVolume; |
138 | AudioDevicePrivate::rightVolume = rightVolume; | 138 | AudioDevicePrivate::rightVolume = rightVolume; |
139 | leftVolume = 0; | 139 | leftVolume = 0; |
140 | rightVolume = 0; | 140 | rightVolume = 0; |
141 | } else { | 141 | } else { |
142 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); | 142 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); |
143 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); | 143 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); |
144 | } | 144 | } |
145 | // #ifdef Q_OS_WIN32 | 145 | // #ifdef Q_OS_WIN32 |
146 | // HWAVEOUT handle; | 146 | // HWAVEOUT handle; |
147 | // WAVEFORMATEX formatData; | 147 | // WAVEFORMATEX formatData; |
148 | // formatData.cbSize = sizeof(WAVEFORMATEX); | 148 | // formatData.cbSize = sizeof(WAVEFORMATEX); |
149 | // formatData.wFormatTag = WAVE_FORMAT_PCM; | 149 | // formatData.wFormatTag = WAVE_FORMAT_PCM; |
150 | // formatData.nAvgBytesPerSec = 4 * 44000; | 150 | // formatData.nAvgBytesPerSec = 4 * 44000; |
151 | // formatData.nBlockAlign = 4; | 151 | // formatData.nBlockAlign = 4; |
152 | // formatData.nChannels = 2; | 152 | // formatData.nChannels = 2; |
153 | // formatData.nSamplesPerSec = 44000; | 153 | // formatData.nSamplesPerSec = 44000; |
154 | // formatData.wBitsPerSample = 16; | 154 | // formatData.wBitsPerSample = 16; |
155 | // waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 155 | // waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
156 | // unsigned int volume = (rightVolume << 16) | leftVolume; | 156 | // unsigned int volume = (rightVolume << 16) | leftVolume; |
157 | // if ( waveOutSetVolume( handle, volume ) ) | 157 | // if ( waveOutSetVolume( handle, volume ) ) |
158 | // // qDebug( "set volume of audio device failed" ); | 158 | // // qDebug( "set volume of audio device failed" ); |
159 | // waveOutClose( handle ); | 159 | // waveOutClose( handle ); |
160 | // #else | 160 | // #else |
161 | // Volume can be from 0 to 100 which is 101 distinct values | 161 | // Volume can be from 0 to 100 which is 101 distinct values |
162 | unsigned int rV = (rightVolume * 101) >> 16; | 162 | unsigned int rV = (rightVolume * 101) >> 16; |
163 | 163 | ||
164 | # if 0 | 164 | # if 0 |
165 | unsigned int lV = (leftVolume * 101) >> 16; | 165 | unsigned int lV = (leftVolume * 101) >> 16; |
166 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 166 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
167 | int mixerHandle = 0; | 167 | int mixerHandle = 0; |
168 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 168 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
169 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) | 169 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
170 | perror("ioctl(\"MIXER_WRITE\")"); | 170 | perror("ioctl(\"MIXER_WRITE\")"); |
171 | close( mixerHandle ); | 171 | close( mixerHandle ); |
172 | } else | 172 | } else |
173 | perror("open(\"/dev/mixer\")"); | 173 | perror("open(\"/dev/mixer\")"); |
174 | 174 | ||
175 | # else | 175 | # else |
176 | // This is the way this has to be done now I guess, doesn't allow for | 176 | // This is the way this has to be done now I guess, doesn't allow for |
177 | // independant right and left channel setting, or setting for different outputs | 177 | // independant right and left channel setting, or setting for different outputs |
178 | Config cfg("qpe"); // qtopia is "Sound" | 178 | Config cfg("qpe"); // qtopia is "Sound" |
179 | cfg.setGroup("Volume"); // qtopia is "Settings" | 179 | cfg.setGroup("Volume"); // qtopia is "Settings" |
180 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume | 180 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume |
181 | # endif | 181 | # endif |
182 | 182 | ||
183 | //#endif | 183 | //#endif |
184 | // qDebug( "setting volume to: 0x%x", volume ); | 184 | // qDebug( "setting volume to: 0x%x", volume ); |
185 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 185 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
186 | // Send notification that the volume has changed | 186 | // Send notification that the volume has changed |
187 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 187 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
188 | #endif | 188 | #endif |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | 193 | ||
194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
195 | qDebug("creating new audio device"); | 195 | qDebug("creating new audio device"); |
196 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 196 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
197 | d = new AudioDevicePrivate; | 197 | d = new AudioDevicePrivate; |
198 | d->frequency = f; | 198 | d->frequency = f; |
199 | d->channels = chs; | 199 | d->channels = chs; |
200 | d->bytesPerSample = bps; | 200 | d->bytesPerSample = bps; |
201 | qDebug("%d",bps); | 201 | qDebug("%d",bps); |
202 | int format=0; | 202 | int format=0; |
203 | if( bps == 8) format = AFMT_U8; | 203 | if( bps == 8) format = AFMT_U8; |
204 | else if( bps <= 0) format = AFMT_S16_LE; | 204 | else if( bps <= 0) format = AFMT_S16_LE; |
205 | else format = AFMT_S16_LE; | 205 | else format = AFMT_S16_LE; |
206 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | 206 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); |
207 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 207 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
208 | 208 | ||
209 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 209 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
210 | int capabilities = 0; | 210 | int capabilities = 0; |
211 | 211 | ||
212 | 212 | ||
213 | #ifdef KEEP_DEVICE_OPEN | 213 | #ifdef KEEP_DEVICE_OPEN |
214 | if ( AudioDevicePrivate::dspFd == 0 ) { | 214 | if ( AudioDevicePrivate::dspFd == 0 ) { |
215 | #endif | 215 | #endif |
216 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 216 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
217 | 217 | ||
218 | // perror("open(\"/dev/dsp\") sending to /dev/null instead"); | 218 | // perror("open(\"/dev/dsp\") sending to /dev/null instead"); |
219 | perror("open(\"/dev/dsp\")"); | 219 | perror("open(\"/dev/dsp\")"); |
220 | QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); | 220 | QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); |
221 | QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); | 221 | QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); |
222 | exit(-1); //harsh? | 222 | exit(-1); //harsh? |
223 | // d->handle = ::open( "/dev/null", O_WRONLY ); | 223 | // d->handle = ::open( "/dev/null", O_WRONLY ); |
224 | // WTF?!?! | 224 | // WTF?!?! |
225 | } | 225 | } |
226 | #ifdef KEEP_DEVICE_OPEN | 226 | #ifdef KEEP_DEVICE_OPEN |
227 | AudioDevicePrivate::dspFd = d->handle; | 227 | AudioDevicePrivate::dspFd = d->handle; |
228 | } else { | 228 | } else { |
229 | d->handle = AudioDevicePrivate::dspFd; | 229 | d->handle = AudioDevicePrivate::dspFd; |
230 | } | 230 | } |
231 | #endif | 231 | #endif |
232 | 232 | ||
233 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 233 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
234 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 234 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
235 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 235 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
236 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 236 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
237 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | 237 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) |
238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
239 | qDebug("freq %d", d->frequency); | 239 | qDebug("freq %d", d->frequency); |
240 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | 240 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) |
241 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 241 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
242 | qDebug("channels %d",d->channels); | 242 | qDebug("channels %d",d->channels); |
243 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 243 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
244 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 244 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
245 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 245 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
246 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 246 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
247 | } | 247 | } |
248 | 248 | ||
249 | d->bufferSize = sound_fragment_bytes; | 249 | d->bufferSize = sound_fragment_bytes; |
250 | d->unwrittenBuffer = new char[d->bufferSize]; | 250 | d->unwrittenBuffer = new char[d->bufferSize]; |
251 | d->unwritten = 0; | 251 | d->unwritten = 0; |
252 | d->can_GETOSPACE = TRUE; // until we find otherwise | 252 | d->can_GETOSPACE = TRUE; // until we find otherwise |
253 | 253 | ||
254 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 254 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); |
255 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 255 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); |
256 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 256 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
257 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 257 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
258 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 258 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
259 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 259 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
260 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 260 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
261 | 261 | ||
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | AudioDevice::~AudioDevice() { | 265 | AudioDevice::~AudioDevice() { |
266 | qDebug("destryo audiodevice"); | 266 | qDebug("destryo audiodevice"); |
267 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 267 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
268 | 268 | ||
269 | // #ifdef Q_OS_WIN32 | 269 | // #ifdef Q_OS_WIN32 |
270 | // waveOutClose( (HWAVEOUT)d->handle ); | 270 | // waveOutClose( (HWAVEOUT)d->handle ); |
271 | // #else | 271 | // #else |
272 | # ifndef KEEP_DEVICE_OPEN | 272 | # ifndef KEEP_DEVICE_OPEN |
273 | close( d->handle ); // Now it should be safe to shut the handle | 273 | close( d->handle ); // Now it should be safe to shut the handle |
274 | # endif | 274 | # endif |
275 | delete d->unwrittenBuffer; | 275 | delete d->unwrittenBuffer; |
276 | delete d; | 276 | delete d; |
277 | //#endif | 277 | //#endif |
278 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 278 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
279 | 279 | ||
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void AudioDevice::volumeChanged( bool muted ) | 283 | void AudioDevice::volumeChanged( bool muted ) |
284 | { | 284 | { |
285 | AudioDevicePrivate::muted = muted; | 285 | AudioDevicePrivate::muted = muted; |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void AudioDevice::write( char *buffer, unsigned int length ) | 289 | void AudioDevice::write( char *buffer, unsigned int length ) |
290 | { | 290 | { |
291 | // #ifdef Q_OS_WIN32 | 291 | // #ifdef Q_OS_WIN32 |
292 | // // returns immediately and (to be implemented) emits completedIO() when finished writing | 292 | // // returns immediately and (to be implemented) emits completedIO() when finished writing |
293 | // WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); | 293 | // WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); |
294 | // // maybe the buffer should be copied so that this fool proof, but its a performance hit | 294 | // // maybe the buffer should be copied so that this fool proof, but its a performance hit |
295 | // lpWaveHdr->lpData = buffer; | 295 | // lpWaveHdr->lpData = buffer; |
296 | // lpWaveHdr->dwBufferLength = length; | 296 | // lpWaveHdr->dwBufferLength = length; |
297 | // lpWaveHdr->dwFlags = 0L; | 297 | // lpWaveHdr->dwFlags = 0L; |
298 | // lpWaveHdr->dwLoops = 0L; | 298 | // lpWaveHdr->dwLoops = 0L; |
299 | // waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); | 299 | // waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); |
300 | // // waveOutWrite returns immediately. the data is sent in the background. | 300 | // // waveOutWrite returns immediately. the data is sent in the background. |
301 | // if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) | 301 | // if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) |
302 | // qDebug( "failed to write block to audio device" ); | 302 | // qDebug( "failed to write block to audio device" ); |
303 | // // emit completedIO(); | 303 | // // emit completedIO(); |
304 | // #else | 304 | // #else |
305 | int t = ::write( d->handle, buffer, length ); | 305 | int t = ::write( d->handle, buffer, length ); |
306 | if ( t<0 ) t = 0; | 306 | if ( t<0 ) t = 0; |
307 | if ( t != (int)length) { | 307 | if ( t != (int)length) { |
308 | qDebug("Ahhh!! memcpys 1"); | 308 | qDebug("Ahhh!! memcpys 1"); |
309 | memcpy(d->unwrittenBuffer,buffer+t,length-t); | 309 | memcpy(d->unwrittenBuffer,buffer+t,length-t); |
310 | d->unwritten = length-t; | 310 | d->unwritten = length-t; |
311 | } | 311 | } |
312 | //#endif | 312 | //#endif |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | unsigned int AudioDevice::channels() const | 316 | unsigned int AudioDevice::channels() const |
317 | { | 317 | { |
318 | return d->channels; | 318 | return d->channels; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | unsigned int AudioDevice::frequency() const | 322 | unsigned int AudioDevice::frequency() const |
323 | { | 323 | { |
324 | return d->frequency; | 324 | return d->frequency; |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | unsigned int AudioDevice::bytesPerSample() const | 328 | unsigned int AudioDevice::bytesPerSample() const |
329 | { | 329 | { |
330 | return d->bytesPerSample; | 330 | return d->bytesPerSample; |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | unsigned int AudioDevice::bufferSize() const | 334 | unsigned int AudioDevice::bufferSize() const |
335 | { | 335 | { |
336 | return d->bufferSize; | 336 | return d->bufferSize; |
337 | } | 337 | } |
338 | 338 | ||
339 | unsigned int AudioDevice::canWrite() const | 339 | unsigned int AudioDevice::canWrite() const |
340 | { | 340 | { |
341 | // #ifdef Q_OS_WIN32 | 341 | // #ifdef Q_OS_WIN32 |
342 | // return bufferSize(); // Any better? | 342 | // return bufferSize(); // Any better? |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 0332237..4926287 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1277,76 +1277,81 @@ void PlayListWidget::writem3u() { | |||
1277 | if( fileDlg->result() == 1 ) { | 1277 | if( fileDlg->result() == 1 ) { |
1278 | filename = fileDlg->LineEdit1->text(); | 1278 | filename = fileDlg->LineEdit1->text(); |
1279 | qDebug(filename); | 1279 | qDebug(filename); |
1280 | int noOfFiles = 0; | 1280 | int noOfFiles = 0; |
1281 | d->selectedFiles->first(); | 1281 | d->selectedFiles->first(); |
1282 | do { | 1282 | do { |
1283 | // we dont check for existance because of url's | 1283 | // we dont check for existance because of url's |
1284 | // qDebug(d->selectedFiles->current()->file()); | 1284 | // qDebug(d->selectedFiles->current()->file()); |
1285 | list += d->selectedFiles->current()->file()+"\n"; | 1285 | list += d->selectedFiles->current()->file()+"\n"; |
1286 | noOfFiles++; | 1286 | noOfFiles++; |
1287 | } | 1287 | } |
1288 | while ( d->selectedFiles->next() ); | 1288 | while ( d->selectedFiles->next() ); |
1289 | qDebug(list); | 1289 | qDebug(list); |
1290 | if(filename.left(1) != "/") | 1290 | if(filename.left(1) != "/") |
1291 | filename=QPEApplication::documentDir()+"/"+filename; | 1291 | filename=QPEApplication::documentDir()+"/"+filename; |
1292 | if(filename.right(3) != "m3u") | 1292 | if(filename.right(3) != "m3u") |
1293 | filename=filename+".m3u"; | 1293 | filename=filename+".m3u"; |
1294 | 1294 | ||
1295 | QFile f(filename); | 1295 | QFile f(filename); |
1296 | f.open(IO_WriteOnly); | 1296 | f.open(IO_WriteOnly); |
1297 | f.writeBlock(list, list.length()); | 1297 | f.writeBlock(list, list.length()); |
1298 | f.close(); | 1298 | f.close(); |
1299 | } | 1299 | } |
1300 | if(fileDlg) delete fileDlg; | 1300 | if(fileDlg) delete fileDlg; |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | void PlayListWidget::readPls(const QString &filename) { | 1303 | void PlayListWidget::readPls(const QString &filename) { |
1304 | 1304 | ||
1305 | qDebug("pls filename is "+filename); | 1305 | qDebug("pls filename is "+filename); |
1306 | QFile f(filename); | 1306 | QFile f(filename); |
1307 | 1307 | ||
1308 | if(f.open(IO_ReadOnly)) { | 1308 | if(f.open(IO_ReadOnly)) { |
1309 | QTextStream t(&f); | 1309 | QTextStream t(&f); |
1310 | QString s;//, first, second; | 1310 | QString s;//, first, second; |
1311 | int i=0; | 1311 | int i=0; |
1312 | while ( !t.atEnd()) { | 1312 | while ( !t.atEnd()) { |
1313 | s=t.readLine(); | 1313 | s=t.readLine(); |
1314 | if(s.left(4) == "File") { | 1314 | if(s.left(4) == "File") { |
1315 | s=s.right(s.length() - 6); | 1315 | s=s.right(s.length() - 6); |
1316 | s.replace(QRegExp("%20")," "); | 1316 | s.replace(QRegExp("%20")," "); |
1317 | qDebug("adding "+s+" to playlist"); | 1317 | qDebug("adding "+s+" to playlist"); |
1318 | // numberofentries=2 | 1318 | // numberofentries=2 |
1319 | // File1=http | 1319 | // File1=http |
1320 | // Title | 1320 | // Title |
1321 | // Length | 1321 | // Length |
1322 | // Version | 1322 | // Version |
1323 | // File2=http | 1323 | // File2=http |
1324 | 1324 | ||
1325 | s=s.replace( QRegExp("\\"),"/"); | 1325 | s=s.replace( QRegExp("\\"),"/"); |
1326 | DocLnk lnk( s ); | 1326 | DocLnk lnk( s ); |
1327 | QFileInfo f(s); | 1327 | QFileInfo f(s); |
1328 | QString name = f.baseName(); | 1328 | QString name = f.baseName(); |
1329 | if(name.left(4)=="http") | 1329 | if(name.left(4)=="http") |
1330 | name = s.right( s.length() - 7); | 1330 | name = s.right( s.length() - 7); |
1331 | else | 1331 | else |
1332 | name=s; | 1332 | name=s; |
1333 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1333 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1334 | // QFileInfo f(s); | 1334 | // QFileInfo f(s); |
1335 | // QString name = f.baseName(); | 1335 | // QString name = f.baseName(); |
1336 | // name = name.left(name.length()-4); | 1336 | // name = name.left(name.length()-4); |
1337 | // name = name.right(name.findRev("/",0,TRUE)); | 1337 | // name = name.right(name.findRev("/",0,TRUE)); |
1338 | lnk.setName( name); | 1338 | lnk.setName( name); |
1339 | if(s.at(s.length()-4) == '.') | 1339 | if(s.at(s.length()-4) == '.') |
1340 | lnk.setFile( s); | 1340 | lnk.setFile( s); |
1341 | else | 1341 | else { |
1342 | lnk.setFile( s+"/"); | 1342 | if( name.right(1).find('/') == -1) |
1343 | s+="/"; | ||
1344 | // if(s.right(1) != '/') | ||
1345 | lnk.setFile( s); | ||
1346 | |||
1347 | } | ||
1343 | lnk.setType("audio/x-mpegurl"); | 1348 | lnk.setType("audio/x-mpegurl"); |
1344 | 1349 | ||
1345 | qDebug("DocLnk add "+name); | 1350 | qDebug("DocLnk add "+name); |
1346 | d->selectedFiles->addToSelection( lnk); | 1351 | d->selectedFiles->addToSelection( lnk); |
1347 | } | 1352 | } |
1348 | } | 1353 | } |
1349 | i++; | 1354 | i++; |
1350 | } | 1355 | } |
1351 | } | 1356 | } |
1352 | 1357 | ||