author | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-01 15:36:31 (UTC) |
commit | 657eeb18141838eeb0d18351a6755d7fa686f9d9 (patch) (side-by-side diff) | |
tree | 049c19f776543aee296ce0cd3a1fde8c37ec374b | |
parent | bba0335bbea81519beafb7fec1979a0abbd8a7ea (diff) | |
download | opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.zip opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.gz opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.bz2 |
mediadetect no longer needed, also beginning of id3 etc tag info support along with some other small fixes
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.h | 32 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 67 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 14 |
8 files changed, 177 insertions, 49 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 620c71f..a6fd334 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -1,599 +1,582 @@ /* 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 ..}^=.= = ; 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 <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qwidget.h> #include <qpixmap.h> #include <qbutton.h> #include <qpainter.h> #include <qframe.h> #include <qlayout.h> #include <qdir.h> #include <stdlib.h> #include <stdio.h> #include "audiowidget.h" #include "mediaplayerstate.h" #include "playlistwidget.h" extern MediaPlayerState *mediaPlayerState; extern PlayListWidget *playList; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { setFrameStyle( WinPanel | Sunken ); - setText( "No Song" ); + //setText( "No Song" ); } Ticker::~Ticker() { } void Ticker::setText( const QString& text ) { pos = 0; // reset it everytime the text is changed scrollText = text; pixelLen = fontMetrics().width( scrollText ); killTimers(); if ( pixelLen > width() ) { startTimer( 50 ); } update(); } void Ticker::timerEvent( QTimerEvent * ) { pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; scroll( -1, 0, contentsRect() ); repaint( FALSE ); } void Ticker::drawContents( QPainter *p ) { for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); } QPixmap pm( width(), height() ); pm.fill( colorGroup().base() ); QPainter pmp( &pm ); for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); } p->drawPixmap( 0, 0, pm ); } struct MediaButton { bool isToggle, isHeld, isDown; }; //Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // stop { FALSE, FALSE, FALSE }, // next { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // volume up { FALSE, FALSE, FALSE }, // volume down { TRUE, FALSE, FALSE }, // repeat/loop { FALSE, FALSE, FALSE }, // playlist { FALSE, FALSE, FALSE }, // forward { FALSE, FALSE, FALSE } // back }; const char *skin_mask_file_names[10] = { "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; static void changeTextColor( QWidget *w ) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); for ( int i = 0; i < 10; i++ ) { QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp->width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } for ( int i = 0; i < 10; i++ ) { buttonPixUp[i] = 0l; buttonPixDown[i] = 0l; } setBackgroundPixmap( *pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); changeTextColor( &songInfo ); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( *pixBg ); time.setFocusPolicy( QWidget::NoFocus ); time.setAlignment( Qt::AlignCenter ); time.setFrame(FALSE); changeTextColor( &time ); resizeEvent( NULL ); connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { for ( int i = 0; i < 10; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; for ( int i = 0; i < 10; i++ ) { delete masks[i]; } // mediaPlayerState->setPlaying(false); } namespace { QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return new QPixmap( pix ); } QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } }; void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); xoff = ( w - imgUp->width() ) / 2; yoff = (( h - imgUp->height() ) / 2) - 10; QPoint p( xoff, yoff ); QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); for ( int i = 0; i < 10; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); } } delete pixUp; delete pixDn; } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider.width() == 0 ) return; long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); mediaPlayerState->setPosition( val ); } void AudioWidget::setPosition( long i ) { // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); updateSlider( i, mediaPlayerState->length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { // this isnt working for some reason if ( mediaPlayerState->streaming() ) { qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); if( !slider.isHidden()) { slider.hide(); } disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } else { // this stops the slider from being moved, thus // does not stop stream when it reaches the end slider.show(); connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } if ( view == 'a' ) { // startTimer( 150 ); showMaximized(); } else { killTimers(); hide(); } // qApp->processEvents(); } static QString timeAsString( long length ) { int minutes = length / 60; int seconds = length % 60; return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); } void AudioWidget::updateSlider( long i, long max ) { time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; if ( max == 0 ) { return; } // Will flicker too much if we don't do this // Scale to something reasonable int width = slider.width(); int val = int((double)i * width / max); if ( !audioSliderBeingMoved ) { if ( slider.value() != val ) { slider.setValue( val ); } if ( slider.maxValue() != width ) { slider.setMaxValue( width ); } } } void AudioWidget::setToggleButton( int i, bool down ) { qDebug("setToggleButton %d", i); if ( down != audioButtons[i].isDown ) { toggleButton( i ); } } void AudioWidget::toggleButton( int i ) { audioButtons[i].isDown = !audioButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { if ( audioButtons[i].isDown ) { p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); } else { p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } } void AudioWidget::skipFor() { skipDirection = +1; startTimer( 50 ); mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); } void AudioWidget::skipBack() { skipDirection = -1; startTimer( 50 ); mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); } void AudioWidget::stopSkip() { killTimers(); } void AudioWidget::timerEvent( QTimerEvent * ) { if ( skipDirection == +1 ) { mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); } else if ( skipDirection == -1 ) { mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case AudioVolumeUp: emit moreClicked(); return; case AudioVolumeDown: emit lessClicked(); return; case AudioForward: emit forwardClicked(); return; case AudioBack: emit backClicked(); return; } } else if ( !isOnButton && audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; toggleButton(i); } } else { if ( audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; if ( !audioButtons[i].isToggle ) { setToggleButton( i, FALSE ); } qDebug("mouseEvent %d", i); switch (i) { case AudioPlay: if( mediaPlayerState->isPaused ) { -// setToggleButton( i, FALSE ); mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { -// setToggleButton( i, TRUE ); mediaPlayerState->setPaused( TRUE ); return; - } else { - // setToggleButton( i, TRUE ); - // mediaPlayerState->setPlaying( videoButtons[i].isDown ); } case AudioStop: mediaPlayerState->setPlaying(FALSE); return; case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; case AudioVolumeUp: emit moreReleased(); return; case AudioVolumeDown: emit lessReleased(); return; case AudioPlayList: mediaPlayerState->setList(); return; case AudioForward: emit forwardReleased(); return; case AudioBack: emit backReleased(); return; } } } } } void AudioWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void AudioWidget::showEvent( QShowEvent* ) { QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); mouseMoveEvent( &event ); } void AudioWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } void AudioWidget::paintEvent( QPaintEvent * pe) { if ( !pe->erased() ) { // Combine with background and double buffer QPixmap pix( pe->rect().size() ); QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); for ( int i = 0; i < numButtons; i++ ) paintButton( &p, i ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); for ( int i = 0; i < numButtons; i++ ) paintButton( &p, i ); } } void AudioWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity hide(); // qDebug("Audio F9"); break; case Key_F10: //contacts break; case Key_F11: //menu mediaPlayerState->toggleBlank(); break; case Key_F12: //home break; case Key_F13: //mail mediaPlayerState->toggleBlank(); break; case Key_Space: { if(mediaPlayerState->playing()) { // toggleButton(1); mediaPlayerState->setPlaying(FALSE); // toggleButton(1); } else { // toggleButton(0); mediaPlayerState->setPlaying(TRUE); // toggleButton(0); } } break; case Key_Down: // toggleButton(6); emit lessClicked(); emit lessReleased(); // toggleButton(6); break; case Key_Up: // toggleButton(5); emit moreClicked(); emit moreReleased(); // toggleButton(5); break; case Key_Right: // toggleButton(3); mediaPlayerState->setNext(); // toggleButton(3); break; case Key_Left: // toggleButton(4); mediaPlayerState->setPrev(); // toggleButton(4); break; case Key_Escape: { -/* - * author pleas tell me where the i come from .-) - #if defined(QT_QWS_IPAQ) - if( mediaPlayerState->isPaused ) { - setToggleButton( i, FALSE ); - mediaPlayerState->setPaused( FALSE ); - } else if( !mediaPlayerState->isPaused ) { - setToggleButton( i, TRUE ); - mediaPlayerState->setPaused( TRUE ); - } -#endif -*/ } break; }; } diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 4021d4a..85030de 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp @@ -1,265 +1,284 @@ /* 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 <qgfx_qws.h> #include <qdirectpainter_qws.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_cfg_entry_t* conf, void* video); 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 ) { m_video = false; m_wid = widget; printf("Lib"); QCString str( getenv("HOME") ); str += "/Settings/opiexine.cf"; // get the configuration // not really OO, should be an extra class, later if ( !QFile(str).exists() ) { QFile f(str); f.open(IO_WriteOnly); QTextStream ts( &f ); ts << "misc.memcpy_method:glibc\n"; f.close(); } m_xine = xine_new( ); xine_config_load( m_xine, str.data() ); // 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_config, NULL ); //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); null_display_handler( m_videoOutput, xine_display_frame, this ); xine_init( 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(); } xine_register_event_listener( m_xine, xine_event_handler, this ); } Lib::~Lib() { // free( m_config ); xine_remove_event_listener( m_xine, xine_event_handler ); xine_exit( m_xine ); /* FIXME either free or delete but valgrind bitches against both */ //free( m_videoOutput ); //delete m_audioOutput; } 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() ); } } QCString Lib::version() { // QCString str( xine_get_str_version() ); // return str; return "test"; } int Lib::majorVersion() { xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); return m_major_version; } int Lib::minorVersion() { xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); return m_minor_version; } int Lib::subVersion() { xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version ); return m_sub_version; } int Lib::play( const QString& fileName, int startPos, int start_time ) { QString str = fileName.stripWhiteSpace(); - xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ); + if ( !xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ) ) { + return 0; + } return xine_play( m_xine, startPos, start_time); } void Lib::stop() { qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); xine_stop( m_xine ); } void Lib::pause() { xine_set_param( m_xine, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); } int Lib::speed() { return xine_get_param ( m_xine, XINE_PARAM_SPEED ); } void Lib::setSpeed( int speed ) { xine_set_param ( m_xine, XINE_PARAM_SPEED, speed ); } int Lib::status() { return xine_get_status( m_xine ); } int Lib::currentPosition() { xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); return m_pos; } int Lib::currentTime() { xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); return m_time/1000; } int Lib::length() { xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length ); return m_length/1000; } bool Lib::isSeekable() { return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE ); } +void Lib::seekTo( int time ) { +// xine_trick_mode ( m_xine, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( + xine_play( m_xine, 0, time ); +} + + Frame Lib::currentFrame() { Frame frame; return frame; }; -QString Lib::metaInfo() { - xine_get_meta_info( m_xine, 0 ); +QString Lib::metaInfo( int number) { + return xine_get_meta_info( m_xine, number ); } int Lib::error() { return xine_get_error( m_xine ); }; void Lib::handleXineEvent( xine_event_t* t ) { if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) { emit stopped(); } } void Lib::setShowVideo( bool video ) { m_video = video; ::null_set_show_video( m_videoOutput, video ); } bool Lib::isShowingVideo() { return ::null_is_showing_video( m_videoOutput ); } +bool Lib::hasVideo() { + //looks like it is not implemented yet + //return xine_get_stream_info( m_xine, XINE_STREAM_INFO_VIDEO_CHANNELS ); + // ugly hack until xine is ready, look for the width of the video + int test = xine_get_stream_info( m_xine, 2 ); + if( test > 0 ) { + // qDebug( QString(" has video: %1").arg( test ) ); + return true; + } else { + //qDebug ( "does not have video "); + return false; + } +} + void Lib::showVideoFullScreen( bool fullScreen ) { ::null_set_fullscreen( m_videoOutput, fullScreen ); } bool Lib::isVideoFullScreen() { return ::null_is_fullscreen( m_videoOutput ); } void Lib::setScaling( bool scale ) { ::null_set_scaling( m_videoOutput, scale ); } void Lib::setGamma( int value ) { //qDebug( QString( "%1").arg(value) ); ::null_set_videoGamma( m_videoOutput, value ); } bool Lib::isScaling() { return ::null_is_scaling( m_videoOutput ); } void Lib::xine_event_handler( void* user_data, 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 ) { if ( !m_video ) { qWarning("not showing video now"); return; } - -// qWarning( "called draw frame %d %d", width, height ); - m_wid-> setVideoFrame ( frame, width, height, bytes ); } diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 29adc4d..6cdd9c6 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h @@ -1,173 +1,197 @@ /* 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" 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 QObject { Q_OBJECT public: Lib(XineVideoWidget* = 0); ~Lib(); QCString version(); int majorVersion()/*const*/; int minorVersion()/*const*/; int subVersion()/*const*/; void resize ( const QSize &s ); int play( const QString& fileName, int startPos = 0, int start_time = 0 ); void stop() /*const*/; void pause()/*const*/; 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() ; + QString metaInfo( int number ); /** * */ bool isScaling(); /** + * seek to a position + */ + void seekTo( int time ); + + /** + * + * @return is media stream has video + */ + bool hasVideo(); + + /** * */ 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(); private: int m_bytes_per_pixel; int m_length, m_pos, m_time; int m_major_version, m_minor_version, m_sub_version; bool m_video:1; XineVideoWidget *m_wid; xine_t *m_xine; xine_cfg_entry_t *m_config; xine_vo_driver_t *m_videoOutput; xine_ao_driver_t* m_audioOutput; void handleXineEvent( xine_event_t* t ); 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, 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 553e3c1..8da7f73 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -1,333 +1,346 @@ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <qfileinfo.h> #include <qmainwindow.h> #include <qmessagebox.h> #include <qwidgetstack.h> #include <qfile.h> #include "mediaplayer.h" #include "playlistwidget.h" #include "audiowidget.h" #include "videowidget.h" #include "volumecontrol.h" #include "mediaplayerstate.h" // for setBacklight() #include <linux/fb.h> #include <sys/file.h> #include <sys/ioctl.h> extern AudioWidget *audioUI; extern VideoWidget *videoUI; extern PlayListWidget *playList; extern MediaPlayerState *mediaPlayerState; #define FBIOBLANK 0x4611 MediaPlayer::MediaPlayer( QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { playList->setCaption(tr("OpiePlayer: Initializating")); qApp->processEvents(); // QPEApplication::grabKeyboard(); // EVIL connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 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 ) ) ); 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() ) ); volControl = new VolumeControl; xineControl = new XineControl(); playList->setCaption(tr("OpiePlayer")); } MediaPlayer::~MediaPlayer() { delete xineControl; delete volControl; } void MediaPlayer::pauseCheck( bool b ) { if ( b && !mediaPlayerState->playing() ) { mediaPlayerState->setPaused( FALSE ); } } void MediaPlayer::play() { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { return; } if ( mediaPlayerState->paused() ) { mediaPlayerState->setPaused( FALSE ); return; } QString tickerText, time, fileName; if( playList->whichList() == 0 ) { //check for filelist const DocLnk *playListCurrent = playList->current(); if ( playListCurrent != NULL ) { currentFile = playListCurrent; } xineControl->play( currentFile->file() ); fileName = currentFile->name(); long seconds = mediaPlayerState->length();// time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); - qDebug(time); + //qDebug(time); - } else { //if playing in file list.. play in a different way + } else { + //if playing in file list.. play in a different way // random and looping settings enabled causes problems here, // since there is no selected file in the playlist, but a selected file in the file list, // so we remember and shutoff l = mediaPlayerState->looping(); - if(l) + if(l) { mediaPlayerState->setLooping( false ); + } r = mediaPlayerState->shuffled(); mediaPlayerState->setShuffled(false); fileName = playList->currentFileListPathName(); xineControl->play( fileName); - long seconds = mediaPlayerState->length();// + long seconds = mediaPlayerState->length(); time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); - qDebug(time); - if( fileName.left(4) != "http" ) + //qDebug(time); + if( fileName.left(4) != "http" ) { fileName = QFileInfo( fileName).baseName(); + } } - if( fileName.left(4) == "http" ) + + if( fileName.left(4) == "http" ) { + if ( xineControl->getMetaInfo().isEmpty() ) { tickerText= tr( " File: " ) + fileName; - else - tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time; + } else { + tickerText = xineControl->getMetaInfo(); + } + } else { + if ( xineControl->getMetaInfo().isEmpty() ) { + tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; + } else { + tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; + } + } audioUI->setTickerText( tickerText ); } void MediaPlayer::prev() { if(playList->whichList() == 0) { //if using the playlist if ( playList->prev() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->last() ) { play(); } } else { mediaPlayerState->setList(); } } } void MediaPlayer::next() { if(playList->whichList() == 0) { //if using the playlist if ( playList->next() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->first() ) { play(); } } else { mediaPlayerState->setList(); } } else { //if playing from file list, let's just stop qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); mediaPlayerState->setPlaying(false); mediaPlayerState->setView('l'); if(l) mediaPlayerState->setLooping(l); if(r) mediaPlayerState->setShuffled(r); } qApp->processEvents(); } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); volControl->decVol(2); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); volControl->incVol(2); } bool drawnOnScreenDisplay = FALSE; unsigned int onScreenDisplayVolume = 0; const int yoff = 110; void MediaPlayer::stopChangingVolume() { killTimers(); // Get rid of the on-screen display stuff drawnOnScreenDisplay = FALSE; onScreenDisplayVolume = 0; int w=0; int h=0; if( !xineControl->hasVideo()) { w = audioUI->width(); h = audioUI->height(); audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } else { w = videoUI->width(); h = videoUI->height(); videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); } } void MediaPlayer::timerEvent( QTimerEvent * ) { if ( volumeDirection == +1 ) { volControl->incVol(2); } else if ( volumeDirection == -1 ) { volControl->decVol(2); } // TODO FIXME // huh?? unsigned int v= 0; v = volControl->volume(); v = v / 10; if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { return; } int w=0; int h=0; if( !xineControl->hasVideo()) { w = audioUI->width(); h = audioUI->height(); if ( drawnOnScreenDisplay ) { if ( onScreenDisplayVolume > v ) { audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); } } drawnOnScreenDisplay = TRUE; onScreenDisplayVolume = v; QPainter p( audioUI ); p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); QFont f; f.setPixelSize( 20 ); f.setBold( TRUE ); p.setFont( f ); p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 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 ); } } } else { w = videoUI->width(); h = videoUI->height(); if ( drawnOnScreenDisplay ) { if ( onScreenDisplayVolume > v ) { videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); } } drawnOnScreenDisplay = TRUE; onScreenDisplayVolume = v; QPainter p( videoUI ); p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); QFont f; f.setPixelSize( 20 ); f.setBold( TRUE ); p.setFont( f ); p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 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); if (fd != -1) { if ( b ) { qDebug("do blanking"); ioctl( fd, FBIOBLANK, 3 ); isBlanked = TRUE; } else { qDebug("do unblanking"); ioctl( fd, FBIOBLANK, 0); 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->writeConfig( cfg ); // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); } diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h index 05be128..131db33 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.h +++ b/noncore/multimedia/opieplayer2/mediaplayer.h @@ -1,46 +1,78 @@ + /* + 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 MEDIA_PLAYER_H #define MEDIA_PLAYER_H #include <qmainwindow.h> #include <qframe.h> #include <qpe/qlibrary.h> #include <qpe/mediaplayerplugininterface.h> #include "xinecontrol.h" class DocLnk; class VolumeControl; class MediaPlayer : public QObject { Q_OBJECT public: MediaPlayer( QObject *parent, const char *name ); ~MediaPlayer(); private slots: void setPlaying( bool ); void pauseCheck( bool ); void play(); void next(); void prev(); void startIncreasingVolume(); void startDecreasingVolume(); void stopChangingVolume(); void cleanUp(); void blank( bool ); protected: void timerEvent( QTimerEvent *e ); void keyReleaseEvent( QKeyEvent *e); private: bool isBlanked, l, r; int fd; int volumeDirection; const DocLnk *currentFile; XineControl *xineControl; VolumeControl *volControl; }; #endif // MEDIA_PLAYER_H diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index 1b687a3..619d36d 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro @@ -1,24 +1,24 @@ TEMPLATE = app #CONFIG = qt warn_on release CONFIG = qt warn_on debug DESTDIR = $(OPIEDIR)/bin -HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ +HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \ videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\ alphablend.h yuv2rgb.h SOURCES = main.cpp \ - playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ + playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \ videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \ playlistwidgetgui.cpp\ alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S TARGET = opieplayer2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lpthread -lopie -lxine MOC_DIR = qpeobj OBJECTS_DIR = qpeobj #INCLUDEPATH += $(OPIEDIR)/include #DEPENDPATH += $(OPIEDIR)/include 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 @@ -1,200 +1,247 @@ /* 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" #include "videowidget.h" extern MediaPlayerState *mediaPlayerState; extern VideoWidget *videoUI; 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( 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() ) ); 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 + ">>>>"); - 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; } else { + whichGui = 'v'; + qDebug("HAS VIDEO"); libXine->setShowVideo( true ); hasVideoChannel=TRUE; } // determine if slider is shown mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); // which gui (video / audio) mediaPlayerState->setView( whichGui ); - #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)" ) << ( whichGui == 'v' ? 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) { if (isSet) { libXine->pause(); } else { libXine->play( m_fileName, 0, m_currentTime); } } /** * get current time in playback */ long XineControl::currentTime() { // todo: jede sekunde überprüfen m_currentTime = libXine->currentTime(); return m_currentTime; QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); } /** * Set the length of the media file */ void XineControl::length() { m_length = libXine->length(); mediaPlayerState->setLength( m_length ); } /** * Reports the position the xine backend is at right now * @return long the postion in seconds */ long XineControl::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); return m_position; } /** * Set videoplayback to fullscreen * @param isSet */ void XineControl::setFullscreen( bool 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" ); + } +} + /** * Seek to a position in the track * @param second the second to jump to */ void XineControl::seekTo( long second ) { - libXine->play( m_fileName , 0, (int)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 1de610b..b1300a8 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h @@ -1,106 +1,116 @@ /* 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. */ #ifndef XINECONTROL_H #define XINECONTROL_H #include "lib.h" -#include "mediadetect.h" #include <qobject.h> class XineControl : public QObject { Q_OBJECT public: XineControl( 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; - MediaDetect mdetect; long m_currentTime; long m_position; int m_length; QString m_fileName; bool disabledSuspendScreenSaver : 1; bool hasVideoChannel : 1; bool hasAudioChannel : 1; signals: void positionChanged( long ); }; #endif |