summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h44
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.h12
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp52
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h5
7 files changed, 57 insertions, 117 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 8d3963a..1b0de5d 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,67 +1,105 @@
#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 "audiowidget.h"
#include "mediaplayerstate.h"
extern MediaPlayerState *mediaPlayerState;
-
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" );
+}
+
+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;
+ repaint( FALSE );
+}
+
+void Ticker::drawContents( QPainter *p ) {
+ 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 {
int xPos, yPos;
int color;
bool isToggle, isBig, isHeld, isDown;
};
+
+
// Layout information for the audioButtons (and if it is a toggle button or not)
MediaButton audioButtons[] = {
{ 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
{ 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
{ 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
{ 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
{ 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
{ 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
{ 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
{ 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
{ 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
};
-
static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
QWidget( parent, name, f )
{
setCaption( tr("OpiePlayer - Audio") );
Config cfg("OpiePlayer");
cfg.setGroup("AudioWidget");
QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
songInfo = new Ticker( this );
songInfo->setFocusPolicy( QWidget::NoFocus );
songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
@@ -124,49 +162,48 @@ void AudioWidget::setPosition( long i ) {
updateSlider( i, mediaPlayerState->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();
showMaximized();
} else {
killTimers();
hide();
}
}
void AudioWidget::updateSlider( long i, long 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 );
}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index eab5df4..441eb6e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -9,87 +9,57 @@
#include <qslider.h>
#include <qframe.h>
class QPixmap;
enum AudioButtons {
AudioPlay,
AudioStop,
AudioPause,
AudioNext,
AudioPrevious,
AudioVolumeUp,
AudioVolumeDown,
AudioLoop,
AudioPlayList
};
#define USE_DBLBUF
class Ticker : public QFrame {
Q_OBJECT
+
public:
- Ticker( QWidget* parent=0 ) : QFrame( parent ) {
- setFrameStyle( WinPanel | Sunken );
- setText( "No Song" );
- }
- ~Ticker() { }
- void 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();
- }
+ Ticker( QWidget* parent=0 );
+ ~Ticker();
+ void setText( const QString& text ) ;
+
protected:
- void timerEvent( QTimerEvent * ) {
- pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
-#ifndef USE_DBLBUF
- scroll( -1, 0, contentsRect() );
-#else
- repaint( FALSE );
-#endif
- }
- void drawContents( QPainter *p ) {
-#ifndef USE_DBLBUF
- for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
- p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
-#else
- // Double buffering code.
- // Looks like qvfb makes it look like it flickers but I don't think it really is
- 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 );
-#endif
- }
+ void timerEvent( QTimerEvent * );
+ void drawContents( QPainter *p );
private:
QString scrollText;
int pos, pixelLen;
};
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 );
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index da8e276..687aff6 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,32 +1,24 @@
-/****************************************************************************
-** Form implementation generated from reading ui file 'inputDialog.ui'
-**
-** Created: Sat Mar 2 07:55:03 2002
-** by: The User Interface Compiler (uic)
-**
-** WARNING! All changes made in this file will be lost!
-****************************************************************************/
#include "inputDialog.h"
#include <qpe/resource.h>
#include <opie/ofiledialog.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
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));
diff --git a/noncore/multimedia/opieplayer2/inputDialog.h b/noncore/multimedia/opieplayer2/inputDialog.h
index 3e3e36f..d4f5e12 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.h
+++ b/noncore/multimedia/opieplayer2/inputDialog.h
@@ -1,30 +1,22 @@
-/****************************************************************************
-** Form interface generated from reading ui file 'inputDialog.ui'
-**
-** Created: Sat Mar 2 07:54:46 2002
-** by: The User Interface Compiler (uic)
-**
-** WARNING! All changes made in this file will be lost!
-****************************************************************************/
+
#ifndef INPUTDIALOG_H
#define INPUTDIALOG_H
#include <qvariant.h>
#include <qdialog.h>
class QLineEdit;
-class InputDialog : public QDialog
-{
+class InputDialog : public QDialog {
Q_OBJECT
public:
InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~InputDialog();
QString inputText;
QLineEdit* LineEdit1;
protected slots:
void browse();
};
#endif // INPUTDIALOG_H
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e6d0525..87184ba 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -34,139 +34,99 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name )
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() ) );
}
MediaPlayer::~MediaPlayer() {
}
void MediaPlayer::pauseCheck( bool b ) {
// Only pause if playing
if ( b && !mediaPlayerState->playing() )
mediaPlayerState->setPaused( FALSE );
}
void MediaPlayer::play() {
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
void MediaPlayer::setPlaying( bool play ) {
if ( !play ) {
mediaPlayerState->setPaused( FALSE );
-// loopControl->stop( FALSE );
return;
}
if ( mediaPlayerState->paused() ) {
mediaPlayerState->setPaused( FALSE );
return;
}
const DocLnk *playListCurrent = playList->current();
if ( playListCurrent != NULL ) {
-// loopControl->stop( TRUE );
currentFile = playListCurrent;
}
- /*
+ audioUI->setTickerText( currentFile->file() );
- if ( currentFile == NULL ) {
- QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
- mediaPlayerState->setPlaying( FALSE );
- return;
- }
-
- if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
- QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
- mediaPlayerState->setPlaying( FALSE );
- return;
- }
-
- if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
- QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
- mediaPlayerState->setPlaying( FALSE );
- return;
- }
-
-// if ( !loopControl->init( currentFile->file() ) ) {
-// QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
-// mediaPlayerState->setPlaying( FALSE );
-// return;
-// }
-// long seconds = loopControl->totalPlaytime();
- long seconds = 120;
- QString time;
- time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
- QString tickerText;
- if( currentFile->file().left(4) == "http" )
- tickerText= tr( " File: " ) + currentFile->name();
- else
- tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
-
- QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
- if ( !fileInfo.isEmpty() )
- tickerText += ", " + fileInfo;
- audioUI->setTickerText( tickerText + "." );
-
-
- */ // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben
+ // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben
- // loopControl->play();
+ // Ob auch video 'v' : 'a'
+ // mediaPlayerState->setView( 'v' );
- // mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
+ // abspielen starten.
}
void MediaPlayer::prev() {
if ( playList->prev() )
play();
else if ( mediaPlayerState->looping() ) {
if ( playList->last() )
play();
} else
mediaPlayerState->setList();
}
void MediaPlayer::next() {
if ( playList->next() )
play();
else if ( mediaPlayerState->looping() ) {
if ( playList->first() )
play();
} else
mediaPlayerState->setList();
}
void MediaPlayer::startDecreasingVolume() {
volumeDirection = -1;
startTimer( 100 );
- // sollte volumeapplet machen
+ // da kommt demnächst osound denk ich mal
// AudioDevice::decreaseVolume();
}
void MediaPlayer::startIncreasingVolume() {
volumeDirection = +1;
startTimer( 100 );
// AudioDevice::increaseVolume();
}
void MediaPlayer::stopChangingVolume() {
killTimers();
}
void MediaPlayer::timerEvent( QTimerEvent * ) {
// if ( volumeDirection == +1 )
// AudioDevice::increaseVolume();
// else if ( volumeDirection == -1 )
// AudioDevice::decreaseVolume();
}
void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 9b5f70e..d1d30e4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,52 +1,44 @@
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/config.h>
#include <qvaluelist.h>
#include <qobject.h>
#include <qdir.h>
#include <qpe/mediaplayerplugininterface.h>
#include "mediaplayerstate.h"
-#ifdef QT_NO_COMPONENT
-// Plugins which are compiled in when no plugin architecture available
-#include "libmad/libmadpluginimpl.h"
-#include "libmpeg3/libmpeg3pluginimpl.h"
-#include "wavplugin/wavpluginimpl.h"
-#endif
-
-
//#define MediaPlayerDebug(x) qDebug x
#define MediaPlayerDebug(x)
MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
- : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
+ : QObject( parent, name ), decoder( NULL ) {
Config cfg( "OpiePlayer" );
readConfig( cfg );
}
MediaPlayerState::~MediaPlayerState() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
}
void MediaPlayerState::readConfig( Config& cfg ) {
cfg.setGroup("Options");
isFullscreen = cfg.readBoolEntry( "FullScreen" );
isScaled = cfg.readBoolEntry( "Scaling" );
isLooping = cfg.readBoolEntry( "Looping" );
isShuffled = cfg.readBoolEntry( "Shuffle" );
usePlaylist = cfg.readBoolEntry( "UsePlayList" );
usePlaylist = TRUE;
isPlaying = FALSE;
isPaused = FALSE;
curPosition = 0;
curLength = 0;
curView = 'l';
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 374e780..8a64939 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -9,50 +9,49 @@
class MediaPlayerDecoder;
class Config;
class MediaPlayerState : public QObject {
Q_OBJECT
public:
MediaPlayerState( QObject *parent, const char *name );
~MediaPlayerState();
bool isStreaming;
bool fullscreen() { return isFullscreen; }
bool scaled() { return isScaled; }
bool looping() { return isLooping; }
bool shuffled() { return isShuffled; }
bool playlist() { return usePlaylist; }
bool paused() { return isPaused; }
bool playing() { return isPlaying; }
long position() { return curPosition; }
long length() { return curLength; }
char view() { return curView; }
MediaPlayerDecoder *newDecoder( const QString& file );
MediaPlayerDecoder *curDecoder();
- MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the
- // number of audio samples if we are using the libmad plugin
+
public slots:
void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); }
void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); }
void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); }
void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); }
void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); }
void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); }
void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); }
void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); }
void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); }
void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); }
void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); }
void setPrev() { emit prev(); }
void setNext() { emit next(); }
void setList() { setPlaying( FALSE ); setView('l'); }
void setVideo() { setView('v'); }
void setAudio() { setView('a'); }
void toggleFullscreen() { setFullscreen( !isFullscreen ); }
void toggleScaled() { setScaled( !isScaled); }
void toggleLooping() { setLooping( !isLooping); }
void toggleShuffled() { setShuffled( !isShuffled); }
void togglePlaylist() { setPlaylist( !usePlaylist); }
@@ -67,34 +66,32 @@ signals:
void playlistToggled( bool );
void pausedToggled( bool );
void playingToggled( bool );
void positionChanged( long ); // When the slider is moved
void positionUpdated( long ); // When the media file progresses
void lengthChanged( long );
void viewChanged( char );
void prev();
void next();
private:
bool isFullscreen;
bool isScaled;
bool isLooping;
bool isShuffled;
bool usePlaylist;
bool isPaused;
bool isPlaying;
long curPosition;
long curLength;
char curView;
MediaPlayerDecoder *decoder;
- MediaPlayerDecoder *libmpeg3decoder;
-// MediaPlayerDecoder *libwavdecoder;
void readConfig( Config& cfg );
void writeConfig( Config& cfg ) const;
};
#endif // MEDIA_PLAYER_STATE_H