summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-12 19:24:08 (UTC)
committer llornkcor <llornkcor>2002-12-12 19:24:08 (UTC)
commitfa60d33a4c40ed6fc0bfb87a5366b276d65b98d8 (patch) (side-by-side diff)
tree96ea1742473b7526089f5f785a2ccff6373f13a4
parent4789fc5908e0f6e5f828e1069b3fa5c7dad1412c (diff)
downloadopie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.zip
opie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.tar.gz
opie-fa60d33a4c40ed6fc0bfb87a5366b276d65b98d8.tar.bz2
moved readM3u and readPls to one function. fixed pls. more to come
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp139
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h5
3 files changed, 73 insertions, 74 deletions
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp
index 235d973..841d950 100644
--- a/noncore/multimedia/opieplayer2/om3u.cpp
+++ b/noncore/multimedia/opieplayer2/om3u.cpp
@@ -85,25 +85,26 @@ void Om3u::readM3u() {
// qDebug(name);
}
}
}
}
void Om3u::readPls() { //it's a pls file
QTextStream t( &f );
QString s;
while ( !t.atEnd() ) {
s = t.readLine();
if( s.left(4) == "File" ) {
- s = s.right( s.length() - 6 );
+ s = s.right( s.length() - s.find("=",0,true)-1 );
+ s = s.stripWhiteSpace();
s.replace( QRegExp( "%20" )," ");
// qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
QFileInfo f( s );
QString name = f.baseName();
if( name.left( 4 ) == "http" ) {
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index a65495e..6e2457f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -98,25 +98,25 @@ PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* par
Config cfg( "OpiePlayer" );
bool b= cfg.readBoolEntry("FullScreen", 0);
mediaPlayerState.setFullscreen( b );
pmView->setItemChecked( -16, b );
(void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
d->selectedFiles, SLOT(moveSelectedUp() ) );
(void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
d->selectedFiles, SLOT(removeSelected() ) );
(void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
d->selectedFiles, SLOT(moveSelectedDown() ) );
- QVBox *stretch2 = new QVBox( vbox1 );
+ // QVBox *stretch2 = new QVBox( vbox1 );
connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
SLOT( deletePlaylist() ) );
connect( pmView, SIGNAL( activated( int ) ),
this, SLOT( pmViewActivated( int ) ) );
connect( skinsMenu, SIGNAL( activated( int ) ) ,
this, SLOT( skinsMenuActivated( int ) ) );
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 ) ),
this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
@@ -356,42 +356,44 @@ void PlayListWidget::addAllVideoToList() {
}
}
*/
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument( const QString& fileref ) {
// qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref );
fromSetDocument = TRUE;
- if ( fileref.isNull() ) {
+ QFileInfo fileInfo(fileref);
+
+ if ( !fileInfo.exists() ) {
QMessageBox::warning( this, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
clearList();
- if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
- readm3u( fileref );
- } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) {
- readm3u( DocLnk( fileref).file() );
- } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
- readPls( fileref );
- } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) {
- readPls( DocLnk( fileref).file() );
+ QString extension = fileInfo.extension(false);
+
+ if( extension.find( "m3u", 0, false) != -1
+ || extension.find( "pls", 0, false) != -1 ) {
+ readListFromFile( fileref );
} else {
clearList();
- addToSelection( DocLnk( fileref ) );
+ DocLnk lnk;
+ lnk.setName( fileInfo.baseName() ); //sets name
+ lnk.setFile( fileref ); //sets file name
+ addToSelection( lnk );
writeCurrentM3u();
d->setDocumentUsed = TRUE;
mediaPlayerState.setPlaying( FALSE );
mediaPlayerState.setPlaying( TRUE );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
@@ -467,25 +469,26 @@ bool PlayListWidget::last() {
writem3u();
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name = lnk.name();
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
if( name.length()>0) {
setCaption("OpiePlayer: "+name);
// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
clearList();
- readm3u(lnk.file());
+// readm3u(lnk.file());
+ readListFromFile(lnk.file());
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::addSelected() {
assert( inFileListMode() );
QListViewItemIterator it( currentFileListView );
for ( ; it.current(); ++it )
if ( it.current()->isSelected() ) {
QString filename = it.current()->text(3);
@@ -671,139 +674,133 @@ void PlayListWidget::openFile() {
}
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
lnk.setName( filename ); //sets name
lnk.setFile( filename ); //sets file name
// lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
writeCurrentM3u();
d->selectedFiles->setSelectedItem( lnk.name());
}
- else if( filename.right( 3) == "m3u" ) {
- readm3u( filename );
-
- } else if( filename.right(3) == "pls" ) {
- readPls( filename );
+ else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
+ readListFromFile( filename );
+// readPls( filename );
} else {
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
writeCurrentM3u();
d->selectedFiles->setSelectedItem( lnk.name());
}
}
+
delete fileDlg;
}
-/*
-reads m3u and shows files/urls to playlist widget */
-void PlayListWidget::readm3u( const QString &filename ) {
- qDebug( "read m3u filename " + filename );
-
+void PlayListWidget::readListFromFile( const QString &filename ) {
+ qDebug( "read list filename " + filename );
+ QFileInfo fi(filename);
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
+ if(fi.extension(false).find("m3u",0,false) != -1 )
m3uList->readM3u();
+ else if(fi.extension(false).find("pls",0,false) != -1 )
+ m3uList->readPls();
+
DocLnk lnk;
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
-// qDebug("reading "+ s);
+ // qDebug(s);
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
lnk.setFile( s ); //sets file name
- } else {
- // if( QFileInfo( s ).exists() ) {
+ } else { //is file
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(MimeType(s).pixmap() );
-// lnk.setIcon("SoundPlayer");
} else {
- // qDebug("set link2 "+s);
lnk.setFile( s);
-// lnk.setIcon(MimeType(s).pixmap() );
-// 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();
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 ) {
+// /*
+// 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;
- }
+// 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 );
+// 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.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.setFile( s );
- }
- lnk.setType( "audio/x-mpegurl" );
+// lnk.setType( "audio/x-mpegurl" );
- lnk.writeLink();
- d->selectedFiles->addToSelection( lnk );
- }
+// lnk.writeLink();
+// d->selectedFiles->addToSelection( lnk );
+// }
- m3uList->close();
- delete m3uList;
-}
+// m3uList->close();
+// delete m3uList;
+// }
-/*
- writes current playlist to current m3u file */
+// /*
+// 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","default");
Om3u *m3uList;
m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
if( d->selectedFiles->first()) {
do {
// qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file());
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index e8bf211..cb65d5c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -85,26 +85,27 @@ public slots:
bool next();
bool prev();
void writeDefaultPlaylist( );
QString currentFileListPathName() const;
protected:
void keyReleaseEvent( QKeyEvent *e);
signals:
void skinSelected();
private:
int defaultSkinIndex;
- void readm3u(const QString &);
- void readPls(const QString &);
+/* void readm3u(const QString &); */
+/* void readPls(const QString &); */
+ void readListFromFile(const QString &);
void initializeStates();
bool inFileListMode() const;
private slots:
void populateSkinsMenu();
void skinsMenuActivated(int);
void pmViewActivated(int);
void writem3u();
void writeCurrentM3u();
void openFile();
void setDocument( const QString& fileref );