author | llornkcor <llornkcor> | 2002-06-21 01:34:05 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-21 01:34:05 (UTC) |
commit | 40d079bad7c5bce23031f7e9610b402cf88438c0 (patch) (unidiff) | |
tree | eb6e18d32754f135a0e395aa371a3a9ba842da56 | |
parent | 3f1129f79e945135828191679559da70cf4ac6fa (diff) | |
download | opie-40d079bad7c5bce23031f7e9610b402cf88438c0.zip opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.gz opie-40d079bad7c5bce23031f7e9610b402cf88438c0.tar.bz2 |
export playlist to m3u
-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 | |||
@@ -177,8 +177,9 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
177 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
179 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
180 | // pmPlayList->insertSeparator(-1); | 180 | pmPlayList->insertSeparator(-1); |
181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
182 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | ||
182 | pmPlayList->insertSeparator(-1); | 183 | pmPlayList->insertSeparator(-1); |
183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 184 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
184 | pmPlayList->insertSeparator(-1); | 185 | pmPlayList->insertSeparator(-1); |
@@ -852,15 +853,13 @@ void PlayListWidget::btnPlay(bool b) { | |||
852 | switch ( tabWidget->currentPageIndex()) { | 853 | switch ( tabWidget->currentPageIndex()) { |
853 | case 0: | 854 | case 0: |
854 | { | 855 | { |
855 | qDebug("here we are"); | 856 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
856 | if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 857 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
857 | || d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | ||
858 | QMessageBox::message("Note","You are trying to play\na malformed url."); | 858 | QMessageBox::message("Note","You are trying to play\na malformed url."); |
859 | 859 | // } else { | |
860 | } else { | ||
861 | |||
862 | mediaPlayerState->setPlaying(b); | 860 | mediaPlayerState->setPlaying(b); |
863 | } } | 861 | // } |
862 | } | ||
864 | break; | 863 | break; |
865 | case 1: | 864 | case 1: |
866 | { | 865 | { |
@@ -1269,8 +1268,36 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1269 | f.close(); | 1268 | f.close(); |
1270 | } | 1269 | } |
1271 | 1270 | ||
1272 | void PlayListWidget::writem3u(const QString &filename) { | 1271 | void PlayListWidget::writem3u() { |
1272 | |||
1273 | InputDialog *fileDlg; | ||
1274 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | ||
1275 | fileDlg->exec(); | ||
1276 | QString filename,list; | ||
1277 | if( fileDlg->result() == 1 ) { | ||
1278 | filename = fileDlg->LineEdit1->text(); | ||
1279 | qDebug(filename); | ||
1280 | int noOfFiles = 0; | ||
1281 | d->selectedFiles->first(); | ||
1282 | do { | ||
1283 | // we dont check for existance because of url's | ||
1284 | // qDebug(d->selectedFiles->current()->file()); | ||
1285 | list += d->selectedFiles->current()->file()+"\n"; | ||
1286 | noOfFiles++; | ||
1287 | } | ||
1288 | while ( d->selectedFiles->next() ); | ||
1289 | qDebug(list); | ||
1290 | if(filename.left(1) != "/") | ||
1291 | filename=QPEApplication::documentDir()+"/"+filename; | ||
1292 | if(filename.right(3) != "m3u") | ||
1293 | filename=filename+".m3u"; | ||
1273 | 1294 | ||
1295 | QFile f(filename); | ||
1296 | f.open(IO_WriteOnly); | ||
1297 | f.writeBlock(list, list.length()); | ||
1298 | f.close(); | ||
1299 | } | ||
1300 | if(fileDlg) delete fileDlg; | ||
1274 | } | 1301 | } |
1275 | 1302 | ||
1276 | void PlayListWidget::readPls(const QString &filename) { | 1303 | void PlayListWidget::readPls(const QString &filename) { |
@@ -1296,18 +1323,22 @@ void PlayListWidget::readPls(const QString &filename) { | |||
1296 | // File2=http | 1323 | // File2=http |
1297 | 1324 | ||
1298 | s=s.replace( QRegExp("\\"),"/"); | 1325 | s=s.replace( QRegExp("\\"),"/"); |
1299 | // Lview->insertLine(t.readLine(),-1); | ||
1300 | // s=t.readLine(); | ||
1301 | // s=s.right(s.length()-2); | ||
1302 | DocLnk lnk( s ); | 1326 | DocLnk lnk( s ); |
1303 | QFileInfo f(s); | 1327 | QFileInfo f(s); |
1304 | QString name = f.baseName(); | 1328 | QString name = f.baseName(); |
1329 | if(name.left(4)=="http") | ||
1330 | name = s.right( s.length() - 7); | ||
1331 | else | ||
1332 | name=s; | ||
1305 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1333 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1306 | // QFileInfo f(s); | 1334 | // QFileInfo f(s); |
1307 | // QString name = f.baseName(); | 1335 | // QString name = f.baseName(); |
1308 | // // name = name.left(name.length()-4); | 1336 | // name = name.left(name.length()-4); |
1309 | // name = name.right(name.findRev("/",0,TRUE)); | 1337 | // name = name.right(name.findRev("/",0,TRUE)); |
1310 | lnk.setName( name); | 1338 | lnk.setName( name); |
1339 | if(s.at(s.length()-4) == '.') | ||
1340 | lnk.setFile( s); | ||
1341 | else | ||
1311 | lnk.setFile( s+"/"); | 1342 | lnk.setFile( s+"/"); |
1312 | lnk.setType("audio/x-mpegurl"); | 1343 | lnk.setType("audio/x-mpegurl"); |
1313 | 1344 | ||
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: | |||
75 | void doBlank(); | 75 | void doBlank(); |
76 | void doUnblank(); | 76 | void doUnblank(); |
77 | void readm3u(const QString &); | 77 | void readm3u(const QString &); |
78 | void writem3u(const QString &); | ||
79 | void readPls(const QString &); | 78 | void readPls(const QString &); |
80 | 79 | ||
81 | 80 | ||
@@ -86,6 +85,7 @@ private: | |||
86 | void populateAudioView(); | 85 | void populateAudioView(); |
87 | void populateVideoView(); | 86 | void populateVideoView(); |
88 | private slots: | 87 | private slots: |
88 | void writem3u(); | ||
89 | void scanForAudio(); | 89 | void scanForAudio(); |
90 | void scanForVideo(); | 90 | void scanForVideo(); |
91 | void openFile(); | 91 | void openFile(); |