author | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
commit | 4c53e68c3ac96baaaf39cc049c89d8ccf022ff59 (patch) (side-by-side diff) | |
tree | 8273ae338f0d611c28438a4f8a6a6fc8329e90e8 | |
parent | a214128c01e38ffd50edc4ed5b5c72593796eab2 (diff) | |
download | opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.zip opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.gz opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.bz2 |
Handling of Errors is a bit problematic with the current design.
We can start playing from multiple contexts. This are the PlayList context
and single file context. Now the problem is that
MediapPlayerState::setPlaying emits a signal. If started from the
the PlayList setPlaying(false) would trigger an infite loop together
with the Play ToggleButton, in single file context setPlaying(false)
is the right choiche.
The intermediate solution is to show an Error MessageBox and to raise
the Audio Widget and leave it to the user to close it or go to the next
file.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 48 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 4 |
3 files changed, 30 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index d73f0cd..37b998f 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -41,32 +41,33 @@ /* OPIE */ #include <opie2/odebug.h> #include <opie2/ofiledialog.h> using namespace Opie::Core; using namespace Opie::Ui; /* QT */ #include <qmessagebox.h> #include <qtoolbar.h> /* STD */ #include <assert.h> PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) { + Global::statusMessage( tr( "Loading of Skin started" ) ); mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", this , SLOT(addSelected() ) ); d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", this , SLOT(removeSelected() ) ); d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", this , SLOT( btnPlay(bool) ), TRUE ); d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index e1816c8..c47a773 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -31,47 +31,39 @@ */ #include "xinecontrol.h" #include "xinevideowidget.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> using namespace Opie::Core; /* QT */ #include <qtimer.h> #include <qmessagebox.h> -XineControl::XineControl( XineVideoWidget *xineWidget, - MediaPlayerState &_mediaPlayerState, - QObject *parent, const char *name ) - : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) -{ - libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); - - init(); -} - XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) { + m_wasError = false; + xine->ensureInitialized(); xine->setWidget( xineWidget ); init(); } void XineControl::init() { connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); @@ -83,40 +75,43 @@ void XineControl::init() XineControl::~XineControl() { #if !defined(QT_NO_COP) if ( disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif delete libXine; } void XineControl::play( const QString& fileName ) { hasVideoChannel = FALSE; hasAudioChannel = FALSE; m_fileName = fileName; + m_wasError = false; - odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; + /* + * If Playing Fails we will fire up an MessgaeBox + * but present the AudioWidget so the User can + * either Quit and change the Playlist or Continue + */ if ( !libXine->play( fileName, 0, 0 ) ) { QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); - // toggle stop so the the play button is reset - mediaPlayerState.setPlaying( false ); - return; + m_wasError = true; } mediaPlayerState.setPlaying( true ); MediaPlayerState::DisplayType displayType; if ( !libXine->hasVideo() ) { displayType = MediaPlayerState::Audio; libXine->setShowVideo( false ); hasAudioChannel = TRUE; } else { displayType = MediaPlayerState::Video; libXine->setShowVideo( true ); hasVideoChannel = TRUE; } // determine if slider is shown mediaPlayerState.setIsSeekable( libXine->isSeekable() ); @@ -201,32 +196,45 @@ long XineControl::position() { return m_position; } /** * Set videoplayback to fullscreen * @param isSet */ void XineControl::setFullscreen( bool isSet ) { libXine->showVideoFullScreen( isSet ); } QString XineControl::getMetaInfo() { QString returnString; + /* + * If there was an error let us + * change the Meta Info to contain the Error Message + */ + if ( m_wasError ) { + returnString = tr("Error on file '%1' with reason: ", + "Error when playing a file" ).arg( m_fileName ); + returnString += getErrorCode(); + returnString.replace( QRegExp("<qt>", false), "" ); + returnString.replace( QRegExp("</qt>", false), "" ); + return returnString; + } + if ( !libXine->metaInfo( 0 ).isEmpty() ) { returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); } if ( !libXine->metaInfo( 1 ).isEmpty() ) { returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); } if ( !libXine->metaInfo( 2 ).isEmpty() ) { returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); } if ( !libXine->metaInfo( 3 ).isEmpty() ) { returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); } @@ -234,41 +242,41 @@ QString XineControl::getMetaInfo() { returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); } if ( !libXine->metaInfo( 5 ).isEmpty() ) { returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); } return returnString; } QString XineControl::getErrorCode() { int errorCode = libXine->error(); odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; if ( errorCode == 1 ) { - return tr( "No input plugin found for this media type" ); + return tr( "<qt>No input plugin found for this media type</qt>" ); } else if ( errorCode == 2 ) { - return tr( "No demux plugin found for this media type" ); + return tr( "<qt>No demux plugin found for this media type</qt>" ); } else if ( errorCode == 3 ) { - return tr( "Demuxing failed for this media type" ); + return tr( "<qt>Demuxing failed for this media type</qt>" ); } else if ( errorCode == 4 ) { - return tr( "Malformed MRL" ); + return tr( "<qt>Malformed MRL</qt>" ); } else if ( errorCode == 5 ) { - return tr( "Input failed" ); + return tr( "<qt>Input failed</qt>" ); } else { - return tr( "Some other error" ); + return tr( "<qt>Some other error</qt>" ); } } /** * Seek to a position in the track * @param second the second to jump to */ void XineControl::seekTo( long second ) { libXine->seekTo( (int)second ); } void XineControl::videoResized ( const QSize &s ) { libXine->resize( s ); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 3f44f2e..848bd05 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -28,35 +28,32 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef XINECONTROL_H #define XINECONTROL_H #include "lib.h" #include "mediaplayerstate.h" class XineControl : public QObject { Q_OBJECT public: - XineControl( XineVideoWidget *xineWidget, - MediaPlayerState &_mediaPlayerState, - QObject *parent = 0, const char *name =0 ); // note that this constructor takes over ownership of the passed // XINE::Lib object. XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 ); ~XineControl(); bool hasVideo() const { return hasVideoChannel; } bool hasAudio() const { return hasAudioChannel; } public slots: void play( const QString& fileName ); void stop( bool ); /** * Pause the media stream @@ -104,23 +101,24 @@ public slots: */ void setGamma( int ); private: void init(); XINE::Lib *libXine; long m_currentTime; long m_position; int m_length; QString m_fileName; bool disabledSuspendScreenSaver : 1; bool hasVideoChannel : 1; bool hasAudioChannel : 1; MediaPlayerState &mediaPlayerState; XineVideoWidget *xineVideoWidget; + bool m_wasError : 1; // used for chaeting on the metainfo signals: void positionChanged( long ); }; #endif |