Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 100 |
1 files changed, 65 insertions, 35 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index bf2acc8..553e3c1 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -1,17 +1,18 @@ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> +#include <qfileinfo.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qwidgetstack.h> #include <qfile.h> #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" #include "videowidget.h" #include "volumecontrol.h" @@ -66,83 +67,112 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) MediaPlayer::~MediaPlayer() { delete xineControl; delete volControl; } void MediaPlayer::pauseCheck( bool b ) { if ( b && !mediaPlayerState->playing() ) { mediaPlayerState->setPaused( FALSE ); } } void MediaPlayer::play() { - mediaPlayerState->setPlaying( FALSE ); - mediaPlayerState->setPlaying( TRUE ); + mediaPlayerState->setPlaying( FALSE ); + mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { return; } - if ( mediaPlayerState->paused() ) { - mediaPlayerState->setPaused( FALSE ); - return; - } - - const DocLnk *playListCurrent = playList->current(); - if ( playListCurrent != NULL ) { - currentFile = playListCurrent; + if ( mediaPlayerState->paused() ) { + mediaPlayerState->setPaused( FALSE ); + return; } - xineControl->play( currentFile->file() ); - - long seconds = mediaPlayerState->length();// - QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); - qDebug(time); - - QString tickerText; - if( currentFile->file().left(4) == "http" ) - tickerText= tr( " File: " ) + currentFile->name(); - else - tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; - - audioUI->setTickerText( currentFile->file( ) ); + QString tickerText, time, fileName; + if( playList->whichList() == 0 ) { //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 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->looping(); + if(l) + mediaPlayerState->setLooping( false ); + r = mediaPlayerState->shuffled(); + mediaPlayerState->setShuffled(false); + + 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" ) + tickerText= tr( " File: " ) + fileName; + else + tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time; + audioUI->setTickerText( tickerText ); } void MediaPlayer::prev() { - if ( playList->prev() ) { - play(); - } else if ( mediaPlayerState->looping() ) { - if ( playList->last() ) { + if(playList->whichList() == 0) { //if using the playlist + if ( playList->prev() ) { play(); + } else if ( mediaPlayerState->looping() ) { + if ( playList->last() ) { + play(); + } + } else { + mediaPlayerState->setList(); } - } else { - mediaPlayerState->setList(); } } void MediaPlayer::next() { - if ( playList->next() ) { - play(); - } else if ( mediaPlayerState->looping() ) { - if ( playList->first() ) { + + if(playList->whichList() == 0) { //if using the playlist + if ( playList->next() ) { play(); + } else if ( mediaPlayerState->looping() ) { + if ( playList->first() ) { + play(); + } + } else { + mediaPlayerState->setList(); } - } else { - mediaPlayerState->setList(); + } else { //if playing from file list, let's just stop + qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); + mediaPlayerState->setPlaying(false); + mediaPlayerState->setView('l'); + if(l) mediaPlayerState->setLooping(l); + if(r) mediaPlayerState->setShuffled(r); } + qApp->processEvents(); } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); volControl->decVol(2); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; |