summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp13
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.h2
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3io.c132
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp20
-rw-r--r--core/multimedia/opieplayer/playlistselection.h6
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp250
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
@@ -33,4 +33,5 @@
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
@@ -48,4 +49,5 @@ extern "C" {
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)
@@ -166,5 +168,8 @@ bool LibMadPlugin::isFileSupported( const QString& path ) {
166bool LibMadPlugin::open( const QString& path ) { 168bool 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;
@@ -198,5 +203,5 @@ bool LibMadPlugin::open( const QString& path ) {
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");
@@ -370,5 +375,5 @@ bool LibMadPlugin::read() {
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);
@@ -381,5 +386,5 @@ bool LibMadPlugin::read() {
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)
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
@@ -104,5 +104,5 @@ private:
104 LibMadPluginData *d; 104 LibMadPluginData *d;
105 QString info; 105 QString info;
106 106int bufferSize;
107}; 107};
108 108
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
@@ -13,36 +13,36 @@
13mpeg3_fs_t* mpeg3_new_fs(char *path) 13mpeg3_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
21int mpeg3_delete_fs(mpeg3_fs_t *fs) 21int 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
28int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src) 28int 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
35long mpeg3io_get_total_bytes(mpeg3_fs_t *fs) 35long 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
@@ -50,78 +50,78 @@ 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
71int mpeg3io_close_file(mpeg3_fs_t *fs) 71int 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
78int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs) 78int 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
87int mpeg3io_device(char *path, char *device) 87int 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
116int mpeg3io_seek(mpeg3_fs_t *fs, long byte) 116int 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
122int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes) 122int 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
@@ -20,4 +20,6 @@
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>
@@ -51,5 +53,5 @@ 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 );
@@ -185,3 +187,17 @@ void PlayListSelection::unSelect()
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
191void 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
200void 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
@@ -24,5 +24,5 @@
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
28class PlayListSelection : public QListView { 28class PlayListSelection : public QListView {
@@ -38,5 +38,7 @@ public slots:
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();
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
@@ -26,4 +26,5 @@
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>
@@ -217,4 +218,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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
@@ -239,4 +243,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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)),
@@ -319,7 +326,6 @@ void PlayListWidget::initializeStates() {
319void PlayListWidget::readConfig( Config& cfg ) { 326void 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;
@@ -327,44 +333,45 @@ void PlayListWidget::readConfig( Config& cfg ) {
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
335void PlayListWidget::writeConfig( Config& cfg ) const { 343void 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
@@ -387,15 +394,15 @@ void PlayListWidget::clearList() {
387 394
388void PlayListWidget::addAllToList() { 395void 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
397void PlayListWidget::addAllMusicToList() { 404void 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 )
@@ -405,7 +412,5 @@ void PlayListWidget::addAllMusicToList() {
405 412
406void PlayListWidget::addAllVideoToList() { 413void 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 );
@@ -469,13 +474,13 @@ const DocLnk *PlayListWidget::current() { // this is fugly
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;
@@ -513,27 +518,27 @@ const DocLnk *PlayListWidget::current() { // this is fugly
513bool PlayListWidget::prev() { 518bool 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}
@@ -542,18 +547,18 @@ bool PlayListWidget::prev() {
542bool PlayListWidget::next() { 547bool 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}
@@ -562,7 +567,7 @@ bool PlayListWidget::next() {
562bool PlayListWidget::first() { 567bool 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
@@ -570,7 +575,7 @@ bool PlayListWidget::first() {
570bool PlayListWidget::last() { 575bool 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
@@ -583,17 +588,20 @@ void PlayListWidget::saveList() {
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( "");
@@ -602,4 +610,5 @@ void PlayListWidget::saveList() {
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");
@@ -609,6 +618,6 @@ void PlayListWidget::saveList() {
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
@@ -622,9 +631,12 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
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
@@ -784,5 +796,6 @@ void PlayListWidget::btnPlay(bool b) {
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 }
@@ -795,5 +808,6 @@ void PlayListWidget::btnPlay(bool b) {
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 }
@@ -906,14 +920,20 @@ 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);
@@ -924,13 +944,19 @@ void PlayListWidget::populateAudioView() {
924 944
925void PlayListWidget::populateVideoView() { 945void 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() ) {