From 97ab73d99688443d02086b4f00d1de7c81faa3c7 Mon Sep 17 00:00:00 2001 From: zecke Date: Thu, 23 Sep 2004 21:38:02 +0000 Subject: -Remove bogus whitespaces -Remove stl dependency -Make switching from fullscreen video to audio work -Remove debug output --- diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 248221b..8afb318 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -130,21 +130,13 @@ void Lib::initialize() m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); - -//xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); - - -// null_display_handler( m_videoOutput, xine_display_frame, this ); - m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); - if (m_wid != 0 ) { - printf( "!0\n" ); + if (m_wid != 0 ) setWidget( m_wid ); - } - m_queue = xine_event_new_queue (m_stream); + m_queue = xine_event_new_queue (m_stream); xine_event_create_listener_thread (m_queue, xine_event_handler, this); ::null_preload_decoders( m_stream ); @@ -159,12 +151,10 @@ Lib::~Lib() { // free( m_config ); xine_close( m_stream ); - xine_event_dispose_queue( m_queue ); - xine_dispose( m_stream ); - xine_exit( m_xine ); + /* FIXME either free or delete but valgrind bitches against both */ //free( m_videoOutput ); //delete m_audioOutput; @@ -199,26 +189,18 @@ int Lib::subVersion() { int Lib::play( const QString& fileName, int startPos, int start_time ) { assert( m_initialized ); - // FIXME actually a hack imho. Should not be needed to dispose the whole stream - // but without we get wrong media length reads from libxine for the second media - //xine_dispose ( m_stream ); QString str = fileName.stripWhiteSpace(); - //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); - //m_queue = xine_event_new_queue (m_stream); - //xine_event_create_listener_thread (m_queue, xine_event_handler, this); - if ( !xine_open( m_stream, str.utf8().data() ) ) { - return 0; + if ( !xine_open( m_stream, str.utf8().data() ) ) { + return 0; } return xine_play( m_stream, startPos, start_time); } void Lib::stop() { assert( m_initialized ); - - odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; xine_stop( m_stream ); } @@ -258,12 +240,12 @@ int Lib::currentTime() const { assert( m_initialized ); int pos, time, length; - xine_get_pos_length( m_stream, &pos, &time, &length ); - if ( time > 0 ) { + pos = time = length = 0; + + if ( xine_get_pos_length( m_stream, &pos, &time, &length ) ) return time/1000; - } else { + else return 0; - } } int Lib::length() const { @@ -300,8 +282,6 @@ bool Lib::isSeekable() const { void Lib::seekTo( int time ) { assert( m_initialized ); - //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( - // since its now milliseconds we need *1000 xine_play( m_stream, 0, time*1000 ); } @@ -425,7 +405,6 @@ void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { assert( m_initialized ); if ( !m_video ) { - owarn << "not showing video now" << oendl; return; } diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index e6afbd8..b8023ca 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -5,6 +5,7 @@ /* OPIE */ #include +#include #include #include @@ -34,10 +35,6 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); - -// What is pauseCheck good for? (Simon) -// connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); - connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); @@ -154,7 +151,7 @@ void MediaPlayer::next() { mediaPlayerState.setList(); } } else { //if playing from file list, let's just stop - odebug << "<<<<<<<<<<<<<<<<>" << oendl; - } + Opie::Core::ODevice::inst()->setDisplayStatus( b ); } void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { @@ -331,11 +293,11 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { case Key_F11: //menu break; case Key_F12: //home - odebug << "Blank here" << oendl; + odebug << "Blank here" << oendl; // mediaPlayerState->toggleBlank(); break; case Key_F13: //mail - odebug << "Blank here" << oendl; + odebug << "Blank here" << oendl; // mediaPlayerState->toggleBlank(); break; } @@ -346,8 +308,6 @@ void MediaPlayer::cleanUp() {// this happens on closing mediaPlayerState.writeConfig( cfg ); playList.writeDefaultPlaylist( ); -// QPEApplication::grabKeyboard(); -// QPEApplication::ungrabKeyboard(); } void MediaPlayer::recreateAudioAndVideoWidgets() const diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 563ccf5..880b295 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -48,11 +48,10 @@ void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount buttonMask = skin.buttonMask( skinInfo, buttonCount ); buttons.clear(); - buttons.reserve( buttonCount ); for ( uint i = 0; i < buttonCount; ++i ) { Button button = setupButton( skinInfo[ i ], skin ); - buttons.push_back( button ); + buttons.append( button ); } } @@ -87,16 +86,10 @@ void MediaWidget::closeEvent( QCloseEvent * ) mediaPlayerState.setList(); } -void MediaWidget::paintEvent( QPaintEvent *pe ) +void MediaWidget::paintEvent( QPaintEvent * ) { QPainter p( this ); - if ( mediaPlayerState.isFullscreen() ) { - // Clear the background - p.setBrush( QBrush( Qt::black ) ); - return; - } - QPixmap buffer( size() ); QPainter bufferedPainter( &buffer ); bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); @@ -109,7 +102,7 @@ void MediaWidget::resizeEvent( QResizeEvent *e ) QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); - for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { + for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it ) { Button &button = *it; if ( button.mask.isNull() ) @@ -129,8 +122,8 @@ MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) return 0; int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); - for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) - if ( it->command + 1 == pixelIdx ) + for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it ) + if ( (*it).command + 1 == pixelIdx ) return &( *it ); return 0; @@ -193,15 +186,15 @@ void MediaWidget::handleCommand( Command command, bool buttonDown ) bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const { - return ( position.x() > 0 && position.y() > 0 && - position.x() < buttonMask.width() && - position.y() < buttonMask.height() && + return ( position.x() > 0 && position.y() > 0 && + position.x() < buttonMask.width() && + position.y() < buttonMask.height() && buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); } void MediaWidget::paintAllButtons( QPainter &p ) { - for ( ButtonVector::const_iterator it = buttons.begin(); + for ( ButtonVector::ConstIterator it = buttons.begin(); it != buttons.end(); ++it ) paintButton( p, *it ); } @@ -222,8 +215,8 @@ void MediaWidget::paintButton( QPainter &p, const Button &button ) void MediaWidget::setToggleButton( Command command, bool down ) { - for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) - if ( it->command == command ) { + for ( ButtonVector::Iterator it = buttons.begin(); it != buttons.end(); ++it ) + if ( (*it).command == command ) { setToggleButton( *it, down ); return; } diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 8c3a467..d885150 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -29,9 +29,6 @@ #include "mediaplayerstate.h" #include "playlistwidget.h" -#include -#include - class Skin; class MediaWidget : public QWidget @@ -54,7 +51,7 @@ public: QPixmap pixUp; QPixmap pixDown; }; - typedef std::vector