summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp92
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
@@ -21,115 +21,112 @@
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// this file is based on work by trolltech
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/config.h>
#include <qvaluelist.h>
#include <qobject.h>
#include <qdir.h>
#include "mediaplayerstate.h"
//#define MediaPlayerDebug(x) qDebug x
#define MediaPlayerDebug(x)
MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
: QObject( parent, name ) {
Config cfg( "OpiePlayer" );
readConfig( cfg );
streaming = false;
seekable = true;
}
MediaPlayerState::~MediaPlayerState() {
}
void MediaPlayerState::readConfig( Config& cfg ) {
cfg.setGroup("Options");
fullscreen = cfg.readBoolEntry( "FullScreen" );
scaled = cfg.readBoolEntry( "Scaling" );
looping = cfg.readBoolEntry( "Looping" );
shuffled = cfg.readBoolEntry( "Shuffle" );
- usePlaylist = cfg.readBoolEntry( "UsePlayList" );
videoGamma = cfg.readNumEntry( "VideoGamma" );
- usePlaylist = TRUE;
playing = FALSE;
streaming = FALSE;
paused = FALSE;
curPosition = 0;
curLength = 0;
curView = 'l';
}
void MediaPlayerState::writeConfig( Config& cfg ) const {
cfg.setGroup( "Options" );
cfg.writeEntry( "FullScreen", fullscreen );
cfg.writeEntry( "Scaling", scaled );
cfg.writeEntry( "Looping", looping );
cfg.writeEntry( "Shuffle", shuffled );
- cfg.writeEntry( "UsePlayList", usePlaylist );
cfg.writeEntry( "VideoGamma", videoGamma );
}
// slots
void MediaPlayerState::setIsStreaming( bool b ) {
streaming = b;
}
void MediaPlayerState::setIsSeekable( bool b ) {
seekable = b;
emit isSeekableToggled(b);
}
void MediaPlayerState::setFullscreen( bool b ) {
if ( fullscreen == b ) {
return;
}
fullscreen = b;
emit fullscreenToggled(b);
}
void MediaPlayerState::setBlanked( bool b ) {
if ( blanked == b ) {
return;
}
blanked = b;
emit blankToggled(b);
}
void MediaPlayerState::setScaled( bool b ) {
if ( scaled == b ) {
return;
}
scaled = b;
emit scaledToggled(b);
}
void MediaPlayerState::setLooping( bool b ) {
if ( looping == b ) {
return;
}
looping = b;
emit loopingToggled(b);
}
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
@@ -11,97 +11,96 @@
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// this file is based on work by trolltech
#ifndef MEDIA_PLAYER_STATE_H
#define MEDIA_PLAYER_STATE_H
#include <qobject.h>
class MediaPlayerDecoder;
class Config;
class MediaPlayerState : public QObject {
Q_OBJECT
public:
MediaPlayerState( QObject *parent, const char *name );
~MediaPlayerState();
bool isStreaming() const { return streaming; }
bool isSeekable() const { return seekable; }
bool isFullscreen() const { return fullscreen; }
bool isScaled() const { return scaled; }
bool isLooping() const { return looping; }
bool isShuffled() const { return shuffled; }
- bool isUsingPlaylist() const { return usePlaylist; }
bool isPaused() const { return paused; }
bool isPlaying() const { return playing; }
bool isStopped() const { return stopped; }
long position() const { return curPosition; }
long length() const { return curLength; }
char view() const { return curView; }
public slots:
void setIsStreaming( bool b );
void setIsSeekable( bool b );
void setFullscreen( bool b );
void setScaled( bool b );
void setLooping( bool b );
void setShuffled( bool b );
void setPaused( bool b );
void setPlaying( bool b );
void setStopped( bool b );
void setPosition( long p );
void updatePosition( long p );
void setLength( long l );
void setView( char v );
void setBlanked( bool b );
void setVideoGamma( int v );
void setPrev();
void setNext();
void setList();
void setVideo();
void setAudio();
void toggleFullscreen();
void toggleScaled();
void toggleLooping();
void toggleShuffled();
void togglePaused();
void togglePlaying();
void toggleBlank();
void writeConfig( Config& cfg ) const;
signals:
void fullscreenToggled( bool );
void scaledToggled( bool );
void loopingToggled( bool );
void shuffledToggled( bool );
void pausedToggled( bool );
void playingToggled( bool );
void stopToggled( bool );
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
@@ -160,105 +160,101 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
populateSkinsMenu();
initializeStates();
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
loadList(DocLnk( currentPlaylist ) );
}
PlayListWidget::~PlayListWidget() {
delete d;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->isPlaying() );
d->tbLoop->setOn( mediaPlayerState->isLooping() );
d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
d->playListFrame->show();
}
void PlayListWidget::writeDefaultPlaylist() {
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
QString filename=QPEApplication::documentDir() + "/default.m3u";
QString currentString = config.readEntry( "CurrentPlaylist", filename);
if( currentString == filename) {
Om3u *m3uList;
// qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
if( d->selectedFiles->first() ) {
m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
do {
// qDebug(d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
- if ( mediaPlayerState->isUsingPlaylist() ) {
- if( QFileInfo( lnk.file() ).exists() ||
- lnk.file().left(4) == "http" ) {
- d->selectedFiles->addToSelection( lnk );
- }
-// writeCurrentM3u();
+ if( QFileInfo( lnk.file() ).exists() ||
+ lnk.file().left(4) == "http" ) {
+ d->selectedFiles->addToSelection( lnk );
}
- else
- mediaPlayerState->setPlaying( TRUE );
+// writeCurrentM3u();
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::addAllToList() {
// QTime t;
// t.start();
if(!audioScan) {
if(audioView->childCount() < 1)
@@ -377,168 +373,150 @@ void PlayListWidget::addAllVideoToList() {
d->selectedFiles->addToSelection( **dit );
}
}
*/
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument( const QString& fileref ) {
// qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
if ( fileref.isNull() ) {
QMessageBox::warning( this, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
clearList();
if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
readm3u( fileref );
} else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
readm3u( DocLnk( fileref).file() );
} else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
readPls( fileref );
} else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
readPls( DocLnk( fileref).file() );
} else {
clearList();
addToSelection( DocLnk( fileref ) );
writeCurrentM3u();
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() const { // this is fugly
assert( currentTab() == CurrentPlayList );
-// qDebug("playlist");
- if ( mediaPlayerState->isUsingPlaylist() )
- return d->selectedFiles->current();
-
- assert( false );
+ return d->selectedFiles->current();
}
bool PlayListWidget::prev() {
- if ( mediaPlayerState->isUsingPlaylist() ) {
- if ( mediaPlayerState->isShuffled() ) {
- const DocLnk *cur = current();
- int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
- for ( int i = 0; i < j; i++ ) {
- if ( !d->selectedFiles->next() )
- d->selectedFiles->first();
+ if ( mediaPlayerState->isShuffled() ) {
+ const DocLnk *cur = current();
+ int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
+ for ( int i = 0; i < j; i++ ) {
+ if ( !d->selectedFiles->next() )
+ d->selectedFiles->first();
+ }
+ if ( cur == current() )
+ if ( !d->selectedFiles->next() ) {
+ d->selectedFiles->first();
}
- if ( cur == current() )
- if ( !d->selectedFiles->next() ) {
- d->selectedFiles->first();
- }
- return TRUE;
- } else {
- if ( !d->selectedFiles->prev() ) {
- if ( mediaPlayerState->isLooping() ) {
- return d->selectedFiles->last();
- } else {
- return FALSE;
- }
+ return TRUE;
+ } else {
+ if ( !d->selectedFiles->prev() ) {
+ if ( mediaPlayerState->isLooping() ) {
+ return d->selectedFiles->last();
+ } else {
+ return FALSE;
}
- return TRUE;
}
- } else {
- return mediaPlayerState->isLooping();
- }
+ return TRUE;
+ }
}
bool PlayListWidget::next() {
//qDebug("<<<<<<<<<<<<next()");
- if ( mediaPlayerState->isUsingPlaylist() ) {
- if ( mediaPlayerState->isShuffled() ) {
- return prev();
- } else {
- if ( !d->selectedFiles->next() ) {
- if ( mediaPlayerState->isLooping() ) {
- return d->selectedFiles->first();
- } else {
- return FALSE;
- }
+ if ( mediaPlayerState->isShuffled() ) {
+ return prev();
+ } else {
+ if ( !d->selectedFiles->next() ) {
+ if ( mediaPlayerState->isLooping() ) {
+ return d->selectedFiles->first();
+ } else {
+ return FALSE;
}
- return TRUE;
}
- } else {
- return mediaPlayerState->isLooping();
+ return TRUE;
}
}
bool PlayListWidget::first() {
- if ( mediaPlayerState->isUsingPlaylist() )
- return d->selectedFiles->first();
- else
- return mediaPlayerState->isLooping();
+ return d->selectedFiles->first();
}
bool PlayListWidget::last() {
- if ( mediaPlayerState->isUsingPlaylist() )
- return d->selectedFiles->last();
- else
- return mediaPlayerState->isLooping();
+ return d->selectedFiles->last();
}
void PlayListWidget::saveList() {
writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
readm3u(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::addSelected() {
assert( inFileListMode() );
QListView *fileListView = currentFileListView();
QListViewItemIterator it( fileListView );
for ( ; it.current(); ++it )
if ( it.current()->isSelected() ) {
QString filename = it.current()->text(3);
DocLnk lnk;
lnk.setName( QFileInfo( filename ).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk );
}
fileListView->clearSelection();
tabWidget->setCurrentPage( 0 );
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
writeCurrentM3u();
}