summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 15:51:48 (UTC)
committer simon <simon>2002-12-02 15:51:48 (UTC)
commita0cfa5b76aac8de36304faef4bb2b14237c04c9a (patch) (side-by-side diff)
tree0b427d07d918671065e6aed1682b108cda166ce7
parent9f770813346acbe7817b20c5fe0fea03827fc41a (diff)
downloadopie-a0cfa5b76aac8de36304faef4bb2b14237c04c9a.zip
opie-a0cfa5b76aac8de36304faef4bb2b14237c04c9a.tar.gz
opie-a0cfa5b76aac8de36304faef4bb2b14237c04c9a.tar.bz2
- simplified MediaPlayer::setPlaying, moving more switch() like code into
playlistwidget
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp12
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h15
4 files changed, 33 insertions, 24 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 6a38adc..74ab2e3 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -30,13 +30,13 @@ extern PlayListWidget *playList;
extern MediaPlayerState *mediaPlayerState;
#define FBIOBLANK 0x4611
MediaPlayer::MediaPlayer( QObject *parent, const char *name )
- : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
+ : QObject( parent, name ), volumeDirection( 0 ) {
fd=-1;fl=-1;
playList->setCaption( tr( "OpiePlayer: Initializating" ) );
qApp->processEvents();
// QPEApplication::grabKeyboard(); // EVIL
@@ -92,47 +92,34 @@ void MediaPlayer::setPlaying( bool play ) {
if ( mediaPlayerState->isPaused() ) {
mediaPlayerState->setPaused( FALSE );
return;
}
QString tickerText, time, fileName;
- if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //check for filelist
- const DocLnk *playListCurrent = playList->current();
- if ( playListCurrent != NULL ) {
- currentFile = playListCurrent;
- }
- xineControl->play( currentFile->file() );
- fileName = currentFile->name();
- long seconds = mediaPlayerState->length();//
- time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
- //qDebug(time);
-
- } else {
+ if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) {
//if playing in file list.. play in a different way
// random and looping settings enabled causes problems here,
// since there is no selected file in the playlist, but a selected file in the file list,
// so we remember and shutoff
l = mediaPlayerState->isLooping();
if(l) {
mediaPlayerState->setLooping( false );
}
r = mediaPlayerState->isShuffled();
mediaPlayerState->setShuffled( false );
+ }
+
+ PlayListWidget::Entry playListEntry = playList->currentEntry();
+ fileName = playListEntry.name;
+ xineControl->play( playListEntry.file );
- fileName = playList->currentFileListPathName();
- xineControl->play( fileName );
long seconds = mediaPlayerState->length();
time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
- //qDebug(time);
- if( fileName.left(4) != "http" ) {
- fileName = QFileInfo( fileName ).baseName();
- }
-
- }
if( fileName.left(4) == "http" ) {
+ fileName = QFileInfo( fileName ).baseName();
if ( xineControl->getMetaInfo().isEmpty() ) {
tickerText = tr( " File: " ) + fileName;
} else {
tickerText = xineControl->getMetaInfo();
}
} else {
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index 002311a..1e34c88 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -65,13 +65,12 @@ protected:
void timerEvent( QTimerEvent *e );
void keyReleaseEvent( QKeyEvent *e);
private:
bool isBlanked, l, r;
int fd, fl;
int volumeDirection;
- const DocLnk *currentFile;
XineControl *xineControl;
VolumeControl *volControl;
};
#endif // MEDIA_PLAYER_H
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index fd256b7..ce73252 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -421,13 +421,13 @@ void PlayListWidget::setDocument( const QString& fileref ) {
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
-const DocLnk *PlayListWidget::current() { // this is fugly
+const DocLnk *PlayListWidget::current() const { // this is fugly
assert( currentTab() == CurrentPlayList );
// qDebug("playlist");
if ( mediaPlayerState->isUsingPlaylist() ) {
return d->selectedFiles->current();
} else if ( d->setDocumentUsed && d->current ) {
@@ -1138,9 +1138,19 @@ PlayListWidget::TabType PlayListWidget::currentTab() const
int index = tabWidget->currentPageIndex();
assert( index < TabTypeCount && index >= 0 );
return indexToTabType[ index ];
}
+PlayListWidget::Entry PlayListWidget::currentEntry() const
+{
+ if ( currentTab() == CurrentPlayList ) {
+ const DocLnk *lnk = current();
+ return Entry( lnk->name(), lnk->file() );
+ }
+
+ return Entry( currentFileListPathName() );
+}
+
QString PlayListWidget::currentFileListPathName() const {
return currentFileListView()->currentItem()->text( 3 );
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 2e2ff89..511a192 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -55,25 +55,38 @@ class QLabel;
class PlayListWidget : public PlayListWidgetGui {
Q_OBJECT
public:
enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
enum { TabTypeCount = 4 };
+ struct Entry
+ {
+ Entry( const QString &_name, const QString &_fileName )
+ : name( _name ), file( _fileName ) {}
+ Entry( const QString &_fileName )
+ : name( _fileName ), file( _fileName ) {}
+
+ QString name;
+ QString file;
+ };
+
PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
~PlayListWidget();
DocLnkSet files;
DocLnkSet vFiles;
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
- const DocLnk *current();
+ const DocLnk *current() const;
void useSelectedDocument();
int selected;
TabType currentTab() const;
+ Entry currentEntry() const;
+
public slots:
bool first();
bool last();
bool next();
bool prev();
void writeDefaultPlaylist( );