summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-21 01:34:05 (UTC)
committer llornkcor <llornkcor>2002-06-21 01:34:05 (UTC)
commit40d079bad7c5bce23031f7e9610b402cf88438c0 (patch) (side-by-side diff)
treeeb6e18d32754f135a0e395aa371a3a9ba842da56
parent3f1129f79e945135828191679559da70cf4ac6fa (diff)
downloadopie-40d079bad7c5bce23031f7e9610b402cf88438c0.zip
opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.gz
opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.bz2
export playlist to m3u
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp57
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h2
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
@@ -177,8 +177,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
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);
@@ -852,15 +853,13 @@ void PlayListWidget::btnPlay(bool 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:
{
@@ -1269,8 +1268,36 @@ 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) {
@@ -1296,18 +1323,22 @@ void PlayListWidget::readPls(const QString &filename) {
// 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");
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
@@ -75,7 +75,6 @@ private:
void doBlank();
void doUnblank();
void readm3u(const QString &);
- void writem3u(const QString &);
void readPls(const QString &);
@@ -86,6 +85,7 @@ private:
void populateAudioView();
void populateVideoView();
private slots:
+ void writem3u();
void scanForAudio();
void scanForVideo();
void openFile();