author | simon <simon> | 2002-12-11 00:29:22 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 00:29:22 (UTC) |
commit | 7d5782ef4fd19498a141ed68c23145dcc6128146 (patch) (side-by-side diff) | |
tree | 8cdbd360962b3fa161823fa88b43e9584b23a464 /noncore | |
parent | 6c71f5ccd9506234a317d9ff3d119613c457e769 (diff) | |
download | opie-7d5782ef4fd19498a141ed68c23145dcc6128146.zip opie-7d5782ef4fd19498a141ed68c23145dcc6128146.tar.gz opie-7d5782ef4fd19498a141ed68c23145dcc6128146.tar.bz2 |
- initialized xine in a background thread. much time is still spend in
skin loading though.
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 18 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 2 |
5 files changed, 42 insertions, 5 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 99d5de6..20fd1e2 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -1,372 +1,389 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 LJP <> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdio.h> #include <stdlib.h> #include <qimage.h> #include <qtextstream.h> #include <qpe/resource.h> #include <qfile.h> #include <qdir.h> #include <qgfx_qws.h> #include <qdirectpainter_qws.h> #include <assert.h> #include "xinevideowidget.h" #include "frame.h" #include "lib.h" typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, int width, int height,int bytes ); extern "C" { xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); int null_is_showing_video( const xine_vo_driver_t* self ); void null_set_show_video( const xine_vo_driver_t* self, int show ); int null_is_fullscreen( const xine_vo_driver_t* self ); void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); int null_is_scaling( const xine_vo_driver_t* self ); void null_set_scaling( const xine_vo_driver_t* self, int scale ); void null_set_gui_width( const xine_vo_driver_t* self, int width ); void null_set_gui_height( const xine_vo_driver_t* self, int height ); void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); void null_set_videoGamma( const xine_vo_driver_t* self , int value ); void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); } using namespace XINE; -Lib::Lib( XineVideoWidget* widget ) { +Lib::Lib( XineVideoWidget* widget ) +{ + ThreadUtil::AutoLock lock( m_initGuard ); m_initialized = false; m_video = false; m_wid = widget; printf("Lib"); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; // get the configuration // not really OO, should be an extra class, later if ( !QFile::exists(configPath) ) { QFile f(configPath); f.open(IO_WriteOnly); QTextStream ts( &f ); ts << "misc.memcpy_method:glibc\n"; f.close(); } + start(); +} + +void Lib::run() +{ initialize(); } void Lib::initialize() { m_xine = xine_new( ); QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; xine_config_load( m_xine, QFile::encodeName( configPath ) ); xine_init( m_xine ); // allocate oss for sound // and fb for framebuffer 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" ); resize ( m_wid-> size ( ) ); ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); // m_wid->repaint(); } m_queue = xine_event_new_queue (m_stream); xine_event_create_listener_thread (m_queue, xine_event_handler, this); + ThreadUtil::AutoLock lock( m_initGuard ); m_initialized = true; + + send( new ThreadUtil::ChannelMessage( InitializationMessageType ), OneWay ); } Lib::~Lib() { ThreadUtil::AutoLock lock( m_initGuard ); assert( m_initialized ); // 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; } void Lib::assertInitialized() const { ThreadUtil::AutoLock lock( m_initGuard ); if ( m_initialized ) return; qDebug( "LibXine: xine function called while not being initialized, yet! Fix the caller!" ); assert( m_initialized ); } void Lib::resize ( const QSize &s ) { if ( s. width ( ) && s. height ( ) ) { ::null_set_gui_width( m_videoOutput, s. width() ); ::null_set_gui_height( m_videoOutput, s. height() ); } } int Lib::majorVersion() { int major, minor, sub; xine_get_version ( &major, &minor, &sub ); return major; } int Lib::minorVersion() { int major, minor, sub; xine_get_version ( &major, &minor, &sub ); return minor; } int Lib::subVersion() { int major, minor, sub; xine_get_version ( &major, &minor, &sub ); return sub; } int Lib::play( const QString& fileName, int startPos, int start_time ) { assertInitialized(); QString str = fileName.stripWhiteSpace(); if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { return 0; } return xine_play( m_stream, startPos, start_time); } void Lib::stop() { assertInitialized(); qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); xine_stop( m_stream ); } void Lib::pause( bool toggle ) { assertInitialized(); xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); } int Lib::speed() const { assertInitialized(); return xine_get_param ( m_stream, XINE_PARAM_SPEED ); } void Lib::setSpeed( int speed ) { assertInitialized(); xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); } int Lib::status() const { assertInitialized(); return xine_get_status( m_stream ); } int Lib::currentPosition() const { assertInitialized(); int pos, time, length; xine_get_pos_length( m_stream, &pos, &time, &length ); return pos; } int Lib::currentTime() const { assertInitialized(); int pos, time, length; xine_get_pos_length( m_stream, &pos, &time, &length ); return time/1000; } int Lib::length() const { assertInitialized(); int pos, time, length; xine_get_pos_length( m_stream, &pos, &time, &length ); return length/1000; } bool Lib::isSeekable() const { assertInitialized(); return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); } void Lib::seekTo( int time ) { assertInitialized(); //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 ); } Frame Lib::currentFrame() const { assertInitialized(); Frame frame; return frame; }; QString Lib::metaInfo( int number) const { assertInitialized(); return xine_get_meta_info( m_stream, number ); } int Lib::error() const { assertInitialized(); return xine_get_error( m_stream ); }; void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) { assert( sendType == ThreadUtil::Channel::OneWay ); - handleXineEvent( msg->type() ); + switch ( msg->type() ) { + case XineMessageType: + handleXineEvent( static_cast<XineMessage *>( msg )->xineEvent ); + break; + case InitializationMessageType: + emit initialized(); + break; + } delete msg; } void Lib::handleXineEvent( const xine_event_t* t ) { - send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); + send( new XineMessage( t->type ), OneWay ); } void Lib::handleXineEvent( int type ) { assertInitialized(); if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { emit stopped(); } } void Lib::setShowVideo( bool video ) { assertInitialized(); m_video = video; ::null_set_show_video( m_videoOutput, video ); } bool Lib::isShowingVideo() const { assertInitialized(); return ::null_is_showing_video( m_videoOutput ); } bool Lib::hasVideo() const { assertInitialized(); return xine_get_stream_info( m_stream, 18 ); } void Lib::showVideoFullScreen( bool fullScreen ) { assertInitialized(); ::null_set_fullscreen( m_videoOutput, fullScreen ); } bool Lib::isVideoFullScreen() const { assertInitialized(); return ::null_is_fullscreen( m_videoOutput ); } void Lib::setScaling( bool scale ) { assertInitialized(); ::null_set_scaling( m_videoOutput, scale ); } void Lib::setGamma( int value ) { assertInitialized(); //qDebug( QString( "%1").arg(value) ); /* int gammaValue = ( 100 + value ); */ ::null_set_videoGamma( m_videoOutput, value ); } bool Lib::isScaling() const { assertInitialized(); return ::null_is_scaling( m_videoOutput ); } void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { ( (Lib*)user_data)->handleXineEvent( t ); } void Lib::xine_display_frame( void* user_data, uint8_t *frame, int width, int height, int bytes ) { ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); } void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { assertInitialized(); if ( !m_video ) { qWarning("not showing video now"); return; } m_wid-> setVideoFrame ( frame, width, height, bytes ); } diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 4b8dc81..34b85b9 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h @@ -1,212 +1,228 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 LJP <> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ZECKEXINELIB_H #define ZECKEXINELIB_H #include <qcstring.h> #include <qstring.h> #include <qobject.h> #include <xine.h> //#include "xine.h" #include "threadutil.h" class XineVideoWidget; namespace XINE { /** * Lib wrapps the simple interface * of libxine for easy every day use * This will become a full C++ Wrapper * It supports playing, pausing, info, * stooping, seeking. */ class Frame; - class Lib : public ThreadUtil::Channel { + class Lib : public ThreadUtil::Channel, private ThreadUtil::Thread + { Q_OBJECT public: Lib(XineVideoWidget* = 0); ~Lib(); static int majorVersion(); static int minorVersion(); static int subVersion(); void resize ( const QSize &s ); int play( const QString& fileName, int startPos = 0, int start_time = 0 ); void stop(); void pause( bool toggle ); int speed() const; /** * Set the speed of the stream, if codec supports it * XINE_SPEED_PAUSE 0 * XINE_SPEED_SLOW_4 1 * XINE_SPEED_SLOW_2 2 * XINE_SPEED_NORMAL 4 * XINE_SPEED_FAST_2 8 *XINE_SPEED_FAST_4 16 */ void setSpeed( int speed = XINE_SPEED_PAUSE ); int status() const; int currentPosition()const; //in seconds int currentTime()const; int length() const; bool isSeekable()const; /** * Whether or not to show video output */ void setShowVideo(bool video); /** * is we show video */ bool isShowingVideo() const; /** * */ void showVideoFullScreen( bool fullScreen ); /** * */ bool isVideoFullScreen() const; /** * Get the meta info (like author etc) from the stream * XINE_META_INFO_TITLE 0 * XINE_META_INFO_COMMENT 1 * XINE_META_INFO_ARTIST 2 * XINE_META_INFO_GENRE 3 * XINE_META_INFO_ALBUM 4 * XINE_META_INFO_YEAR 5 * XINE_META_INFO_VIDEOCODEC 6 * XINE_META_INFO_AUDIOCODEC 7 * XINE_META_INFO_SYSTEMLAYER 8 * XINE_META_INFO_INPUT_PLUGIN 9 */ QString metaInfo( int number ) const; /** * */ bool isScaling() const; /** * seek to a position */ void seekTo( int time ); /** * * @return is media stream has video */ bool hasVideo() const; /** * */ void setScaling( bool ); /** * Set the Gamma value for video output * @param int the value between -100 and 100, 0 is original */ void setGamma( int ); /** * test */ Frame currentFrame() const; /** * Returns the error code * XINE_ERROR_NONE 0 * XINE_ERROR_NO_INPUT_PLUGIN 1 * XINE_ERROR_NO_DEMUXER_PLUGIN 2 * XINE_ERROR_DEMUXER_FAILED 3 */ int error() const; signals: void stopped(); + void initialized(); + protected: virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); + virtual void run(); + private: void initialize(); void assertInitialized() const; + enum { XineMessageType = 1, InitializationMessageType }; + + struct XineMessage : public ThreadUtil::ChannelMessage + { + XineMessage( int _xineEvent ) : ThreadUtil::ChannelMessage( XineMessageType ), + xineEvent( _xineEvent ) + {} + + int xineEvent; + }; + mutable ThreadUtil::Mutex m_initGuard; bool m_initialized : 1; int m_bytes_per_pixel; bool m_video:1; XineVideoWidget *m_wid; xine_t *m_xine; xine_stream_t *m_stream; xine_cfg_entry_t *m_config; xine_vo_driver_t *m_videoOutput; xine_ao_driver_t* m_audioOutput; xine_event_queue_t *m_queue; void handleXineEvent( const xine_event_t* t ); void handleXineEvent( int type ); void drawFrame( uint8_t* frame, int width, int height, int bytes ); // C -> C++ bridge for the event system static void xine_event_handler( void* user_data, const xine_event_t* t); static void xine_display_frame( void* user_data, uint8_t* frame , int width, int height, int bytes ); }; }; #endif diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 5e91561..0d9a5b8 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -272,105 +272,106 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { for ( unsigned int i = 0; i < 10; i++ ) { if ( v > i ) { p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); } else { p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); } } } } void MediaPlayer::blank( bool b ) { fd=open("/dev/fb0",O_RDWR); #ifdef QT_QWS_EBX fl= open( "/dev/fl", O_RDWR ); #endif if (fd != -1) { if ( b ) { qDebug("do blanking"); #ifdef QT_QWS_EBX ioctl( fd, FBIOBLANK, 1 ); if(fl !=-1) { ioctl( fl, 2 ); ::close(fl); } #else ioctl( fd, FBIOBLANK, 3 ); #endif isBlanked = TRUE; } else { qDebug("do unblanking"); ioctl( fd, FBIOBLANK, 0); #ifdef QT_QWS_EBX if(fl != -1) { ioctl( fl, 1); ::close(fl); } #endif isBlanked = FALSE; } close( fd ); } else { qDebug("<< /dev/fb0 could not be opened >>"); } } void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts break; case Key_F11: //menu break; case Key_F12: //home qDebug("Blank here"); // mediaPlayerState->toggleBlank(); break; case Key_F13: //mail qDebug("Blank here"); // mediaPlayerState->toggleBlank(); break; } } void MediaPlayer::cleanUp() {// this happens on closing Config cfg( "OpiePlayer" ); mediaPlayerState.writeConfig( cfg ); playList.writeDefaultPlaylist( ); // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); } void MediaPlayer::recreateAudioAndVideoWidgets() { delete xineControl; delete audioUI; delete videoUI; audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); - mediaPlayerState.setBackendInitialized(); + connect( xineControl, SIGNAL( initialized() ), + &mediaPlayerState, SLOT( setBackendInitialized() ) ); } void MediaPlayer::reloadSkins() { audioUI->loadSkin(); videoUI->loadSkin(); } diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 0e81fa2..14e71d9 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -1,153 +1,154 @@ /* This file is part of the Opie Project Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> Copyright (c) 2002 L. Potter <ljp@llornkcor.com> Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qtimer.h> #include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpeapplication.h> #include "xinecontrol.h" #include "mediaplayerstate.h" XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) { libXine = new XINE::Lib( xineWidget ); connect ( videoContainerWidget, 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 ) ) ); 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() ) ); + connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); disabledSuspendScreenSaver = FALSE; } XineControl::~XineControl() { #if defined(Q_WS_QWS) && !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; qDebug("<<FILENAME: " + fileName + ">>>>"); 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; } mediaPlayerState.setPlaying( true ); MediaPlayerState::DisplayType displayType; // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); if ( !libXine->hasVideo() ) { displayType = MediaPlayerState::Audio; qDebug("HAS AUDIO"); libXine->setShowVideo( false ); hasAudioChannel = TRUE; } else { displayType = MediaPlayerState::Video; qDebug("HAS VIDEO"); libXine->setShowVideo( true ); hasVideoChannel = TRUE; } // determine if slider is shown mediaPlayerState.setIsSeekable( libXine->isSeekable() ); // which gui (video / audio) mediaPlayerState.setDisplayType( displayType ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = TRUE; // Stop the screen from blanking and power saving state QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); } #endif length(); position(); } void XineControl::nextMedia() { mediaPlayerState.setNext(); } void XineControl::setGamma( int value ) { libXine->setGamma( value ); } void XineControl::stop( bool isSet ) { if ( !isSet ) { libXine->stop(); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif } } /** * Pause playback * @isSet */ void XineControl::pause( bool isSet) { libXine->pause( isSet ); } /** * get current time in playback */ diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 69a594f..000529c 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -21,100 +21,102 @@ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. 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 <qobject.h> #include "mediaplayerstate.h" class XineControl : public QObject { Q_OBJECT public: XineControl( QWidget *videoContainerWidget, 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 * @param if pause or not */ void pause( bool ); /** * Set videos fullscreen * @param yes or no */ void setFullscreen( bool ); /** * */ long currentTime(); void seekTo( long ); // get length of media file and set it void length(); long position(); /** * Proceed to the next media file in playlist */ void nextMedia(); /** * Get as much info about the stream from xine as possible */ QString getMetaInfo(); /** * get the error code and "translate" it for the user * */ QString getErrorCode(); void videoResized ( const QSize &s ); /** * Set the gamma value of the video output * @param int value between -100 and 100, 0 is original */ void setGamma( int ); private: 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; signals: void positionChanged( long ); + + void initialized(); }; #endif |