summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp67
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediadetect.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro1
4 files changed, 39 insertions, 38 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 6d867e5..bf3590b 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -60,105 +60,105 @@ Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
}
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 );
+ 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;
+ 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 ) {
-
+ 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
+ //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(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;
}
}
@@ -172,93 +172,92 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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( 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() );
+ // 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];
}
}
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 *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 );
@@ -271,61 +270,61 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
}
}
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);
+ // 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
+ // 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();
@@ -385,89 +384,88 @@ void AudioWidget::paintButton( QPainter *p, int 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 );
+ 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 ( !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 ) {
// 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: mediaPlayerState->setNext(); return;
case AudioPrevious: mediaPlayerState->setPrev(); return;
case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
@@ -501,93 +499,92 @@ void AudioWidget::showEvent( QShowEvent* ) {
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)
-{
+void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
-////////////////////////////// Zaurus keys
+ ////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
-// qDebug("Audio F9");
+ // 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);
+ // toggleButton(1);
mediaPlayerState->setPlaying(FALSE);
-// toggleButton(1);
+ // toggleButton(1);
} else {
-// toggleButton(0);
+ // toggleButton(0);
mediaPlayerState->setPlaying(TRUE);
-// toggleButton(0);
+ // toggleButton(0);
}
}
break;
case Key_Down:
-// toggleButton(6);
+ // toggleButton(6);
emit lessClicked();
emit lessReleased();
-// toggleButton(6);
+ // toggleButton(6);
break;
case Key_Up:
-// toggleButton(5);
+ // toggleButton(5);
emit moreClicked();
emit moreReleased();
-// toggleButton(5);
+ // toggleButton(5);
break;
case Key_Right:
-// toggleButton(3);
+ // toggleButton(3);
mediaPlayerState->setNext();
-// toggleButton(3);
+ // toggleButton(3);
break;
case Key_Left:
-// toggleButton(4);
+ // toggleButton(4);
mediaPlayerState->setPrev();
-// toggleButton(4);
+ // toggleButton(4);
break;
case Key_Escape: {
#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 39364ab..3a82a50 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -144,50 +144,50 @@ void Lib::resize ( const QSize &s )
::null_set_gui_height(m_videoOutput, s. height() );
}
}
QCString Lib::version() {
QCString str( xine_get_str_version() );
return str;
};
int Lib::majorVersion() {
return xine_get_major_version();
}
int Lib::minorVersion() {
return xine_get_minor_version();
};
int Lib::subVersion() {
return xine_get_sub_version();
}
int Lib::play( const QString& fileName,
int startPos,
int start_time ) {
QString str = fileName.stripWhiteSpace();
//workaround OpiePlayer bug
- if (str.right(1) == QString::fromLatin1("/") )
- str = str.mid( str.length() -1 );
+ //f (str.right(1) == QString::fromLatin1("/") )
+ // str = str.mid( str.length() -1 );
return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
startPos, start_time);
}
void Lib::stop() {
qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
xine_stop(m_xine );
}
void Lib::pause(){
xine_set_speed( m_xine, SPEED_PAUSE );
}
int Lib::speed() {
return xine_get_speed( m_xine );
}
void Lib::setSpeed( int speed ) {
xine_set_speed( m_xine, speed );
}
int Lib::status(){
return xine_get_status( m_xine );
}
int Lib::currentPosition(){
return xine_get_current_position( m_xine );
}
int Lib::currentTime() {
return xine_get_current_time( m_xine );
diff --git a/noncore/multimedia/opieplayer2/mediadetect.cpp b/noncore/multimedia/opieplayer2/mediadetect.cpp
index 5e0da88..91137db 100644
--- a/noncore/multimedia/opieplayer2/mediadetect.cpp
+++ b/noncore/multimedia/opieplayer2/mediadetect.cpp
@@ -1,40 +1,43 @@
#include <qstring.h>
#include "mediadetect.h"
MediaDetect::MediaDetect() {
}
MediaDetect::~MediaDetect() {
}
char MediaDetect::videoOrAudio( const QString& fileName ) {
if( (fileName.lower()).right(4) == ".avi" ||
(fileName.lower()).right(4) == ".mpg" ||
(fileName.lower()).right(4) == ".asf" ||
(fileName.lower()).right(4) == ".mov" ||
(fileName.lower()).right(5) == ".mpeg" ) {
qDebug("Video out taken");
return 'v';
} else if ( (fileName.lower()).right(4) == "·mp1" ||
(fileName.lower()).right(4) == ".mp3" ||
(fileName.lower()).right(4) == ".ogg" ||
(fileName.lower()).right(4) == ".wav" ) {
qDebug("AUDIO out taken");
return 'a';
+ } else if ( (fileName.lower()).left(7) == "http://" &&
+ (fileName.lower()).right(1) == "/" ) {
+ return 'a';
} else {
- return 'f';
+ return 'f';
}
}
bool MediaDetect::isStreaming( const QString& fileName ) {
// ugly
if( (fileName.lower()).left(4) == "http" ) {
return true;
} else if ( (fileName.lower()).left(3) == "ftp" ) {
return true;
} else {
return false;
}
}
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index edc4624..03540a1 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,23 +1,24 @@
TEMPLATE = app
CONFIG = qt warn_on release
+#CONFIG = qt warn_on debug
#release
DESTDIR = $(OPIEDIR)/bin
HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\
videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \
frame.h lib.h xinevideowidget.h volumecontrol.h\
alphablend.h yuv2rgb.h
SOURCES = main.cpp \
playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\
videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \
frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp\
alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S
TARGET = opieplayer2
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lpthread -lopie -lxine -lxineutils
MOC_DIR=qpeobj
OBJECTS_DIR=qpeobj
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include