-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 92 |
3 files changed, 35 insertions, 61 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 43040c2..586870c 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -57,43 +57,40 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | |||
57 | 57 | ||
58 | 58 | ||
59 | MediaPlayerState::~MediaPlayerState() { | 59 | MediaPlayerState::~MediaPlayerState() { |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void MediaPlayerState::readConfig( Config& cfg ) { | 63 | void MediaPlayerState::readConfig( Config& cfg ) { |
64 | cfg.setGroup("Options"); | 64 | cfg.setGroup("Options"); |
65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
66 | scaled = cfg.readBoolEntry( "Scaling" ); | 66 | scaled = cfg.readBoolEntry( "Scaling" ); |
67 | looping = cfg.readBoolEntry( "Looping" ); | 67 | looping = cfg.readBoolEntry( "Looping" ); |
68 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 68 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
69 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | ||
70 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
71 | usePlaylist = TRUE; | ||
72 | playing = FALSE; | 70 | playing = FALSE; |
73 | streaming = FALSE; | 71 | streaming = FALSE; |
74 | paused = FALSE; | 72 | paused = FALSE; |
75 | curPosition = 0; | 73 | curPosition = 0; |
76 | curLength = 0; | 74 | curLength = 0; |
77 | curView = 'l'; | 75 | curView = 'l'; |
78 | } | 76 | } |
79 | 77 | ||
80 | 78 | ||
81 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 79 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
82 | cfg.setGroup( "Options" ); | 80 | cfg.setGroup( "Options" ); |
83 | cfg.writeEntry( "FullScreen", fullscreen ); | 81 | cfg.writeEntry( "FullScreen", fullscreen ); |
84 | cfg.writeEntry( "Scaling", scaled ); | 82 | cfg.writeEntry( "Scaling", scaled ); |
85 | cfg.writeEntry( "Looping", looping ); | 83 | cfg.writeEntry( "Looping", looping ); |
86 | cfg.writeEntry( "Shuffle", shuffled ); | 84 | cfg.writeEntry( "Shuffle", shuffled ); |
87 | cfg.writeEntry( "UsePlayList", usePlaylist ); | ||
88 | cfg.writeEntry( "VideoGamma", videoGamma ); | 85 | cfg.writeEntry( "VideoGamma", videoGamma ); |
89 | } | 86 | } |
90 | 87 | ||
91 | // slots | 88 | // slots |
92 | void MediaPlayerState::setIsStreaming( bool b ) { | 89 | void MediaPlayerState::setIsStreaming( bool b ) { |
93 | streaming = b; | 90 | streaming = b; |
94 | } | 91 | } |
95 | 92 | ||
96 | void MediaPlayerState::setIsSeekable( bool b ) { | 93 | void MediaPlayerState::setIsSeekable( bool b ) { |
97 | seekable = b; | 94 | seekable = b; |
98 | emit isSeekableToggled(b); | 95 | emit isSeekableToggled(b); |
99 | } | 96 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 7a80ad8..fc4e6cb 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -47,25 +47,24 @@ class Config; | |||
47 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | MediaPlayerState( QObject *parent, const char *name ); | 50 | MediaPlayerState( QObject *parent, const char *name ); |
51 | ~MediaPlayerState(); | 51 | ~MediaPlayerState(); |
52 | 52 | ||
53 | bool isStreaming() const { return streaming; } | 53 | bool isStreaming() const { return streaming; } |
54 | bool isSeekable() const { return seekable; } | 54 | bool isSeekable() const { return seekable; } |
55 | bool isFullscreen() const { return fullscreen; } | 55 | bool isFullscreen() const { return fullscreen; } |
56 | bool isScaled() const { return scaled; } | 56 | bool isScaled() const { return scaled; } |
57 | bool isLooping() const { return looping; } | 57 | bool isLooping() const { return looping; } |
58 | bool isShuffled() const { return shuffled; } | 58 | bool isShuffled() const { return shuffled; } |
59 | bool isUsingPlaylist() const { return usePlaylist; } | ||
60 | bool isPaused() const { return paused; } | 59 | bool isPaused() const { return paused; } |
61 | bool isPlaying() const { return playing; } | 60 | bool isPlaying() const { return playing; } |
62 | bool isStopped() const { return stopped; } | 61 | bool isStopped() const { return stopped; } |
63 | long position() const { return curPosition; } | 62 | long position() const { return curPosition; } |
64 | long length() const { return curLength; } | 63 | long length() const { return curLength; } |
65 | char view() const { return curView; } | 64 | char view() const { return curView; } |
66 | 65 | ||
67 | public slots: | 66 | public slots: |
68 | void setIsStreaming( bool b ); | 67 | void setIsStreaming( bool b ); |
69 | void setIsSeekable( bool b ); | 68 | void setIsSeekable( bool b ); |
70 | void setFullscreen( bool b ); | 69 | void setFullscreen( bool b ); |
71 | void setScaled( bool b ); | 70 | void setScaled( bool b ); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 5b277cc..f53def6 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -196,33 +196,29 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | 201 | ||
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
208 | if ( mediaPlayerState->isUsingPlaylist() ) { | 208 | if( QFileInfo( lnk.file() ).exists() || |
209 | if( QFileInfo( lnk.file() ).exists() || | 209 | lnk.file().left(4) == "http" ) { |
210 | lnk.file().left(4) == "http" ) { | 210 | d->selectedFiles->addToSelection( lnk ); |
211 | d->selectedFiles->addToSelection( lnk ); | ||
212 | } | ||
213 | // writeCurrentM3u(); | ||
214 | } | 211 | } |
215 | else | 212 | // writeCurrentM3u(); |
216 | mediaPlayerState->setPlaying( TRUE ); | ||
217 | } | 213 | } |
218 | 214 | ||
219 | 215 | ||
220 | void PlayListWidget::clearList() { | 216 | void PlayListWidget::clearList() { |
221 | while ( first() ) { | 217 | while ( first() ) { |
222 | d->selectedFiles->removeSelected(); | 218 | d->selectedFiles->removeSelected(); |
223 | } | 219 | } |
224 | } | 220 | } |
225 | 221 | ||
226 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
227 | switch (mouse) { | 223 | switch (mouse) { |
228 | case 1: | 224 | case 1: |
@@ -413,96 +409,78 @@ void PlayListWidget::setDocument( const QString& fileref ) { | |||
413 | } | 409 | } |
414 | } | 410 | } |
415 | 411 | ||
416 | 412 | ||
417 | void PlayListWidget::useSelectedDocument() { | 413 | void PlayListWidget::useSelectedDocument() { |
418 | d->setDocumentUsed = FALSE; | 414 | d->setDocumentUsed = FALSE; |
419 | } | 415 | } |
420 | 416 | ||
421 | 417 | ||
422 | const DocLnk *PlayListWidget::current() const { // this is fugly | 418 | const DocLnk *PlayListWidget::current() const { // this is fugly |
423 | assert( currentTab() == CurrentPlayList ); | 419 | assert( currentTab() == CurrentPlayList ); |
424 | 420 | ||
425 | // qDebug("playlist"); | 421 | return d->selectedFiles->current(); |
426 | if ( mediaPlayerState->isUsingPlaylist() ) | ||
427 | return d->selectedFiles->current(); | ||
428 | |||
429 | assert( false ); | ||
430 | } | 422 | } |
431 | 423 | ||
432 | 424 | ||
433 | bool PlayListWidget::prev() { | 425 | bool PlayListWidget::prev() { |
434 | if ( mediaPlayerState->isUsingPlaylist() ) { | 426 | if ( mediaPlayerState->isShuffled() ) { |
435 | if ( mediaPlayerState->isShuffled() ) { | 427 | const DocLnk *cur = current(); |
436 | const DocLnk *cur = current(); | 428 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
437 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 429 | for ( int i = 0; i < j; i++ ) { |
438 | for ( int i = 0; i < j; i++ ) { | 430 | if ( !d->selectedFiles->next() ) |
439 | if ( !d->selectedFiles->next() ) | 431 | d->selectedFiles->first(); |
440 | d->selectedFiles->first(); | 432 | } |
433 | if ( cur == current() ) | ||
434 | if ( !d->selectedFiles->next() ) { | ||
435 | d->selectedFiles->first(); | ||
441 | } | 436 | } |
442 | if ( cur == current() ) | 437 | return TRUE; |
443 | if ( !d->selectedFiles->next() ) { | 438 | } else { |
444 | d->selectedFiles->first(); | 439 | if ( !d->selectedFiles->prev() ) { |
445 | } | 440 | if ( mediaPlayerState->isLooping() ) { |
446 | return TRUE; | 441 | return d->selectedFiles->last(); |
447 | } else { | 442 | } else { |
448 | if ( !d->selectedFiles->prev() ) { | 443 | return FALSE; |
449 | if ( mediaPlayerState->isLooping() ) { | ||
450 | return d->selectedFiles->last(); | ||
451 | } else { | ||
452 | return FALSE; | ||
453 | } | ||
454 | } | 444 | } |
455 | return TRUE; | ||
456 | } | 445 | } |
457 | } else { | 446 | return TRUE; |
458 | return mediaPlayerState->isLooping(); | 447 | } |
459 | } | ||
460 | } | 448 | } |
461 | 449 | ||
462 | 450 | ||
463 | bool PlayListWidget::next() { | 451 | bool PlayListWidget::next() { |
464 | //qDebug("<<<<<<<<<<<<next()"); | 452 | //qDebug("<<<<<<<<<<<<next()"); |
465 | if ( mediaPlayerState->isUsingPlaylist() ) { | 453 | if ( mediaPlayerState->isShuffled() ) { |
466 | if ( mediaPlayerState->isShuffled() ) { | 454 | return prev(); |
467 | return prev(); | 455 | } else { |
468 | } else { | 456 | if ( !d->selectedFiles->next() ) { |
469 | if ( !d->selectedFiles->next() ) { | 457 | if ( mediaPlayerState->isLooping() ) { |
470 | if ( mediaPlayerState->isLooping() ) { | 458 | return d->selectedFiles->first(); |
471 | return d->selectedFiles->first(); | 459 | } else { |
472 | } else { | 460 | return FALSE; |
473 | return FALSE; | ||
474 | } | ||
475 | } | 461 | } |
476 | return TRUE; | ||
477 | } | 462 | } |
478 | } else { | 463 | return TRUE; |
479 | return mediaPlayerState->isLooping(); | ||
480 | } | 464 | } |
481 | } | 465 | } |
482 | 466 | ||
483 | 467 | ||
484 | bool PlayListWidget::first() { | 468 | bool PlayListWidget::first() { |
485 | if ( mediaPlayerState->isUsingPlaylist() ) | 469 | return d->selectedFiles->first(); |
486 | return d->selectedFiles->first(); | ||
487 | else | ||
488 | return mediaPlayerState->isLooping(); | ||
489 | } | 470 | } |
490 | 471 | ||
491 | 472 | ||
492 | bool PlayListWidget::last() { | 473 | bool PlayListWidget::last() { |
493 | if ( mediaPlayerState->isUsingPlaylist() ) | 474 | return d->selectedFiles->last(); |
494 | return d->selectedFiles->last(); | ||
495 | else | ||
496 | return mediaPlayerState->isLooping(); | ||
497 | } | 475 | } |
498 | 476 | ||
499 | 477 | ||
500 | void PlayListWidget::saveList() { | 478 | void PlayListWidget::saveList() { |
501 | writem3u(); | 479 | writem3u(); |
502 | } | 480 | } |
503 | 481 | ||
504 | 482 | ||
505 | void PlayListWidget::loadList( const DocLnk & lnk) { | 483 | void PlayListWidget::loadList( const DocLnk & lnk) { |
506 | QString name = lnk.name(); | 484 | QString name = lnk.name(); |
507 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 485 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
508 | 486 | ||