From 4c53e68c3ac96baaaf39cc049c89d8ccf022ff59 Mon Sep 17 00:00:00 2001 From: zecke Date: Fri, 24 Sep 2004 15:15:51 +0000 Subject: 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. --- 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 @@ -54,6 +54,7 @@ using namespace Opie::Ui; 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"); 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 @@ -44,21 +44,13 @@ using namespace Opie::Core; #include #include -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 ); @@ -96,14 +88,17 @@ void XineControl::play( const QString& fileName ) { hasVideoChannel = FALSE; hasAudioChannel = FALSE; m_fileName = fileName; + m_wasError = false; - odebug << "<>>>" << 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 ); @@ -214,6 +209,19 @@ 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("", false), "" ); + returnString.replace( QRegExp("", false), "" ); + return returnString; + } + if ( !libXine->metaInfo( 0 ).isEmpty() ) { returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); } @@ -247,17 +255,17 @@ QString XineControl::getErrorCode() { odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; if ( errorCode == 1 ) { - return tr( "No input plugin found for this media type" ); + return tr( "No input plugin found for this media type" ); } else if ( errorCode == 2 ) { - return tr( "No demux plugin found for this media type" ); + return tr( "No demux plugin found for this media type" ); } else if ( errorCode == 3 ) { - return tr( "Demuxing failed for this media type" ); + return tr( "Demuxing failed for this media type" ); } else if ( errorCode == 4 ) { - return tr( "Malformed MRL" ); + return tr( "Malformed MRL" ); } else if ( errorCode == 5 ) { - return tr( "Input failed" ); + return tr( "Input failed" ); } else { - return tr( "Some other error" ); + return tr( "Some other error" ); } } 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 @@ -41,9 +41,6 @@ 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, @@ -117,6 +114,7 @@ private: bool hasAudioChannel : 1; MediaPlayerState &mediaPlayerState; XineVideoWidget *xineVideoWidget; + bool m_wasError : 1; // used for chaeting on the metainfo signals: void positionChanged( long ); -- cgit v0.9.0.2