summaryrefslogtreecommitdiff
path: root/core/multimedia
authorllornkcor <llornkcor>2002-11-03 21:45:32 (UTC)
committer llornkcor <llornkcor>2002-11-03 21:45:32 (UTC)
commitbf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (patch) (side-by-side diff)
treef2a02844f411d874e9afd703c18b6ebd70d97172 /core/multimedia
parent5ba841a12e67b326833751ea502cf054e423114d (diff)
downloadopie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.zip
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.gz
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.bz2
m3u stuff and op2 skins
Diffstat (limited to 'core/multimedia') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp326
-rw-r--r--core/multimedia/opieplayer/audiowidget.h73
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp31
-rw-r--r--core/multimedia/opieplayer/inputDialog.h17
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp51
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h4
-rw-r--r--core/multimedia/opieplayer/opie-mediaplayer.control2
-rw-r--r--core/multimedia/opieplayer/opieplayer.pro9
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp496
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
10 files changed, 564 insertions, 450 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index b96b1ef..896da91 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -31,76 +31,117 @@
#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
-
struct MediaButton {
- int xPos, yPos;
- int color;
- bool isToggle, isBig, isHeld, isDown;
+ bool isToggle, isHeld, isDown;
};
-
-// Layout information for the audioButtons (and if it is a toggle button or not)
+//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
+ { TRUE, FALSE, FALSE }, // play
+ { FALSE, FALSE, FALSE }, // stop
+ { TRUE, FALSE, FALSE }, // pause
+ { 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[11] = {
+ "play", "stop", "pause", "next", "prev", "up",
+ "down", "loop", "playlist", "forward", "back"
+};
-static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
+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 )
+ QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
{
setCaption( tr("OpiePlayer") );
+ qDebug("<<<<<audioWidget");
+
Config cfg("OpiePlayer");
cfg.setGroup("AudioWidget");
-// QGridLayout *layout = new QGridLayout( this );
-// layout->setSpacing( 2);
-// layout->setMargin( 2);
- 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");
-// animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton");
-
- 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 ) );
-// pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) );
-
- songInfo = new Ticker( this );
- songInfo->setFocusPolicy( QWidget::NoFocus );
- songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
-// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 );
-
- slider = new QSlider( Qt::Horizontal, this );
- slider->setFixedWidth( 220 );
- slider->setFixedHeight( 20 );
- slider->setMinValue( 0 );
- slider->setMaxValue( 1 );
- slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
- slider->setFocusPolicy( QWidget::NoFocus );
- slider->setGeometry( QRect( 7, 262, 220, 20 ) );
- // layout->addMultiCellWidget( slider, 4, 4, 0, 2 );
-
- connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
- connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
+ 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 < 11; 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;
+ }
+
+ 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) ) );
@@ -114,20 +155,77 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
setLooping( mediaPlayerState->fullscreen() );
setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState->playing() );
-
+
}
AudioWidget::~AudioWidget() {
- mediaPlayerState->isStreaming = FALSE;
- for ( int i = 0; i < 3; i++ )
- delete pixmaps[i];
+
+ for ( int i = 0; i < 11; i++ ) {
+ delete buttonPixUp[i];
+ delete buttonPixDown[i];
+ }
+ delete pixBg;
+ delete imgUp;
+ delete imgDn;
+ delete imgButtonMask;
+ for ( int i = 0; i < 11; i++ ) {
+ delete masks[i];
+ }
}
-static bool audioSliderBeingMoved = FALSE;
+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 < 11; 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;
}
@@ -135,16 +233,17 @@ void AudioWidget::sliderPressed() {
void AudioWidget::sliderReleased() {
audioSliderBeingMoved = FALSE;
- if ( slider->width() == 0 )
+ if ( slider.width() == 0 )
return;
- long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
+ 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() );
+ long length = mediaPlayerState->length();
+ updateSlider( i, length );
}
@@ -154,14 +253,15 @@ void AudioWidget::setLength( long max ) {
void AudioWidget::setView( char view ) {
+
if (mediaPlayerState->isStreaming) {
- if( !slider->isHidden()) slider->hide();
+ 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();
+ slider.show();
connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
}
@@ -177,18 +277,27 @@ void AudioWidget::setView( char view ) {
}
+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 ) {
+ 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 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 );
+ if ( slider.value() != val )
+ slider.setValue( val );
+ if ( slider.maxValue() != width )
+ slider.setMaxValue( width );
}
}
@@ -207,63 +316,64 @@ void AudioWidget::toggleButton( int i ) {
void AudioWidget::paintButton( QPainter *p, int i ) {
- int x = audioButtons[i].xPos;
- int y = audioButtons[i].yPos;
- int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
- int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
- p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
- p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
+ 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;
-// 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 );
}
+ */
}
void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( int i = 0; i < numButtons; i++ ) {
- int size = audioButtons[i].isBig;
- int x = audioButtons[i].xPos;
- int y = audioButtons[i].yPos;
if ( event->state() == QMouseEvent::LeftButton ) {
- // The test to see if the mouse click is inside the circular button or not
- // (compared with the radius squared to avoid a square-root of our distance)
- int radius = 32 + 13 * size;
- QPoint center = QPoint( x + radius, y + radius );
- QPoint dXY = center - event->pos();
- int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
- bool isOnButton = dist <= (radius * radius);
-// QRect r( x, y, 64 + 22*size, 64 + 22*size );
-// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
+
+ // 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);
- qDebug("button toggled1 %d",i);
switch (i) {
- case AudioVolumeUp: emit moreClicked(); return;
+ case AudioVolumeUp:
+ qDebug("more clicked");
+ emit moreClicked();
+ return;
case AudioVolumeDown: emit lessClicked(); return;
}
} else if ( !isOnButton && audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
toggleButton(i);
- qDebug("button toggled2 %d",i);
}
} else {
if ( audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
if ( !audioButtons[i].isToggle )
setToggleButton( i, FALSE );
- qDebug("button toggled3 %d",i);
switch (i) {
case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
@@ -281,6 +391,7 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
}
+
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
@@ -302,10 +413,22 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
}
-void AudioWidget::paintEvent( QPaintEvent * ) {
- QPainter p( this );
- for ( int i = 0; i < numButtons; i++ )
- paintButton( &p, i );
+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)
@@ -327,6 +450,7 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
case Key_F13: //mail
break;
case Key_Space: {
+
if(mediaPlayerState->playing()) {
// toggleButton(1);
mediaPlayerState->setPlaying(FALSE);
@@ -338,24 +462,24 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
}
}
break;
- case Key_Down:
+ case Key_Down: //volume
toggleButton(6);
emit lessClicked();
emit lessReleased();
toggleButton(6);
break;
- case Key_Up:
+ case Key_Up: //volume
toggleButton(5);
emit moreClicked();
emit moreReleased();
toggleButton(5);
break;
- case Key_Right:
+ case Key_Right: //next in playlist
// toggleButton(3);
mediaPlayerState->setNext();
// toggleButton(3);
break;
- case Key_Left:
+ case Key_Left: // previous in playlist
// toggleButton(4);
mediaPlayerState->setPrev();
// toggleButton(4);
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index b3d39bf..c686741 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -25,14 +25,16 @@
#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>
class QPixmap;
-
enum AudioButtons {
AudioPlay,
AudioStop,
@@ -46,62 +48,14 @@ enum AudioButtons {
};
-#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();
- }
-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
- }
-private:
- QString scrollText;
- int pos, pixelLen;
-};
-
+//#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 ); }
+ void setTickerText( const QString &text ) { songInfo.setText( text ); }
bool isStreaming;
public slots:
void updateSlider( long, long );
@@ -126,6 +80,7 @@ protected:
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 );
@@ -136,9 +91,21 @@ 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];
- Ticker *songInfo;
- QSlider *slider;
+ OTicker songInfo;
+ QSlider slider;
+ QLineEdit time;
+ int xoff, yoff;
+
};
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp
index da8e276..62240b2 100644
--- a/core/multimedia/opieplayer/inputDialog.cpp
+++ b/core/multimedia/opieplayer/inputDialog.cpp
@@ -1,11 +1,3 @@
-/****************************************************************************
-** 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>
@@ -19,13 +11,13 @@
#include <qwhatsthis.h>
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl )
-{
- if ( !name )
- setName( "InputDialog" );
+ : QDialog( parent, name, modal, fl ) {
+ if ( !name ) {
+ setName( "InputDialog" );
+ }
resize( 234, 115);
setMaximumSize( QSize( 240, 40));
- setCaption( tr(name ) );
+ setCaption( tr( name ) );
QPushButton *browserButton;
browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
@@ -33,15 +25,18 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
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()
-{
- inputText= LineEdit1->text();
-
+InputDialog::~InputDialog() {
}
void InputDialog::browse() {
diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h
index 3e3e36f..0f36ea4 100644
--- a/core/multimedia/opieplayer/inputDialog.h
+++ b/core/multimedia/opieplayer/inputDialog.h
@@ -1,11 +1,4 @@
-/****************************************************************************
-** 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
@@ -14,15 +7,17 @@
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;
+ QString text()const;
+
+private:
QLineEdit* LineEdit1;
+
protected slots:
void browse();
};
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 64fdc01..b0963cf 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -80,56 +80,61 @@ void MediaPlayer::play() {
void MediaPlayer::setPlaying( bool play ) {
+ qDebug("MediaPlayer setPlaying");
if ( !play ) {
- mediaPlayerState->setPaused( FALSE );
- loopControl->stop( FALSE );
- return;
+ mediaPlayerState->setPaused( FALSE );
+ loopControl->stop( FALSE );
+ return;
}
if ( mediaPlayerState->paused() ) {
- mediaPlayerState->setPaused( FALSE );
- return;
+ mediaPlayerState->setPaused( FALSE );
+ return;
}
-
+ qDebug("about to ctrash");
const DocLnk *playListCurrent = playList->current();
+
if ( playListCurrent != NULL ) {
- loopControl->stop( TRUE );
- currentFile = playListCurrent;
+ loopControl->stop( TRUE );
+ currentFile = playListCurrent;
}
if ( currentFile == NULL ) {
- QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
- mediaPlayerState->setPlaying( FALSE );
- return;
+ 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;
+ 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;
+ 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;
+ 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();
QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
QString tickerText;
if( currentFile->file().left(4) == "http" )
- tickerText= tr( " File: " ) + currentFile->name();
+ tickerText= tr( " File: " ) + currentFile->name();
else
- tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
+ tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
if ( !fileInfo.isEmpty() )
- tickerText += ", " + fileInfo;
+ tickerText += ", " + fileInfo;
audioUI->setTickerText( tickerText + "." );
loopControl->play();
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 06c5556..26185c5 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -57,7 +57,9 @@ public slots:
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 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); }
diff --git a/core/multimedia/opieplayer/opie-mediaplayer.control b/core/multimedia/opieplayer/opie-mediaplayer.control
index 3bfb911..da193c0 100644
--- a/core/multimedia/opieplayer/opie-mediaplayer.control
+++ b/core/multimedia/opieplayer/opie-mediaplayer.control
@@ -1,4 +1,4 @@
-Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop
+Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop pics/opieplayer2/skins/default
Priority: optional
Section: opie/applications
Maintainer: L.J.Potter <ljp@llornkcor.com>
diff --git a/core/multimedia/opieplayer/opieplayer.pro b/core/multimedia/opieplayer/opieplayer.pro
index e111717..6f22280 100644
--- a/core/multimedia/opieplayer/opieplayer.pro
+++ b/core/multimedia/opieplayer/opieplayer.pro
@@ -2,11 +2,14 @@ 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
+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
+ videowidget.cpp audiowidget.cpp playlistwidget.cpp \
+ mediaplayer.cpp audiodevice.cpp inputDialog.cpp om3u.cpp
TARGET = opieplayer
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 5be0d6d..6580a88 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -83,6 +83,7 @@ extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern MediaPlayerState *mediaPlayerState;
+QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
// class myFileSelector {
// };
@@ -179,8 +180,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
- new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
- pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
pmPlayList->insertSeparator(-1);
new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
@@ -279,6 +278,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
+
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
@@ -300,7 +300,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
- connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
+// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
@@ -322,7 +322,6 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
-
if ( d->current )
delete d->current;
@@ -393,13 +392,13 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
- d->setDocumentUsed = FALSE;
+ d->setDocumentUsed = false;
if ( mediaPlayerState->playlist() ) {
if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
}
else
- mediaPlayerState->setPlaying( TRUE );
+ mediaPlayerState->setPlaying( true);
}
@@ -496,6 +495,7 @@ const DocLnk *PlayListWidget::current() { // this is fugly
// }
// } else
+ qDebug("current");
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
@@ -606,54 +606,20 @@ bool PlayListWidget::last() {
void PlayListWidget::saveList() {
-
- QString filename;
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
- fileDlg->exec();
- if( fileDlg->result() == 1 ) {
- if ( d->current )
- delete d->current;
- filename = fileDlg->LineEdit1->text();//+".playlist";
-// qDebug("saving playlist "+filename+".playlist");
- Config cfg( filename +".playlist");
- writeConfig( cfg );
-
- DocLnk lnk;
-// lnk.setComment( "");
- lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
- lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
- lnk.setIcon("opieplayer/playlist2");
- lnk.setName( filename); //sets file name
-// qDebug(filename);
- if(!lnk.writeLink())
- qDebug("Writing doclink did not work");
- }
- Config config( "OpiePlayer" );
- config.writeEntry("CurrentPlaylist",filename);
- setCaption(tr("OpiePlayer: ")+filename);
- d->selectedFiles->first();
- if(fileDlg)
- delete fileDlg;
+ writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
- QString name= lnk.name();
-// qDebug("currentList is "+name);
- if( name.length()>1) {
+ QString name = lnk.name();
+// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
+
+ if( name.length()>0) {
setCaption("OpiePlayer: "+name);
-// qDebug("load list "+ name+".playlist");
+// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
- Config cfg( name+".playlist");
- readConfig(cfg);
-
+ readm3u(lnk.file());
tabWidget->setCurrentPage(0);
-
- Config config( "OpiePlayer" );
- config.writeEntry("CurrentPlaylist", name);
-// d->selectedFiles->first();
}
-
}
void PlayListWidget::setPlaylist( bool shown ) {
@@ -675,7 +641,7 @@ void PlayListWidget::addSelected() {
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
- int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
@@ -738,7 +704,7 @@ void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
-void PlayListWidget::playIt( QListViewItem *it) {
+void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
// mediaPlayerState->curPosition =0;
qDebug("playIt");
@@ -777,7 +743,7 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
}
}
-void PlayListWidget::tabChanged(QWidget *widg) {
+void PlayListWidget::tabChanged(QWidget *) {
switch ( tabWidget->currentPageIndex()) {
case 0:
@@ -820,21 +786,25 @@ void PlayListWidget::tabChanged(QWidget *widg) {
}
void PlayListWidget::btnPlay(bool b) {
-
+ qDebug("<<<<<<<<<<<<<<<BtnPlay");
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
+ qDebug("1");
// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
// QMessageBox::message("Note","You are trying to play\na malformed url.");
-// } else {
- mediaPlayerState->setPlaying(b);
+// } else {
+ mediaPlayerState->setPlaying(b);
+ insanityBool=FALSE;
+ qDebug("insanity");
// }
}
break;
case 1:
{
+ qDebug("2");
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
@@ -845,6 +815,8 @@ void PlayListWidget::btnPlay(bool b) {
break;
case 2:
{
+ qDebug("3");
+
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
@@ -863,16 +835,16 @@ void PlayListWidget::deletePlaylist() {
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
case 0: // Yes clicked,
-// QFile().remove(playLists->selected()->file());
-// QFile().remove(playLists->selected()->linkFile());
-// playLists->reread();
+ QFile().remove(playLists->selectedDocument().file());
+ QFile().remove(playLists->selectedDocument().linkFile());
+ playLists->reread();
break;
case 1: // Cancel
break;
};
}
-void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
+void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
{
switch (mouse) {
case 1:
@@ -894,11 +866,12 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint&
void PlayListWidget::playSelected()
{
- btnPlay( TRUE);
+ qDebug("playSelected");
+ btnPlay( true);
// d->selectedFiles->unSelect();
}
-void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
+void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
{
switch (mouse) {
case 1:
@@ -922,7 +895,7 @@ void PlayListWidget::listDelete() {
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
QString file;
- int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch ( tabWidget->currentPageIndex()) {
case 0:
break;
@@ -961,24 +934,24 @@ void PlayListWidget::listDelete() {
}
void PlayListWidget::scanForAudio() {
- qDebug("scan for audio");
+// qDebug("scan for audio");
files.detachChildren();
QListIterator<DocLnk> sdit( files.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
- Global::findDocuments(&files, "audio/*");
- audioScan = TRUE;
+ Global::findDocuments( &files, audioMimes);
+ audioScan = true;
}
void PlayListWidget::scanForVideo() {
- qDebug("scan for video");
+// qDebug("scan for video");
vFiles.detachChildren();
QListIterator<DocLnk> sdit( vFiles.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&vFiles, "video/*");
- videoScan = TRUE;
+ videoScan = true;
}
void PlayListWidget::populateAudioView() {
@@ -1006,7 +979,7 @@ void PlayListWidget::populateAudioView() {
size=0;
else
size = QFile( dit.current()->file() ).size();
- qDebug(dit.current()->name());
+// qDebug(dit.current()->name());
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
QString::number(size ), storage);
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
@@ -1043,43 +1016,234 @@ void PlayListWidget::populateVideoView() {
}
void PlayListWidget::openFile() {
+ qDebug("<<<<<<<<<OPEN File");
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
- filename = fileDlg->LineEdit1->text();
-// http://205.188.234.129:8030
-// http://66.28.68.70:8000
-// filename.replace(QRegExp("%20")," ");
- qDebug("Selected filename is "+filename);
- if(filename.right(3) == "m3u")
- readm3u( filename);
- else if(filename.right(3) == "pls")
- readPls( filename);
- else {
- DocLnk lnk;
-
- lnk.setName(filename); //sets file name
- if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
- filename += "/";
- lnk.setFile(filename); //sets File property
-
- lnk.setType("audio/x-mpegurl");
- lnk.setExec("opieplayer");
- lnk.setIcon("opieplayer/MPEGPlayer");
-
- if(!lnk.writeLink())
- qDebug("Writing doclink did not work");
- d->selectedFiles->addToSelection( lnk);
-// if(fileDlg2)
-// delete fileDlg2;
+ filename = fileDlg->text();
+ qDebug( "Selected filename is " + filename );
+// Om3u *m3uList;
+ DocLnk lnk;
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("PlayList");
+
+ if(filename.left(4) == "http") {
+ QString m3uFile, m3uFilePath;
+ if(filename.find(":",8,TRUE) != -1) { //found a port
+ m3uFile = filename.left( filename.find( ":",8,TRUE));
+ m3uFile = m3uFile.right( 7);
+ } else if(filename.left(4) == "http"){
+ m3uFile=filename;
+ m3uFile = m3uFile.right( m3uFile.length() - 7);
+ } else{
+ m3uFile=filename;
}
+
+// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
+ lnk.setName( filename ); //sets name
+ lnk.setFile( filename ); //sets file name
+ lnk.setIcon("opieplayer2/musicfile");
+ d->selectedFiles->addToSelection( lnk );
+ writeCurrentM3u();
+ }
+ else if( filename.right( 3) == "m3u" ) {
+ readm3u( filename );
+
+ } else if( filename.right(3) == "pls" ) {
+ readPls( filename );
+ } else {
+ d->selectedFiles->addToSelection( DocLnk(filename) );
+ writeCurrentM3u();
+ }
}
- if(fileDlg)
+
+ if( fileDlg ) {
delete fileDlg;
+ }
+}
+
+
+/*
+reads m3u and shows files/urls to playlist widget */
+void PlayListWidget::readm3u( const QString &filename ) {
+ qDebug( "read m3u filename " + filename );
+
+ Om3u *m3uList;
+ QString s, name;
+ m3uList = new Om3u( filename, IO_ReadOnly );
+ m3uList->readM3u();
+ DocLnk lnk;
+ for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
+ s = *it;
+// qDebug("reading "+ s);
+ if(s.left(4)=="http") {
+ lnk.setName( s ); //sets file name
+ lnk.setIcon("opieplayer2/musicfile");
+ if(s.right(4) != '.' || s.right(5) != '.')
+ lnk.setFile( s+"/"); //if url with no extension
+ else
+ lnk.setFile( s ); //sets file name
+
+ } else {
+ // if( QFileInfo( s ).exists() ) {
+ lnk.setName( QFileInfo(s).baseName());
+ // if(s.right(4) == '.') {//if regular file
+ if(s.left(1) != "/") {
+ // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
+ lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
+ lnk.setIcon("SoundPlayer");
+ } else {
+ // qDebug("set link2 "+s);
+ lnk.setFile( s);
+ lnk.setIcon("SoundPlayer");
+ }
+ }
+ d->selectedFiles->addToSelection( lnk );
+ }
+ Config config( "OpiePlayer" );
+ config.setGroup( "PlayList" );
+
+ config.writeEntry("CurrentPlaylist",filename);
+ config.write();
+ currentPlayList=filename;
+
+// m3uList->write();
+ m3uList->close();
+ if(m3uList) delete m3uList;
+
+ d->selectedFiles->setSelectedItem( s);
+ setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
+
+}
+
+/*
+reads pls and adds files/urls to playlist */
+void PlayListWidget::readPls( const QString &filename ) {
+
+ qDebug( "pls filename is " + filename );
+ Om3u *m3uList;
+ QString s, name;
+ m3uList = new Om3u( filename, IO_ReadOnly );
+ m3uList->readPls();
+
+ for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
+ s = *it;
+ // s.replace( QRegExp( "%20" )," " );
+ DocLnk lnk( s );
+ QFileInfo f( s );
+ QString name = f.baseName();
+
+ if( name.left( 4 ) == "http" ) {
+ name = s.right( s.length() - 7);
+ } else {
+ name = s;
+ }
+
+ name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
+
+ lnk.setName( name );
+ if( s.at( s.length() - 4) == '.') {// if this is probably a file
+ lnk.setFile( s );
+ } else { //if its a url
+ if( name.right( 1 ).find( '/' ) == -1) {
+ s += "/";
+ }
+ lnk.setFile( s );
+ }
+ lnk.setType( "audio/x-mpegurl" );
+
+ lnk.writeLink();
+ d->selectedFiles->addToSelection( lnk );
+ }
+
+ m3uList->close();
+ if(m3uList) delete m3uList;
}
+/*
+ writes current playlist to current m3u file */
+void PlayListWidget::writeCurrentM3u() {
+ qDebug("writing to current m3u");
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("PlayList");
+ QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
+
+ if( d->selectedFiles->first()) {
+ Om3u *m3uList;
+ m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
+
+ do {
+ qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
+ m3uList->add( d->selectedFiles->current()->file() );
+ }
+ while ( d->selectedFiles->next() );
+ qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
+ m3uList->write();
+ m3uList->close();
+
+ if(m3uList) delete m3uList;
+ }
+}
+
+ /*
+ writes current playlist to m3u file */
+void PlayListWidget::writem3u() {
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
+ fileDlg->exec();
+ QString name, filename, list;
+ Om3u *m3uList;
+
+ if( fileDlg->result() == 1 ) {
+ name = fileDlg->text();
+// qDebug( filename );
+
+ if( name.left( 1) != "/" ) {
+ filename = QPEApplication::documentDir() + "/" + name;
+ }
+
+ if( name.right( 3 ) != "m3u" ) {
+ filename = QPEApplication::documentDir() + "/" +name+".m3u";
+ }
+
+ if( d->selectedFiles->first()) {
+ m3uList = new Om3u(filename, IO_ReadWrite);
+
+ do {
+ m3uList->add( d->selectedFiles->current()->file());
+ }
+ while ( d->selectedFiles->next() );
+ // qDebug( list );
+ m3uList->write();
+ m3uList->close();
+ if(m3uList) delete m3uList;
+
+ if(fileDlg) delete fileDlg;
+
+ DocLnk lnk;
+ lnk.setFile( filename);
+ lnk.setIcon("opieplayer2/playlist2");
+ lnk.setName( name); //sets file name
+
+ // qDebug(filename);
+ Config config( "OpiePlayer" );
+ config.setGroup( "PlayList" );
+
+ config.writeEntry("CurrentPlaylist",filename);
+ currentPlayList=filename;
+
+ if(!lnk.writeLink()) {
+ qDebug("Writing doclink did not work");
+ }
+
+ setCaption(tr("OpiePlayer: ") + name);
+ }
+ }
+}
+
+
void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
{
switch ( e->key() ) {
@@ -1141,7 +1305,7 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
}
}
-void PlayListWidget::keyPressEvent( QKeyEvent *e)
+void PlayListWidget::keyPressEvent( QKeyEvent *)
{
// qDebug("Key press");
// switch ( e->key() ) {
@@ -1186,147 +1350,3 @@ void PlayListWidget::doUnblank() {
h <<-3;// v[1]; // -3 Force on
}
-void PlayListWidget::readm3u(const QString &filename) {
-
- qDebug("m3u filename is "+filename);
- QFile f(filename);
-
- if(f.open(IO_ReadOnly)) {
- QTextStream t(&f);
- QString s;//, first, second;
- int i=0;
- while ( !t.atEnd()) {
-// Lview->insertLine(t.readLine(),-1);
- s=t.readLine();
-
- if(s.find("#",0,TRUE) == -1) {
- if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
- if(s.left(2) == "E:" || s.left(2) == "P:") {
- s=s.right(s.length()-2);
- DocLnk lnk( s );
- QFileInfo f(s);
- QString name = f.baseName();
- name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
- lnk.setName( name);
- s=s.replace( QRegExp("\\"),"/");
- lnk.setFile( s);
- lnk.writeLink();
-// lnk.setIcon(opieplayer/MPEGPlayer);
- qDebug("add "+name);
- d->selectedFiles->addToSelection( lnk);
- } else { // is url
-
- s.replace(QRegExp("%20")," ");
- DocLnk lnk( s);
- QString name;
- if(name.left(4)=="http")
- name = s.right( s.length() - 7);
- else
- name=s;
-// name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
- lnk.setName(name);
- if(s.at(s.length()-4) == '.')
- lnk.setFile( s);
- else
- lnk.setFile( s+"/");
-// lnk.setFile( filename);
-// lnk.setComment( s+"/");
- lnk.setType("audio/x-mpegurl");
- lnk.writeLink();
-// lnk.setIcon( "opieplayer/MPEGPlayer");
-// qDebug("add "+s);
- d->selectedFiles->addToSelection( lnk);
- }
- i++;
- }
- }
- }
- }
- f.close();
-}
-
-void PlayListWidget::writem3u() {
-
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
- fileDlg->exec();
- QString filename,list;
- if( fileDlg->result() == 1 ) {
- filename = fileDlg->LineEdit1->text();
- qDebug(filename);
- int noOfFiles = 0;
- d->selectedFiles->first();
- do {
-// we dont check for existance because of url's
-// qDebug(d->selectedFiles->current()->file());
- list += d->selectedFiles->current()->file()+"\n";
- noOfFiles++;
- }
- while ( d->selectedFiles->next() );
- qDebug(list);
- if(filename.left(1) != "/")
- filename=QPEApplication::documentDir()+"/"+filename;
- if(filename.right(3) != "m3u")
- filename=filename+".m3u";
-
- QFile f(filename);
- f.open(IO_WriteOnly);
- f.writeBlock(list, list.length());
- f.close();
- }
- if(fileDlg) delete fileDlg;
-}
-
-void PlayListWidget::readPls(const QString &filename) {
-
- qDebug("pls filename is "+filename);
- QFile f(filename);
-
- if(f.open(IO_ReadOnly)) {
- QTextStream t(&f);
- QString s;//, first, second;
- int i=0;
- while ( !t.atEnd()) {
- s=t.readLine();
- if(s.left(4) == "File") {
- s=s.right(s.length() - 6);
- s.replace(QRegExp("%20")," ");
- qDebug("adding "+s+" to playlist");
-// numberofentries=2
-// File1=http
-// Title
-// Length
-// Version
-// File2=http
-
- s=s.replace( QRegExp("\\"),"/");
- DocLnk lnk( s );
- QFileInfo f(s);
- QString name = f.baseName();
- if(name.left(4)=="http")
- name = s.right( s.length() - 7);
- else
- name=s;
- name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
-// QFileInfo f(s);
-// QString name = f.baseName();
-// name = name.left(name.length()-4);
-// name = name.right(name.findRev("/",0,TRUE));
- lnk.setName( name);
- if(s.at(s.length()-4) == '.') // if this is probably a file
- lnk.setFile( s);
- else { //if its a url
- if( name.right(1).find('/') == -1)
- s+="/";
- lnk.setFile( s);
- }
- lnk.setType("audio/x-mpegurl");
-
- qDebug("DocLnk add "+name);
- d->selectedFiles->addToSelection( lnk);
- }
- }
- i++;
- }
-}
-
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 7718a8c..1be5a15 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -26,6 +26,7 @@
#include <qpe/fileselector.h>
#include <qpushbutton.h>
+#include "om3u.h"
/* #include <qtimer.h> */
@@ -50,7 +51,7 @@ public:
QLabel *libString;
bool fromSetDocument;
bool insanityBool;
- QString setDocFileRef;
+ QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
@@ -85,7 +86,9 @@ private:
void populateAudioView();
void populateVideoView();
private slots:
+
void writem3u();
+ void writeCurrentM3u();
void scanForAudio();
void scanForVideo();
void openFile();