summaryrefslogtreecommitdiff
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
parent5ba841a12e67b326833751ea502cf054e423114d (diff)
downloadopie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.zip
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.gz
opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.bz2
m3u stuff and op2 skins
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp316
-rw-r--r--core/multimedia/opieplayer/audiowidget.h73
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp27
-rw-r--r--core/multimedia/opieplayer/inputDialog.h17
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp13
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h2
-rw-r--r--core/multimedia/opieplayer/opie-mediaplayer.control2
-rw-r--r--core/multimedia/opieplayer/opieplayer.pro9
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp474
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
10 files changed, 526 insertions, 412 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
@@ -30,78 +30,119 @@
#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)
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) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
@@ -118,34 +159,92 @@ 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];
+ }
}
-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;
}
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 );
}
void AudioWidget::setLength( long max ) {
@@ -153,16 +252,17 @@ 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) ) );
}
@@ -176,20 +276,29 @@ 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 );
}
}
@@ -206,65 +315,66 @@ 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;
case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
@@ -280,8 +390,9 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
}
}
+
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
@@ -301,13 +412,25 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
mediaPlayerState->setList();
}
-void AudioWidget::paintEvent( QPaintEvent * ) {
+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)
{
switch ( e->key() ) {
@@ -326,8 +449,9 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
break;
case Key_F13: //mail
break;
case Key_Space: {
+
if(mediaPlayerState->playing()) {
// toggleButton(1);
mediaPlayerState->setPlaying(FALSE);
// toggleButton(1);
@@ -337,26 +461,26 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e)
// toggleButton(0);
}
}
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);
break;
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
@@ -24,16 +24,18 @@
#include <qwidget.h>
#include <qpainter.h>
#include <qdrawutil.h>
#include <qpixmap.h>
+#include <qbitmap.h>
#include <qstring.h>
#include <qslider.h>
+#include <qlineedit.h>
#include <qframe.h>
+#include <opie/oticker.h>
class QPixmap;
-
enum AudioButtons {
AudioPlay,
AudioStop,
AudioPause,
@@ -45,64 +47,16 @@ enum AudioButtons {
AudioPlayList
};
-#define USE_DBLBUF
-
-
-class Ticker : public QFrame {
- Q_OBJECT
-public:
- Ticker( QWidget* parent=0 ) : QFrame( parent ) {
- setFrameStyle( WinPanel | Sunken );
- setText( "No Song" );
- }
- ~Ticker() { }
- void setText( const QString& text ) {
- pos = 0; // reset it everytime the text is changed
- scrollText = text;
- pixelLen = fontMetrics().width( scrollText );
- killTimers();
- if ( pixelLen > width() )
- startTimer( 50 );
- update();
- }
-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 );
void sliderPressed( );
@@ -125,8 +79,9 @@ protected:
void doBlank();
void doUnblank();
void paintEvent( QPaintEvent *pe );
void showEvent( QShowEvent *se );
+ void resizeEvent( QResizeEvent *re );
void mouseMoveEvent( QMouseEvent *event );
void mousePressEvent( QMouseEvent *event );
void mouseReleaseEvent( QMouseEvent *event );
void timerEvent( QTimerEvent *event );
@@ -135,11 +90,23 @@ protected:
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;
+
};
#endif // AUDIO_WIDGET_H
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,12 +1,4 @@
-/****************************************************************************
-** 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>
@@ -18,12 +10,12 @@
#include <qpushbutton.h>
#include <qwhatsthis.h>
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl )
-{
- if ( !name )
+ : QDialog( parent, name, modal, fl ) {
+ if ( !name ) {
setName( "InputDialog" );
+ }
resize( 234, 115);
setMaximumSize( QSize( 240, 40));
setCaption( tr(name ) );
@@ -32,17 +24,20 @@ InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags
browserButton->setGeometry( QRect( 205, 10, 22, 22));
connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
+ LineEdit1->setFocus();
+}
+/*
+ * return the current text(input)
+ */
+QString InputDialog::text() const {
+ return LineEdit1->text();
}
-
/*
* Destroys the object and frees any allocated resources
*/
-InputDialog::~InputDialog()
-{
- 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,29 +1,24 @@
-/****************************************************************************
-** Form interface generated from reading ui file 'inputDialog.ui'
-**
-** Created: Sat Mar 2 07:54:46 2002
-** by: The User Interface Compiler (uic)
-**
-** WARNING! All changes made in this file will be lost!
-****************************************************************************/
+
#ifndef INPUTDIALOG_H
#define INPUTDIALOG_H
#include <qvariant.h>
#include <qdialog.h>
class QLineEdit;
-class InputDialog : public QDialog
-{
+class InputDialog : public QDialog {
Q_OBJECT
public:
InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~InputDialog();
- QString inputText;
+ 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
@@ -79,8 +79,9 @@ void MediaPlayer::play() {
}
void MediaPlayer::setPlaying( bool play ) {
+ qDebug("MediaPlayer setPlaying");
if ( !play ) {
mediaPlayerState->setPaused( FALSE );
loopControl->stop( FALSE );
return;
@@ -89,10 +90,11 @@ void MediaPlayer::setPlaying( bool play ) {
if ( mediaPlayerState->paused() ) {
mediaPlayerState->setPaused( FALSE );
return;
}
-
+ qDebug("about to ctrash");
const DocLnk *playListCurrent = playList->current();
+
if ( playListCurrent != NULL ) {
loopControl->stop( TRUE );
currentFile = playListCurrent;
}
@@ -102,21 +104,24 @@ void MediaPlayer::setPlaying( bool play ) {
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>" );
+ 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>" );
+ 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>" );
+ 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();
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
@@ -56,9 +56,11 @@ public slots:
void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); }
void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); }
void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); }
void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); }
+
void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); }
+
void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); }
void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); }
void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); }
void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); }
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,5 +1,5 @@
-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>
Architecture: arm
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
@@ -1,13 +1,16 @@
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
LIBS += -lqpe -lpthread -lopie
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
@@ -82,8 +82,9 @@
extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern MediaPlayerState *mediaPlayerState;
+QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
// class myFileSelector {
// };
class PlayListWidgetPrivate {
@@ -178,10 +179,8 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
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() ) );
new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
@@ -278,8 +277,9 @@ 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)) );
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
@@ -299,9 +299,9 @@ 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,9 +322,8 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
-
if ( d->current )
delete d->current;
delete d;
}
@@ -392,15 +391,15 @@ 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);
}
void PlayListWidget::clearList() {
@@ -495,8 +494,9 @@ const DocLnk *PlayListWidget::current() { // this is fugly
// }
// }
// } else
+ qDebug("current");
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
{
@@ -605,56 +605,22 @@ 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) {
+// 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 ) {
if ( shown )
@@ -674,9 +640,9 @@ 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
break;
@@ -737,9 +703,9 @@ void PlayListWidget::addSelected() {
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
-void PlayListWidget::playIt( QListViewItem *it) {
+void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
// mediaPlayerState->curPosition =0;
qDebug("playIt");
mediaPlayerState->setPlaying(FALSE);
@@ -776,9 +742,9 @@ void PlayListWidget::addToSelection( QListViewItem *it) {
tabWidget->setCurrentPage(0);
}
}
-void PlayListWidget::tabChanged(QWidget *widg) {
+void PlayListWidget::tabChanged(QWidget *) {
switch ( tabWidget->currentPageIndex()) {
case 0:
{
@@ -819,23 +785,27 @@ 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);
+ insanityBool=FALSE;
+ qDebug("insanity");
// }
}
break;
case 1:
{
+ qDebug("2");
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(1);
@@ -844,8 +814,10 @@ void PlayListWidget::btnPlay(bool b) {
}// audioView->clearSelection();
break;
case 2:
{
+ qDebug("3");
+
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
d->selectedFiles->removeSelected( );
@@ -862,18 +834,18 @@ void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(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:
break;
@@ -893,13 +865,14 @@ 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:
@@ -921,9 +894,9 @@ void PlayListWidget::listDelete() {
Config cfg( "OpiePlayer" );
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;
case 1:
@@ -960,26 +933,26 @@ 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() {
@@ -1005,9 +978,9 @@ void PlayListWidget::populateAudioView() {
if( dit.current()->file().left(4) == "http" )
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" ));
}
@@ -1042,45 +1015,236 @@ 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")," ");
+ filename = fileDlg->text();
qDebug("Selected filename is "+filename);
- if(filename.right(3) == "m3u")
+// 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")
+
+ } else if( filename.right(3) == "pls" ) {
readPls( filename);
- else {
+ } else {
+ d->selectedFiles->addToSelection( DocLnk(filename) );
+ writeCurrentM3u();
+ }
+ }
+
+ 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;
- 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
+ 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.setExec("opieplayer");
- lnk.setIcon("opieplayer/MPEGPlayer");
- if(!lnk.writeLink())
- qDebug("Writing doclink did not work");
+ lnk.writeLink();
d->selectedFiles->addToSelection( lnk);
-// if(fileDlg2)
-// delete fileDlg2;
}
+
+ m3uList->close();
+ if(m3uList) delete m3uList;
}
- if(fileDlg)
- delete fileDlg;
+
+/*
+ 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() ) {
////////////////////////////// Zaurus keys
@@ -1140,9 +1304,9 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
}
}
-void PlayListWidget::keyPressEvent( QKeyEvent *e)
+void PlayListWidget::keyPressEvent( QKeyEvent *)
{
// qDebug("Key press");
// switch ( e->key() ) {
// ////////////////////////////// Zaurus keys
@@ -1185,148 +1349,4 @@ void PlayListWidget::doUnblank() {
QCopEnvelope h("QPE/System", "setBacklight(int)");
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
@@ -25,8 +25,9 @@
#include <qtabwidget.h>
#include <qpe/fileselector.h>
#include <qpushbutton.h>
+#include "om3u.h"
/* #include <qtimer.h> */
class PlayListWidgetPrivate;
@@ -49,9 +50,9 @@ public:
QListView *audioView, *videoView, *playlistView;
QLabel *libString;
bool fromSetDocument;
bool insanityBool;
- QString setDocFileRef;
+ QString setDocFileRef, currentPlayList;
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
/* QTimer * menuTimer; */
@@ -84,9 +85,11 @@ private:
PlayListWidgetPrivate *d; // Private implementation data
void populateAudioView();
void populateVideoView();
private slots:
+
void writem3u();
+ void writeCurrentM3u();
void scanForAudio();
void scanForVideo();
void openFile();
void setDocument( const QString& fileref );