12 files changed, 23 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 8bcc567..7da2d54 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -1,420 +1,421 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qdir.h> #include "audiowidget.h" #include "mediaplayerstate.h" #include <stdlib.h> #include <stdio.h> extern MediaPlayerState *mediaPlayerState; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset +using namespace Opie::Ui; 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") ); // qDebug("<<<<<audioWidget"); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency // QString skinPath = "opieplayer/skins/" + skin; QString skinPath; skinPath = "opieplayer2/skins/" + skin; if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) skinPath = "opieplayer2/skins/default"; // qDebug("skin path " + skinPath); 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(getenv("OPIEDIR")) + "/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 < 11; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } QWidget *d = QApplication::desktop(); int width = d->width(); int height = d->height(); if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); QImage img; img = pixBg->convertToImage(); pixBg->convertFromImage( img.smoothScale( width, height)); } setBackgroundPixmap( *pixBg); songInfo.setFocusPolicy( QWidget::NoFocus ); // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); // songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); //NoFrame // songInfo.setForegroundColor(Qt::white); 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) ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); this->setFocus(); } AudioWidget::~AudioWidget() { // setPlaying( false); for ( int i = 0; i < 10; i++ ) { if(buttonPixUp[i]) delete buttonPixUp[i]; if(buttonPixDown[i]) delete buttonPixDown[i]; } if(pixBg) delete pixBg; if(imgUp) delete imgUp; if(imgDn) delete imgDn; if(imgButtonMask) delete imgButtonMask; for ( int i = 0; i < 10; i++ ) { if(masks[i]) delete masks[i]; } } 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, 10, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 30, 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); long length = mediaPlayerState->length(); updateSlider( i, length ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { if (mediaPlayerState->isStreaming) { 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 ); // show(); QPEApplication::showWidget( this ); } else { killTimers(); hide(); } } static QString timeAsString( long length ) { length /= 44100; 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 ) { this->setFocus(); time.setText( 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 ) { 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::timerEvent( QTimerEvent * ) { /* int x = audioButtons[AudioPlay].xPos; int y = audioButtons[AudioPlay].yPos; QPainter p( this ); // Optimize to only draw the little bit of the changing images which is different p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); */ /* static int frame = 0; if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { frame = frame >= 7 ? 0 : frame + 1; } */ } 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 && i == AudioVolumeUp ) // qDebug("on up"); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case AudioVolumeUp: // qDebug("more clicked"); emit moreClicked(); return; case AudioVolumeDown: // qDebug("less clicked"); 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 ); switch (i) { case AudioPlay: if( mediaPlayerState->isPaused ) { mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { mediaPlayerState->setPaused( TRUE ); return; } // case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; case AudioStop: mediaPlayerState->setPlaying(FALSE); return; // case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; case AudioPrevious: 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; } } } } diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index 96bc55c..0a7cb26 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h @@ -1,118 +1,118 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef AUDIO_WIDGET_H #define AUDIO_WIDGET_H #include <qwidget.h> #include <qpainter.h> #include <qdrawutil.h> #include <qpixmap.h> #include <qbitmap.h> #include <qstring.h> #include <qslider.h> #include <qlineedit.h> #include <qframe.h> -#include <opie/oticker.h> +#include <opie2/oticker.h> class QPixmap; enum AudioButtons { AudioPlay=0, AudioStop, AudioNext, AudioPrevious, AudioVolumeUp, AudioVolumeDown, AudioLoop, AudioPlayList, AudioForward, AudioBack }; //#define USE_DBLBUF class AudioWidget : public QWidget { Q_OBJECT public: AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); ~AudioWidget(); void setTickerText( const QString &text ) { songInfo.setText( text ); } bool isStreaming; public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); // void setPaused( bool b) { setToggleButton( AudioPause, b ); } void setLooping( bool b) { setToggleButton( AudioLoop, b ); } void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } void setPosition( long ); void setLength( long ); void setView( char ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void sliderMoved(long); void forwardClicked(); void backClicked(); void forwardReleased(); void backReleased(); protected: void doBlank(); void doUnblank(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: void toggleButton( int ); void setToggleButton( int, bool ); void paintButton( QPainter *p, int i ); QString skin; QPixmap *pixBg; QImage *imgUp; QImage *imgDn; QImage *imgButtonMask; QBitmap *masks[11]; QPixmap *buttonPixUp[11]; QPixmap *buttonPixDown[11]; QPixmap *pixmaps[4]; - OTicker songInfo; + Opie::Ui::OTicker songInfo; QSlider slider; QLineEdit time; int xoff, yoff; }; #endif // AUDIO_WIDGET_H diff --git a/core/multimedia/opieplayer/config.in b/core/multimedia/opieplayer/config.in index dc1b79a..d25b11f 100644 --- a/core/multimedia/opieplayer/config.in +++ b/core/multimedia/opieplayer/config.in @@ -1,12 +1,12 @@ config OPIEPLAYER boolean "opie-mediaplayer (mediaplayer that plays mp3, mpeg, and wav)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIEUI2 source core/multimedia/opieplayer/libflash/config.in source core/multimedia/opieplayer/libmad/config.in source core/multimedia/opieplayer/libmpeg3/config.in source core/multimedia/opieplayer/modplug/config.in source core/multimedia/opieplayer/wavplugin/config.in source core/multimedia/opieplayer/vorbis/tremor/config.in source core/multimedia/opieplayer/vorbis/config.in diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp index 38b8f53..44a1cdd 100644 --- a/core/multimedia/opieplayer/inputDialog.cpp +++ b/core/multimedia/opieplayer/inputDialog.cpp @@ -1,59 +1,60 @@ #include "inputDialog.h" #include <qpe/resource.h> -#include <opie/ofiledialog.h> +#include <opie2/ofiledialog.h> #include <qlineedit.h> #include <qpushbutton.h> +using namespace Opie::Ui; InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) { setName( "InputDialog" ); } resize( 234, 115); setMaximumSize( QSize( 240, 40)); setCaption( tr( name ) ); QPushButton *browserButton; browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); browserButton->setGeometry( QRect( 205, 10, 22, 22)); connect( browserButton, SIGNAL(released()),this,SLOT(browse())); LineEdit1 = new QLineEdit( this, "LineEdit1" ); LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); LineEdit1->setFocus(); } /* * return the current text(input) */ QString InputDialog::text() const { return LineEdit1->text(); } /* * Destroys the object and frees any allocated resources */ InputDialog::~InputDialog() { } void InputDialog::browse() { MimeTypes types; QStringList audio, video, all; audio << "audio/*"; audio << "playlist/plain"; audio << "audio/x-mpegurl"; video << "video/*"; video << "playlist/plain"; all += audio; all += video; types.insert("All Media Files", all ); types.insert("Audio", audio ); types.insert("Video", video ); QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); LineEdit1->setText(str); } diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.cpp b/core/multimedia/opieplayer/libflash/libflashpluginimpl.cpp index af2c07e..b2a1b5d 100644 --- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.cpp +++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.cpp @@ -1,70 +1,72 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "libflashplugin.h" #include "libflashpluginimpl.h" LibFlashPluginImpl::LibFlashPluginImpl() : libflashplugin(0), ref(0) { } LibFlashPluginImpl::~LibFlashPluginImpl() { if ( libflashplugin ) delete libflashplugin; } MediaPlayerDecoder *LibFlashPluginImpl::decoder() { if ( !libflashplugin ) libflashplugin = new LibFlashPlugin; return libflashplugin; } MediaPlayerEncoder *LibFlashPluginImpl::encoder() { return NULL; } #ifndef QT_NO_COMPONENT QRESULT LibFlashPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( LibFlashPluginImpl ) } #endif diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp index 67779e8..b3e01e5 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp @@ -1,70 +1,72 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "libmadplugin.h" #include "libmadpluginimpl.h" LibMadPluginImpl::LibMadPluginImpl() : libmadplugin(0), ref(0) { } LibMadPluginImpl::~LibMadPluginImpl() { if ( libmadplugin ) delete libmadplugin; } MediaPlayerDecoder *LibMadPluginImpl::decoder() { if ( !libmadplugin ) libmadplugin = new LibMadPlugin; return libmadplugin; } MediaPlayerEncoder *LibMadPluginImpl::encoder() { return NULL; } #ifndef QT_NO_COMPONENT QRESULT LibMadPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( LibMadPluginImpl ) } #endif diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp index bf3f372..f6d34b8 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp @@ -1,70 +1,72 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "libmpeg3plugin.h" #include "libmpeg3pluginimpl.h" LibMpeg3PluginImpl::LibMpeg3PluginImpl() : libmpeg3plugin(0), ref(0) { } LibMpeg3PluginImpl::~LibMpeg3PluginImpl() { if ( libmpeg3plugin ) delete libmpeg3plugin; } MediaPlayerDecoder *LibMpeg3PluginImpl::decoder() { if ( !libmpeg3plugin ) libmpeg3plugin = new LibMpeg3Plugin; return libmpeg3plugin; } MediaPlayerEncoder *LibMpeg3PluginImpl::encoder() { return NULL; } #ifndef QT_NO_COMPONENT QRESULT LibMpeg3PluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( LibMpeg3PluginImpl ) } #endif diff --git a/core/multimedia/opieplayer/modplug/modpluginimpl.cpp b/core/multimedia/opieplayer/modplug/modpluginimpl.cpp index 6e64e76..6205779 100644 --- a/core/multimedia/opieplayer/modplug/modpluginimpl.cpp +++ b/core/multimedia/opieplayer/modplug/modpluginimpl.cpp @@ -1,60 +1,62 @@ /* This file is part of the KDE project Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "modplugin.h" #include "modpluginimpl.h" ModPluginImpl::ModPluginImpl() :m_plugin( 0 ), ref( 0 ) { } ModPluginImpl::~ModPluginImpl() { delete m_plugin; } #ifndef QT_NO_COMPONENT QRESULT ModPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( ModPluginImpl ) } #endif MediaPlayerDecoder *ModPluginImpl::decoder() { if ( !m_plugin ) m_plugin = new ModPlugin; return m_plugin; } MediaPlayerEncoder *ModPluginImpl::encoder() { return 0; } diff --git a/core/multimedia/opieplayer/opieplayer.pro b/core/multimedia/opieplayer/opieplayer.pro index 03d8a89..d7b0fb8 100644 --- a/core/multimedia/opieplayer/opieplayer.pro +++ b/core/multimedia/opieplayer/opieplayer.pro @@ -1,21 +1,21 @@ TEMPLATE = app CONFIG = qt warn_on release #release DESTDIR = $(OPIEDIR)/bin HEADERS = loopcontrol.h mediaplayerplugininterface.h \ playlistselection.h mediaplayerstate.h \ videowidget.h audiowidget.h playlistwidget.h \ mediaplayer.h audiodevice.h inputDialog.h om3u.h SOURCES = main.cpp \ loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ videowidget.cpp audiowidget.cpp playlistwidget.cpp \ mediaplayer.cpp audiodevice.cpp inputDialog.cpp om3u.cpp TARGET = opieplayer INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lpthread -lopie +LIBS += -lqpe -lpthread -lopieui2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include include ( $(OPIEDIR)/include.pro ) diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index d002c42..164458b 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp @@ -184,490 +184,492 @@ VideoWidget::~VideoWidget() { static bool videoSliderBeingMoved = FALSE; QPixmap *combineVImageWithBackground( 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 *maskVPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } void VideoWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); //int Vh = 160; //int Vw = 220; slider->setFixedWidth( w - 20 ); slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider->setBackgroundOrigin( QWidget::ParentOrigin ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setBackgroundPixmap( *pixBg ); xoff = 0;// ( imgUp->width() ) / 2; if(w>h) yoff = 0; else yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; QPoint p( xoff, yoff ); QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); for ( int i = 0; i < 7; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); } } delete pixUp; delete pixDn; } void VideoWidget::sliderPressed() { videoSliderBeingMoved = TRUE; } void VideoWidget::sliderReleased() { videoSliderBeingMoved = FALSE; if ( slider->width() == 0 ) return; long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } void VideoWidget::setPosition( long i ) { updateSlider( i, mediaPlayerState->length() ); } void VideoWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void VideoWidget::setView( char view ) { if ( view == 'v' ) { makeVisible(); } else { // Effectively blank the view next time we show it so it looks nicer scaledWidth = 0; scaledHeight = 0; hide(); } } void VideoWidget::updateSlider( long i, long max ) { // Will flicker too much if we don't do this if ( max == 0 ) return; int width = slider->width(); int val = int((double)i * width / max); if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { if ( slider->value() != val ) slider->setValue( val ); if ( slider->maxValue() != width ) slider->setMaxValue( width ); } } void VideoWidget::setToggleButton( int i, bool down ) { if ( down != videoButtons[i].isDown ) toggleButton( i ); } void VideoWidget::toggleButton( int i ) { videoButtons[i].isDown = !videoButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void VideoWidget::paintButton( QPainter *p, int i ) { if ( videoButtons[i].isDown ) { p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); } else { p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numVButtons; 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 && !videoButtons[i].isHeld ) { videoButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case VideoVolUp: emit moreClicked(); return; case VideoVolDown: emit lessClicked(); return; } } else if ( !isOnButton && videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; toggleButton(i); } } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) { setToggleButton( i, FALSE ); } switch(i) { case VideoPlay: { // qDebug("play"); if( !mediaPlayerState->playing()) { mediaPlayerState->setPlaying( true); setToggleButton( i-1, false ); setToggleButton( i, false ); return; } if( mediaPlayerState->isPaused ) { // qDebug("isPaused"); setToggleButton( i, FALSE ); mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { // qDebug("is not paused"); setToggleButton( i, TRUE ); mediaPlayerState->setPaused( TRUE ); return; } else { return; } } case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; case VideoNext: mediaPlayerState->setNext(); return; case VideoPrevious: mediaPlayerState->setPrev(); return; case VideoVolUp: emit moreReleased(); return; case VideoVolDown: emit lessReleased(); return; case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; } } } } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState->fullscreen() ) { mediaPlayerState->setFullscreen( FALSE ); makeVisible(); } mouseMoveEvent( event ); // } } void VideoWidget::makeVisible() { if ( mediaPlayerState->fullscreen() ) { setBackgroundMode( QWidget::NoBackground ); showFullScreen(); resize( qApp->desktop()->size() ); slider->hide(); } else { setBackgroundPixmap( *pixBg ); showNormal(); QPEApplication::showWidget( this ); slider->show(); } } void VideoWidget::paintEvent( QPaintEvent * pe) { QPainter p( this ); if ( mediaPlayerState->fullscreen() ) { // Clear the background p.setBrush( QBrush( Qt::black ) ); p.drawRect( rect() ); } else { 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 < numVButtons; i++ ) { paintButton( &p, i ); } QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); for ( int i = 0; i < numVButtons; i++ ) paintButton( &p, i ); } slider->repaint( TRUE ); } } void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } bool VideoWidget::playVideo() { bool result = FALSE; // qDebug("<<<<<<<<<<<<<<<< play video"); int stream = 0; int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); int dd = QPixmap::defaultDepth(); int w = height(); int h = width(); ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; if ( mediaPlayerState->fullscreen() ) { #ifdef USE_DIRECT_PAINTER QDirectPainter p(this); if ( ( qt_screen->transformOrientation() == 3 ) && ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { w = 320; h = 240; if ( mediaPlayerState->scaled() ) { // maintain aspect ratio if ( w * sh > sw * h ) w = sw * h / sh; else h = sh * w / sw; } else { w = sw; h = sh; } w--; // we can't allow libmpeg to overwrite. QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); int ox = roff.x() - height() + 2 + (height() - w) / 2; int oy = roff.y() + (width() - h) / 2; int sx = 0, sy = 0; uchar* fp = p.frameBuffer() + p.lineStep() * oy; fp += dd * ox / 8; uchar **jt = new uchar*[h]; for ( int i = h; i; i-- ) { jt[h - i] = fp; fp += p.lineStep(); } result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; delete [] jt; } else { #endif QPainter p(this); w = 320; h = 240; if ( mediaPlayerState->scaled() ) { // maintain aspect ratio if ( w * sh > sw * h ) w = sw * h / sh; else h = sh * w / sw; } else { w = sw; h = sh; } int bytes = ( dd == 16 ) ? 2 : 4; QImage tempFrame( w, h, bytes << 3 ); result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; if ( result && mediaPlayerState->fullscreen() ) { int rw = h, rh = w; QImage rotatedFrame( rw, rh, bytes << 3 ); ushort* in = (ushort*)tempFrame.bits(); ushort* out = (ushort*)rotatedFrame.bits(); int spl = rotatedFrame.bytesPerLine() / bytes; for (int x=0; x<h; x++) { if ( bytes == 2 ) { ushort* lout = out++ + (w - 1)*spl; for (int y=0; y<w; y++) { *lout=*in++; lout-=spl; } } else { - ulong* lout = ((ulong *)out)++ + (w - 1)*spl; + ulong* _out = (ulong *)out; + ulong* lout = _out++ + (w - 1)*spl; for (int y=0; y<w; y++) { - *lout=*((ulong*)in)++; + ulong *_in = (ulong*)in; + *lout=*_in++; lout-=spl; } } } p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); } #ifdef USE_DIRECT_PAINTER } #endif } else { w = 220; h = 160; // maintain aspect ratio if ( w * sh > sw * h ) w = sw * h / sh; else h = sh * w / sw; result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; QPainter p( this ); int deskW = qApp->desktop()->width(); // Image changed size, therefore need to blank the possibly unpainted regions first if ( scaledWidth != w || scaledHeight != h ) { p.setBrush( QBrush( Qt::black ) ); p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); } scaledWidth = w; scaledHeight = h; if ( result ) { p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); } } return result; } void VideoWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; case Key_F9: //activity break; case Key_F10: //contacts // hide(); break; case Key_F11: //menu break; case Key_F12: //home break; case Key_F13: //mail break; case Key_Space: { if(mediaPlayerState->playing()) { mediaPlayerState->setPlaying(FALSE); } else { mediaPlayerState->setPlaying(TRUE); } } 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: mediaPlayerState->setNext(); break; case Key_Left: mediaPlayerState->setPrev(); break; case Key_Escape: break; }; } diff --git a/core/multimedia/opieplayer/vorbis/libtremorpluginimpl.cpp b/core/multimedia/opieplayer/vorbis/libtremorpluginimpl.cpp index 440747a..0c7b1ea 100644 --- a/core/multimedia/opieplayer/vorbis/libtremorpluginimpl.cpp +++ b/core/multimedia/opieplayer/vorbis/libtremorpluginimpl.cpp @@ -1,71 +1,73 @@ /**************************************************************************** * libtremorpluginimpl.cpp * * Copyright (C) 2002 Latchesar Ionkov <lucho@ionkov.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ****************************************************************************/ #include "libtremorplugin.h" #include "libtremorpluginimpl.h" LibTremorPluginImpl::LibTremorPluginImpl() : libtremorplugin(0), ref(0) { } LibTremorPluginImpl::~LibTremorPluginImpl() { if ( libtremorplugin ) delete libtremorplugin; } MediaPlayerDecoder *LibTremorPluginImpl::decoder() { if ( !libtremorplugin ) libtremorplugin = new LibTremorPlugin; return libtremorplugin; } MediaPlayerEncoder *LibTremorPluginImpl::encoder() { return NULL; } #ifndef QT_NO_COMPONENT QRESULT LibTremorPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( LibTremorPluginImpl ) } #endif diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp index c232d7b..4280880 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp @@ -1,69 +1,71 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "wavplugin.h" #include "wavpluginimpl.h" WavPluginImpl::WavPluginImpl() : libmadplugin(0), ref(0) { } WavPluginImpl::~WavPluginImpl() { if ( libmadplugin ) delete libmadplugin; } MediaPlayerDecoder *WavPluginImpl::decoder() { if ( !libmadplugin ) libmadplugin = new WavPlugin; return libmadplugin; } MediaPlayerEncoder *WavPluginImpl::encoder() { return NULL; } #ifndef QT_NO_COMPONENT QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) *iface = this, (*iface)->addRef(); + else + return QS_FALSE; return QS_OK; } Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( WavPluginImpl ) } #endif |