summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -33,2 +33,5 @@
+#include <stdlib.h>
+#include <stdio.h>
+
extern MediaPlayerState *mediaPlayerState;
@@ -39,66 +42,104 @@ 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() ) );
@@ -116,3 +157,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
setPlaying( mediaPlayerState->playing() );
-
+
}
@@ -121,5 +162,14 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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];
+ }
}
@@ -127,5 +177,53 @@ AudioWidget::~AudioWidget() {
-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() {
@@ -137,5 +235,5 @@ 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 );
@@ -146,3 +244,4 @@ void AudioWidget::setPosition( long i ) {
// qDebug("set position %d",i);
- updateSlider( i, mediaPlayerState->length() );
+ long length = mediaPlayerState->length();
+ updateSlider( i, length );
}
@@ -156,4 +255,5 @@ 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) ) );
@@ -163,3 +263,3 @@ void AudioWidget::setView( char view ) {
// does not stop stream when it reaches the end
- slider->show();
+ slider.show();
connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
@@ -179,3 +279,12 @@ 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 )
@@ -184,9 +293,9 @@ void AudioWidget::updateSlider( long i, long max ) {
// 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 );
}
@@ -209,8 +318,6 @@ 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] );
}
@@ -219,2 +326,11 @@ void AudioWidget::paintButton( QPainter *p, int 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;
@@ -222,9 +338,4 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
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 );
}
+ */
}
@@ -234,15 +345,14 @@ 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 ) {
@@ -250,5 +360,7 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
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;
@@ -258,3 +370,2 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
toggleButton(i);
- qDebug("button toggled2 %d",i);
}
@@ -265,3 +376,2 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
setToggleButton( i, FALSE );
- qDebug("button toggled3 %d",i);
switch (i) {
@@ -283,2 +393,3 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
+
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
@@ -304,6 +415,18 @@ 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 );
+ }
}
@@ -329,2 +452,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
case Key_Space: {
+
if(mediaPlayerState->playing()) {
@@ -340,3 +464,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
break;
- case Key_Down:
+ case Key_Down: //volume
toggleButton(6);
@@ -346,3 +470,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
break;
- case Key_Up:
+ case Key_Up: //volume
toggleButton(5);
@@ -352,3 +476,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
break;
- case Key_Right:
+ case Key_Right: //next in playlist
// toggleButton(3);
@@ -357,3 +481,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
break;
- case Key_Left:
+ case Key_Left: // previous in playlist
// 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
@@ -27,6 +27,9 @@
#include <qpixmap.h>
+#include <qbitmap.h>
#include <qstring.h>
#include <qslider.h>
+#include <qlineedit.h>
#include <qframe.h>
+#include <opie/oticker.h>
@@ -34,3 +37,2 @@ class QPixmap;
-
enum AudioButtons {
@@ -48,51 +50,3 @@ 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
@@ -103,3 +57,3 @@ public:
~AudioWidget();
- void setTickerText( const QString &text ) { songInfo->setText( text ); }
+ void setTickerText( const QString &text ) { songInfo.setText( text ); }
bool isStreaming;
@@ -128,2 +82,3 @@ protected:
void showEvent( QShowEvent *se );
+ void resizeEvent( QResizeEvent *re );
void mouseMoveEvent( QMouseEvent *event );
@@ -138,5 +93,17 @@ private:
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,9 +1 @@
-/****************************************************************************
-** 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"
@@ -21,9 +13,9 @@
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 ) );
@@ -35,4 +27,10 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
+ LineEdit1->setFocus();
+}
+/*
+ * return the current text(input)
+ */
+QString InputDialog::text() const {
+ return LineEdit1->text();
}
-
/*
@@ -40,6 +38,3 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
*/
-InputDialog::~InputDialog()
-{
- inputText= LineEdit1->text();
-
+InputDialog::~InputDialog() {
}
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,9 +1,2 @@
-/****************************************************************************
-** 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
@@ -16,4 +9,3 @@ class QLineEdit;
-class InputDialog : public QDialog
-{
+class InputDialog : public QDialog {
Q_OBJECT
@@ -23,4 +15,7 @@ public:
~InputDialog();
- QString inputText;
+ QString text()const;
+
+private:
QLineEdit* LineEdit1;
+
protected slots:
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
@@ -82,6 +82,7 @@ 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;
}
@@ -89,15 +90,16 @@ void MediaPlayer::setPlaying( bool play ) {
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;
}
@@ -105,5 +107,6 @@ void MediaPlayer::setPlaying( bool play ) {
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;
}
@@ -111,5 +114,6 @@ void MediaPlayer::setPlaying( bool play ) {
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;
}
@@ -117,5 +121,6 @@ void MediaPlayer::setPlaying( bool play ) {
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;
}
@@ -125,5 +130,5 @@ void MediaPlayer::setPlaying( bool play ) {
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;
@@ -131,3 +136,3 @@ void MediaPlayer::setPlaying( bool play ) {
if ( !fileInfo.isEmpty() )
- tickerText += ", " + fileInfo;
+ tickerText += ", " + fileInfo;
audioUI->setTickerText( tickerText + "." );
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
@@ -59,3 +59,5 @@ public slots:
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); }
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,2 +1,2 @@
-Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop
+Files: bin/opieplayer pics/opieplayer apps/Applications/opieplayer.desktop pics/opieplayer2/skins/default
Priority: optional
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
@@ -4,7 +4,10 @@ CONFIG = qt warn_on 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
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
@@ -85,2 +85,3 @@ extern MediaPlayerState *mediaPlayerState;
+QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
// class myFileSelector {
@@ -181,4 +182,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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() ) );
@@ -281,2 +280,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
+
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
@@ -302,3 +302,3 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
- 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 ) ) );
@@ -324,3 +324,2 @@ PlayListWidget::~PlayListWidget() {
writeConfig( cfg );
-
@@ -395,3 +394,3 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
- d->setDocumentUsed = FALSE;
+ d->setDocumentUsed = false;
if ( mediaPlayerState->playlist() ) {
@@ -401,3 +400,3 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) {
else
- mediaPlayerState->setPlaying( TRUE );
+ mediaPlayerState->setPlaying( true);
}
@@ -498,2 +497,3 @@ const DocLnk *PlayListWidget::current() { // this is fugly
+ qDebug("current");
@@ -608,31 +608,3 @@ 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();
}
@@ -640,18 +612,12 @@ void PlayListWidget::saveList() {
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();
}
-
}
@@ -677,3 +643,3 @@ void PlayListWidget::addSelected() {
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
- int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
@@ -740,3 +706,3 @@ void PlayListWidget::removeSelected() {
-void PlayListWidget::playIt( QListViewItem *it) {
+void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
@@ -779,3 +745,3 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
-void PlayListWidget::tabChanged(QWidget *widg) {
+void PlayListWidget::tabChanged(QWidget *) {
@@ -822,3 +788,3 @@ void PlayListWidget::tabChanged(QWidget *widg) {
void PlayListWidget::btnPlay(bool b) {
-
+ qDebug("<<<<<<<<<<<<<<<BtnPlay");
// mediaPlayerState->setPlaying(b);
@@ -827,2 +793,3 @@ void PlayListWidget::btnPlay(bool b) {
{
+ qDebug("1");
// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
@@ -830,4 +797,6 @@ void PlayListWidget::btnPlay(bool b) {
// QMessageBox::message("Note","You are trying to play\na malformed url.");
-// } else {
- mediaPlayerState->setPlaying(b);
+// } else {
+ mediaPlayerState->setPlaying(b);
+ insanityBool=FALSE;
+ qDebug("insanity");
// }
@@ -837,2 +806,3 @@ void PlayListWidget::btnPlay(bool b) {
{
+ qDebug("2");
addToSelection( audioView->currentItem() );
@@ -847,2 +817,4 @@ void PlayListWidget::btnPlay(bool b) {
{
+ qDebug("3");
+
addToSelection( videoView->currentItem() );
@@ -865,5 +837,5 @@ void PlayListWidget::deletePlaylist() {
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;
@@ -874,3 +846,3 @@ void PlayListWidget::deletePlaylist() {
-void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
+void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
{
@@ -896,3 +868,4 @@ void PlayListWidget::playSelected()
{
- btnPlay( TRUE);
+ qDebug("playSelected");
+ btnPlay( true);
// d->selectedFiles->unSelect();
@@ -900,3 +873,3 @@ void PlayListWidget::playSelected()
-void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
+void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
{
@@ -924,3 +897,3 @@ void PlayListWidget::listDelete() {
QString file;
- int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
+// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch ( tabWidget->currentPageIndex()) {
@@ -963,3 +936,3 @@ void PlayListWidget::listDelete() {
void PlayListWidget::scanForAudio() {
- qDebug("scan for audio");
+// qDebug("scan for audio");
files.detachChildren();
@@ -969,7 +942,7 @@ void PlayListWidget::scanForAudio() {
}
- 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();
@@ -980,3 +953,3 @@ void PlayListWidget::scanForVideo() {
Global::findDocuments(&vFiles, "video/*");
- videoScan = TRUE;
+ videoScan = true;
}
@@ -1008,3 +981,3 @@ void PlayListWidget::populateAudioView() {
size = QFile( dit.current()->file() ).size();
- qDebug(dit.current()->name());
+// qDebug(dit.current()->name());
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
@@ -1045,2 +1018,3 @@ void PlayListWidget::populateVideoView() {
void PlayListWidget::openFile() {
+ qDebug("<<<<<<<<<OPEN File");
QString filename, name;
@@ -1050,34 +1024,224 @@ void PlayListWidget::openFile() {
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)
@@ -1143,3 +1307,3 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
-void PlayListWidget::keyPressEvent( QKeyEvent *e)
+void PlayListWidget::keyPressEvent( QKeyEvent *)
{
@@ -1188,145 +1352 @@ void PlayListWidget::doUnblank() {
-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
@@ -28,2 +28,3 @@
+#include "om3u.h"
/* #include <qtimer.h> */
@@ -52,3 +53,3 @@ public:
bool insanityBool;
- QString setDocFileRef;
+ QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
@@ -87,3 +88,5 @@ private:
private slots:
+
void writem3u();
+ void writeCurrentM3u();
void scanForAudio();