-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 57 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 2 |
2 files changed, 45 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index eeaed33..ae25fe3 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -176,10 +176,11 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); -// pmPlayList->insertSeparator(-1); + 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() ) ); @@ -851,17 +852,15 @@ void PlayListWidget::btnPlay(bool b) { // mediaPlayerState->setPlaying(b); switch ( tabWidget->currentPageIndex()) { case 0: { - qDebug("here we are"); - if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 - || d->selectedFiles->current()->file().find("%20",0,TRUE) != -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 { - +// } else { mediaPlayerState->setPlaying(b); - } } +// } + } break; case 1: { addToSelection( audioView->currentItem() ); @@ -1268,10 +1267,38 @@ void PlayListWidget::readm3u(const QString &filename) { } f.close(); } -void PlayListWidget::writem3u(const QString &filename) { +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) { @@ -1295,20 +1322,24 @@ void PlayListWidget::readPls(const QString &filename) { // Version // File2=http s=s.replace( QRegExp("\\"),"/"); -// Lview->insertLine(t.readLine(),-1); -// s=t.readLine(); -// s=s.right(s.length()-2); 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.left(name.length()-4); // name = name.right(name.findRev("/",0,TRUE)); lnk.setName( name); + if(s.at(s.length()-4) == '.') + lnk.setFile( s); + else lnk.setFile( s+"/"); lnk.setType("audio/x-mpegurl"); qDebug("DocLnk add "+name); diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 5837ed3..7718a8c 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -74,9 +74,8 @@ private: bool audioScan, videoScan; void doBlank(); void doUnblank(); void readm3u(const QString &); - void writem3u(const QString &); void readPls(const QString &); void initializeStates(); @@ -85,8 +84,9 @@ private: PlayListWidgetPrivate *d; // Private implementation data void populateAudioView(); void populateVideoView(); private slots: + void writem3u(); void scanForAudio(); void scanForVideo(); void openFile(); void setDocument( const QString& fileref ); |