Diffstat (limited to 'noncore/multimedia/opieplayer2/xinecontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 109 |
1 files changed, 78 insertions, 31 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index fabc9a5..c22822c 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -35,2 +35,3 @@ #include <qtimer.h> +#include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> @@ -45,6 +46,7 @@ XineControl::XineControl( QObject *parent, const char *name ) : QObject( parent, name ) { + libXine = new XINE::Lib(videoUI->vidWidget() ); - connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); - connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); + connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); + connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); @@ -54,3 +56,3 @@ XineControl::XineControl( QObject *parent, const char *name ) connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); - connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); + connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); @@ -64,3 +66,3 @@ XineControl::~XineControl() { // Re-enable the suspend mode - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } @@ -71,4 +73,4 @@ XineControl::~XineControl() { void XineControl::play( const QString& fileName ) { - hasVideoChannel=FALSE; - hasAudioChannel=FALSE; + hasVideoChannel = FALSE; + hasAudioChannel = FALSE; m_fileName = fileName; @@ -77,15 +79,20 @@ void XineControl::play( const QString& fileName ) { - libXine->play( fileName ); - mediaPlayerState->setPlaying( true ); - char whichGui = mdetect.videoOrAudio( fileName ); - if (whichGui == 'f') { - qDebug("Nicht erkannter Dateityp"); + if ( !libXine->play( fileName ) ) { + QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); return; } - if (whichGui == 'a') { + mediaPlayerState->setPlaying( true ); + + char whichGui; + // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); + if ( !libXine->hasVideo() ) { + whichGui = 'a'; + qDebug("HAS AUDIO"); libXine->setShowVideo( false ); - hasAudioChannel=TRUE; + hasAudioChannel = TRUE; } else { + whichGui = 'v'; + qDebug("HAS VIDEO"); libXine->setShowVideo( true ); - hasVideoChannel=TRUE; + hasVideoChannel = TRUE; } @@ -96,3 +103,2 @@ void XineControl::play( const QString& fileName ) { - #if defined(Q_WS_QWS) && !defined(QT_NO_COP) @@ -101,3 +107,3 @@ void XineControl::play( const QString& fileName ) { // Stop the screen from blanking and power saving state - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); @@ -119,4 +125,4 @@ void XineControl::setGamma( int value ) { void XineControl::stop( bool isSet ) { - if ( !isSet) { - libXine->stop( ); + if ( !isSet ) { + libXine->stop(); @@ -126,6 +132,5 @@ void XineControl::stop( bool isSet ) { // Re-enable the suspend mode - QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif - } @@ -138,6 +143,6 @@ void XineControl::stop( bool isSet ) { void XineControl::pause( bool isSet) { - if (isSet) { + if ( isSet ) { libXine->pause(); } else { - libXine->play( m_fileName, 0, m_currentTime); + libXine->play( m_fileName, 0, m_currentTime ); } @@ -151,3 +156,3 @@ long XineControl::currentTime() { // todo: jede sekunde überprüfen - m_currentTime = libXine->currentTime(); + m_currentTime = libXine->currentTime(); return m_currentTime; @@ -170,10 +175,11 @@ void XineControl::length() { long XineControl::position() { - m_position = ( currentTime() ); - mediaPlayerState->updatePosition( m_position ); + m_position = ( currentTime() ); + mediaPlayerState->updatePosition( m_position ); long emitPos = (long)m_position; emit positionChanged( emitPos ); - if(mediaPlayerState->isPlaying) + if( mediaPlayerState->isPlaying ) { // needs to be stopped the media is stopped - QTimer::singleShot( 1000, this, SLOT( position() ) ); -// qDebug("POSITION : %d", m_position); + QTimer::singleShot( 1000, this, SLOT( position() ) ); + } + // qDebug("POSITION : %d", m_position); return m_position; @@ -186,3 +192,44 @@ long XineControl::position() { void XineControl::setFullscreen( bool isSet ) { - libXine->showVideoFullScreen( isSet); + libXine->showVideoFullScreen( isSet ); +} + + +QString XineControl::getMetaInfo() { + + QString returnString; + + if ( !libXine->metaInfo( 0 ).isEmpty() ) { + returnString += tr( " Titel: " + 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 ) ); + } + + if ( !libXine->metaInfo( 4 ).isEmpty() ) { + 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(); + + if ( errorCode == 1 ) { + return tr( "No input plugin found for this media type" ); + } else { + return tr( "Some other error" ); + } } @@ -194,3 +241,3 @@ void XineControl::setFullscreen( bool isSet ) { void XineControl::seekTo( long second ) { - libXine->play( m_fileName , 0, (int)second ); + libXine->seekTo( (int)second ); } @@ -198,3 +245,3 @@ void XineControl::seekTo( long second ) { void XineControl::videoResized ( const QSize &s ) { - libXine-> resize ( s ); + libXine->resize( s ); } |