author | llornkcor <llornkcor> | 2002-11-03 21:45:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-03 21:45:32 (UTC) |
commit | bf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (patch) (unidiff) | |
tree | f2a02844f411d874e9afd703c18b6ebd70d97172 /core/multimedia/opieplayer/playlistwidget.cpp | |
parent | 5ba841a12e67b326833751ea502cf054e423114d (diff) | |
download | opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.zip opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.gz opie-bf62b8f48d08f5a5e92681e1487a5f43d5c7a231.tar.bz2 |
m3u stuff and op2 skins
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 496 |
1 files changed, 258 insertions, 238 deletions
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 | |||
@@ -84,4 +84,5 @@ extern VideoWidget *videoUI; | |||
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | ||
86 | // class myFileSelector { | 87 | // class myFileSelector { |
87 | 88 | ||
@@ -180,6 +181,4 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
180 | pmPlayList->insertSeparator(-1); | 181 | pmPlayList->insertSeparator(-1); |
181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
182 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | ||
183 | pmPlayList->insertSeparator(-1); | ||
184 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
185 | pmPlayList->insertSeparator(-1); | 184 | pmPlayList->insertSeparator(-1); |
@@ -280,4 +279,5 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
280 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 279 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
281 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 280 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
281 | |||
282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
@@ -301,5 +301,5 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
302 | 302 | ||
303 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 303 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
@@ -323,5 +323,4 @@ PlayListWidget::~PlayListWidget() { | |||
323 | Config cfg( "OpiePlayer" ); | 323 | Config cfg( "OpiePlayer" ); |
324 | writeConfig( cfg ); | 324 | writeConfig( cfg ); |
325 | |||
326 | 325 | ||
327 | if ( d->current ) | 326 | if ( d->current ) |
@@ -394,5 +393,5 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
394 | 393 | ||
395 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 394 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
396 | d->setDocumentUsed = FALSE; | 395 | d->setDocumentUsed = false; |
397 | if ( mediaPlayerState->playlist() ) { | 396 | if ( mediaPlayerState->playlist() ) { |
398 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 397 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
@@ -400,5 +399,5 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { | |||
400 | } | 399 | } |
401 | else | 400 | else |
402 | mediaPlayerState->setPlaying( TRUE ); | 401 | mediaPlayerState->setPlaying( true); |
403 | } | 402 | } |
404 | 403 | ||
@@ -497,4 +496,5 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
497 | // } else | 496 | // } else |
498 | 497 | ||
498 | qDebug("current"); | ||
499 | 499 | ||
500 | switch (tabWidget->currentPageIndex()) { | 500 | switch (tabWidget->currentPageIndex()) { |
@@ -607,52 +607,18 @@ bool PlayListWidget::last() { | |||
607 | 607 | ||
608 | void PlayListWidget::saveList() { | 608 | void PlayListWidget::saveList() { |
609 | 609 | writem3u(); | |
610 | QString filename; | ||
611 | InputDialog *fileDlg; | ||
612 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | ||
613 | fileDlg->exec(); | ||
614 | if( fileDlg->result() == 1 ) { | ||
615 | if ( d->current ) | ||
616 | delete d->current; | ||
617 | filename = fileDlg->LineEdit1->text();//+".playlist"; | ||
618 | // qDebug("saving playlist "+filename+".playlist"); | ||
619 | Config cfg( filename +".playlist"); | ||
620 | writeConfig( cfg ); | ||
621 | |||
622 | DocLnk lnk; | ||
623 | // lnk.setComment( ""); | ||
624 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | ||
625 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
626 | lnk.setIcon("opieplayer/playlist2"); | ||
627 | lnk.setName( filename); //sets file name | ||
628 | // qDebug(filename); | ||
629 | if(!lnk.writeLink()) | ||
630 | qDebug("Writing doclink did not work"); | ||
631 | } | ||
632 | Config config( "OpiePlayer" ); | ||
633 | config.writeEntry("CurrentPlaylist",filename); | ||
634 | setCaption(tr("OpiePlayer: ")+filename); | ||
635 | d->selectedFiles->first(); | ||
636 | if(fileDlg) | ||
637 | delete fileDlg; | ||
638 | } | 610 | } |
639 | 611 | ||
640 | void PlayListWidget::loadList( const DocLnk & lnk) { | 612 | void PlayListWidget::loadList( const DocLnk & lnk) { |
641 | QString name= lnk.name(); | 613 | QString name = lnk.name(); |
642 | // qDebug("currentList is "+name); | 614 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
643 | if( name.length()>1) { | 615 | |
616 | if( name.length()>0) { | ||
644 | setCaption("OpiePlayer: "+name); | 617 | setCaption("OpiePlayer: "+name); |
645 | // qDebug("load list "+ name+".playlist"); | 618 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
646 | clearList(); | 619 | clearList(); |
647 | Config cfg( name+".playlist"); | 620 | readm3u(lnk.file()); |
648 | readConfig(cfg); | ||
649 | |||
650 | tabWidget->setCurrentPage(0); | 621 | tabWidget->setCurrentPage(0); |
651 | |||
652 | Config config( "OpiePlayer" ); | ||
653 | config.writeEntry("CurrentPlaylist", name); | ||
654 | // d->selectedFiles->first(); | ||
655 | } | 622 | } |
656 | |||
657 | } | 623 | } |
658 | 624 | ||
@@ -676,5 +642,5 @@ void PlayListWidget::addSelected() { | |||
676 | cfg.setGroup("PlayList"); | 642 | cfg.setGroup("PlayList"); |
677 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 643 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
678 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 644 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
679 | 645 | ||
680 | switch (tabWidget->currentPageIndex()) { | 646 | switch (tabWidget->currentPageIndex()) { |
@@ -739,5 +705,5 @@ void PlayListWidget::removeSelected() { | |||
739 | } | 705 | } |
740 | 706 | ||
741 | void PlayListWidget::playIt( QListViewItem *it) { | 707 | void PlayListWidget::playIt( QListViewItem *) { |
742 | // d->setDocumentUsed = FALSE; | 708 | // d->setDocumentUsed = FALSE; |
743 | // mediaPlayerState->curPosition =0; | 709 | // mediaPlayerState->curPosition =0; |
@@ -778,5 +744,5 @@ void PlayListWidget::addToSelection( QListViewItem *it) { | |||
778 | } | 744 | } |
779 | 745 | ||
780 | void PlayListWidget::tabChanged(QWidget *widg) { | 746 | void PlayListWidget::tabChanged(QWidget *) { |
781 | 747 | ||
782 | switch ( tabWidget->currentPageIndex()) { | 748 | switch ( tabWidget->currentPageIndex()) { |
@@ -821,14 +787,17 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
821 | 787 | ||
822 | void PlayListWidget::btnPlay(bool b) { | 788 | void PlayListWidget::btnPlay(bool b) { |
823 | 789 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | |
824 | // mediaPlayerState->setPlaying(b); | 790 | // mediaPlayerState->setPlaying(b); |
825 | switch ( tabWidget->currentPageIndex()) { | 791 | switch ( tabWidget->currentPageIndex()) { |
826 | case 0: | 792 | case 0: |
827 | { | 793 | { |
794 | qDebug("1"); | ||
828 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 795 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
829 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 796 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
830 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 797 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
831 | // } else { | 798 | // } else { |
832 | mediaPlayerState->setPlaying(b); | 799 | mediaPlayerState->setPlaying(b); |
800 | insanityBool=FALSE; | ||
801 | qDebug("insanity"); | ||
833 | // } | 802 | // } |
834 | } | 803 | } |
@@ -836,4 +805,5 @@ void PlayListWidget::btnPlay(bool b) { | |||
836 | case 1: | 805 | case 1: |
837 | { | 806 | { |
807 | qDebug("2"); | ||
838 | addToSelection( audioView->currentItem() ); | 808 | addToSelection( audioView->currentItem() ); |
839 | mediaPlayerState->setPlaying(b); | 809 | mediaPlayerState->setPlaying(b); |
@@ -846,4 +816,6 @@ void PlayListWidget::btnPlay(bool b) { | |||
846 | case 2: | 816 | case 2: |
847 | { | 817 | { |
818 | qDebug("3"); | ||
819 | |||
848 | addToSelection( videoView->currentItem() ); | 820 | addToSelection( videoView->currentItem() ); |
849 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
@@ -864,7 +836,7 @@ void PlayListWidget::deletePlaylist() { | |||
864 | (tr("Yes")), (tr("No")), 0 )){ | 836 | (tr("Yes")), (tr("No")), 0 )){ |
865 | case 0: // Yes clicked, | 837 | case 0: // Yes clicked, |
866 | // QFile().remove(playLists->selected()->file()); | 838 | QFile().remove(playLists->selectedDocument().file()); |
867 | // QFile().remove(playLists->selected()->linkFile()); | 839 | QFile().remove(playLists->selectedDocument().linkFile()); |
868 | // playLists->reread(); | 840 | playLists->reread(); |
869 | break; | 841 | break; |
870 | case 1: // Cancel | 842 | case 1: // Cancel |
@@ -873,5 +845,5 @@ void PlayListWidget::deletePlaylist() { | |||
873 | } | 845 | } |
874 | 846 | ||
875 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 847 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
876 | { | 848 | { |
877 | switch (mouse) { | 849 | switch (mouse) { |
@@ -895,9 +867,10 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& | |||
895 | void PlayListWidget::playSelected() | 867 | void PlayListWidget::playSelected() |
896 | { | 868 | { |
897 | btnPlay( TRUE); | 869 | qDebug("playSelected"); |
870 | btnPlay( true); | ||
898 | // d->selectedFiles->unSelect(); | 871 | // d->selectedFiles->unSelect(); |
899 | } | 872 | } |
900 | 873 | ||
901 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 874 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
902 | { | 875 | { |
903 | switch (mouse) { | 876 | switch (mouse) { |
@@ -923,5 +896,5 @@ void PlayListWidget::listDelete() { | |||
923 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 896 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
924 | QString file; | 897 | QString file; |
925 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 898 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
926 | switch ( tabWidget->currentPageIndex()) { | 899 | switch ( tabWidget->currentPageIndex()) { |
927 | case 0: | 900 | case 0: |
@@ -962,5 +935,5 @@ void PlayListWidget::listDelete() { | |||
962 | 935 | ||
963 | void PlayListWidget::scanForAudio() { | 936 | void PlayListWidget::scanForAudio() { |
964 | qDebug("scan for audio"); | 937 | // qDebug("scan for audio"); |
965 | files.detachChildren(); | 938 | files.detachChildren(); |
966 | QListIterator<DocLnk> sdit( files.children() ); | 939 | QListIterator<DocLnk> sdit( files.children() ); |
@@ -968,9 +941,9 @@ void PlayListWidget::scanForAudio() { | |||
968 | delete sdit.current(); | 941 | delete sdit.current(); |
969 | } | 942 | } |
970 | Global::findDocuments(&files, "audio/*"); | 943 | Global::findDocuments( &files, audioMimes); |
971 | audioScan = TRUE; | 944 | audioScan = true; |
972 | } | 945 | } |
973 | void PlayListWidget::scanForVideo() { | 946 | void PlayListWidget::scanForVideo() { |
974 | qDebug("scan for video"); | 947 | // qDebug("scan for video"); |
975 | vFiles.detachChildren(); | 948 | vFiles.detachChildren(); |
976 | QListIterator<DocLnk> sdit( vFiles.children() ); | 949 | QListIterator<DocLnk> sdit( vFiles.children() ); |
@@ -979,5 +952,5 @@ void PlayListWidget::scanForVideo() { | |||
979 | } | 952 | } |
980 | Global::findDocuments(&vFiles, "video/*"); | 953 | Global::findDocuments(&vFiles, "video/*"); |
981 | videoScan = TRUE; | 954 | videoScan = true; |
982 | } | 955 | } |
983 | 956 | ||
@@ -1007,5 +980,5 @@ void PlayListWidget::populateAudioView() { | |||
1007 | else | 980 | else |
1008 | size = QFile( dit.current()->file() ).size(); | 981 | size = QFile( dit.current()->file() ).size(); |
1009 | qDebug(dit.current()->name()); | 982 | // qDebug(dit.current()->name()); |
1010 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 983 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1011 | QString::number(size ), storage); | 984 | QString::number(size ), storage); |
@@ -1044,4 +1017,5 @@ void PlayListWidget::populateVideoView() { | |||
1044 | 1017 | ||
1045 | void PlayListWidget::openFile() { | 1018 | void PlayListWidget::openFile() { |
1019 | qDebug("<<<<<<<<<OPEN File"); | ||
1046 | QString filename, name; | 1020 | QString filename, name; |
1047 | InputDialog *fileDlg; | 1021 | InputDialog *fileDlg; |
@@ -1049,36 +1023,226 @@ void PlayListWidget::openFile() { | |||
1049 | fileDlg->exec(); | 1023 | fileDlg->exec(); |
1050 | if( fileDlg->result() == 1 ) { | 1024 | if( fileDlg->result() == 1 ) { |
1051 | filename = fileDlg->LineEdit1->text(); | 1025 | filename = fileDlg->text(); |
1052 | // http://205.188.234.129:8030 | 1026 | qDebug( "Selected filename is " + filename ); |
1053 | // http://66.28.68.70:8000 | 1027 | // Om3u *m3uList; |
1054 | // filename.replace(QRegExp("%20")," "); | 1028 | DocLnk lnk; |
1055 | qDebug("Selected filename is "+filename); | 1029 | Config cfg( "OpiePlayer" ); |
1056 | if(filename.right(3) == "m3u") | 1030 | cfg.setGroup("PlayList"); |
1057 | readm3u( filename); | 1031 | |
1058 | else if(filename.right(3) == "pls") | 1032 | if(filename.left(4) == "http") { |
1059 | readPls( filename); | 1033 | QString m3uFile, m3uFilePath; |
1060 | else { | 1034 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1061 | DocLnk lnk; | 1035 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1062 | 1036 | m3uFile = m3uFile.right( 7); | |
1063 | lnk.setName(filename); //sets file name | 1037 | } else if(filename.left(4) == "http"){ |
1064 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1038 | m3uFile=filename; |
1065 | filename += "/"; | 1039 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
1066 | lnk.setFile(filename); //sets File property | 1040 | } else{ |
1067 | 1041 | m3uFile=filename; | |
1068 | lnk.setType("audio/x-mpegurl"); | ||
1069 | lnk.setExec("opieplayer"); | ||
1070 | lnk.setIcon("opieplayer/MPEGPlayer"); | ||
1071 | |||
1072 | if(!lnk.writeLink()) | ||
1073 | qDebug("Writing doclink did not work"); | ||
1074 | d->selectedFiles->addToSelection( lnk); | ||
1075 | // if(fileDlg2) | ||
1076 | // delete fileDlg2; | ||
1077 | } | 1042 | } |
1043 | |||
1044 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | ||
1045 | lnk.setName( filename ); //sets name | ||
1046 | lnk.setFile( filename ); //sets file name | ||
1047 | lnk.setIcon("opieplayer2/musicfile"); | ||
1048 | d->selectedFiles->addToSelection( lnk ); | ||
1049 | writeCurrentM3u(); | ||
1050 | } | ||
1051 | else if( filename.right( 3) == "m3u" ) { | ||
1052 | readm3u( filename ); | ||
1053 | |||
1054 | } else if( filename.right(3) == "pls" ) { | ||
1055 | readPls( filename ); | ||
1056 | } else { | ||
1057 | d->selectedFiles->addToSelection( DocLnk(filename) ); | ||
1058 | writeCurrentM3u(); | ||
1059 | } | ||
1078 | } | 1060 | } |
1079 | if(fileDlg) | 1061 | |
1062 | if( fileDlg ) { | ||
1080 | delete fileDlg; | 1063 | delete fileDlg; |
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | |||
1068 | /* | ||
1069 | reads m3u and shows files/urls to playlist widget */ | ||
1070 | void PlayListWidget::readm3u( const QString &filename ) { | ||
1071 | qDebug( "read m3u filename " + filename ); | ||
1072 | |||
1073 | Om3u *m3uList; | ||
1074 | QString s, name; | ||
1075 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1076 | m3uList->readM3u(); | ||
1077 | DocLnk lnk; | ||
1078 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1079 | s = *it; | ||
1080 | // qDebug("reading "+ s); | ||
1081 | if(s.left(4)=="http") { | ||
1082 | lnk.setName( s ); //sets file name | ||
1083 | lnk.setIcon("opieplayer2/musicfile"); | ||
1084 | if(s.right(4) != '.' || s.right(5) != '.') | ||
1085 | lnk.setFile( s+"/"); //if url with no extension | ||
1086 | else | ||
1087 | lnk.setFile( s ); //sets file name | ||
1088 | |||
1089 | } else { | ||
1090 | // if( QFileInfo( s ).exists() ) { | ||
1091 | lnk.setName( QFileInfo(s).baseName()); | ||
1092 | // if(s.right(4) == '.') {//if regular file | ||
1093 | if(s.left(1) != "/") { | ||
1094 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | ||
1095 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | ||
1096 | lnk.setIcon("SoundPlayer"); | ||
1097 | } else { | ||
1098 | // qDebug("set link2 "+s); | ||
1099 | lnk.setFile( s); | ||
1100 | lnk.setIcon("SoundPlayer"); | ||
1101 | } | ||
1102 | } | ||
1103 | d->selectedFiles->addToSelection( lnk ); | ||
1104 | } | ||
1105 | Config config( "OpiePlayer" ); | ||
1106 | config.setGroup( "PlayList" ); | ||
1107 | |||
1108 | config.writeEntry("CurrentPlaylist",filename); | ||
1109 | config.write(); | ||
1110 | currentPlayList=filename; | ||
1111 | |||
1112 | // m3uList->write(); | ||
1113 | m3uList->close(); | ||
1114 | if(m3uList) delete m3uList; | ||
1115 | |||
1116 | d->selectedFiles->setSelectedItem( s); | ||
1117 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | ||
1118 | |||
1119 | } | ||
1120 | |||
1121 | /* | ||
1122 | reads pls and adds files/urls to playlist */ | ||
1123 | void PlayListWidget::readPls( const QString &filename ) { | ||
1124 | |||
1125 | qDebug( "pls filename is " + filename ); | ||
1126 | Om3u *m3uList; | ||
1127 | QString s, name; | ||
1128 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1129 | m3uList->readPls(); | ||
1130 | |||
1131 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1132 | s = *it; | ||
1133 | // s.replace( QRegExp( "%20" )," " ); | ||
1134 | DocLnk lnk( s ); | ||
1135 | QFileInfo f( s ); | ||
1136 | QString name = f.baseName(); | ||
1137 | |||
1138 | if( name.left( 4 ) == "http" ) { | ||
1139 | name = s.right( s.length() - 7); | ||
1140 | } else { | ||
1141 | name = s; | ||
1142 | } | ||
1143 | |||
1144 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | ||
1145 | |||
1146 | lnk.setName( name ); | ||
1147 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | ||
1148 | lnk.setFile( s ); | ||
1149 | } else { //if its a url | ||
1150 | if( name.right( 1 ).find( '/' ) == -1) { | ||
1151 | s += "/"; | ||
1152 | } | ||
1153 | lnk.setFile( s ); | ||
1154 | } | ||
1155 | lnk.setType( "audio/x-mpegurl" ); | ||
1156 | |||
1157 | lnk.writeLink(); | ||
1158 | d->selectedFiles->addToSelection( lnk ); | ||
1159 | } | ||
1160 | |||
1161 | m3uList->close(); | ||
1162 | if(m3uList) delete m3uList; | ||
1081 | } | 1163 | } |
1082 | 1164 | ||
1165 | /* | ||
1166 | writes current playlist to current m3u file */ | ||
1167 | void PlayListWidget::writeCurrentM3u() { | ||
1168 | qDebug("writing to current m3u"); | ||
1169 | Config cfg( "OpiePlayer" ); | ||
1170 | cfg.setGroup("PlayList"); | ||
1171 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
1172 | |||
1173 | if( d->selectedFiles->first()) { | ||
1174 | Om3u *m3uList; | ||
1175 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | ||
1176 | |||
1177 | do { | ||
1178 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | ||
1179 | m3uList->add( d->selectedFiles->current()->file() ); | ||
1180 | } | ||
1181 | while ( d->selectedFiles->next() ); | ||
1182 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
1183 | m3uList->write(); | ||
1184 | m3uList->close(); | ||
1185 | |||
1186 | if(m3uList) delete m3uList; | ||
1187 | } | ||
1188 | } | ||
1189 | |||
1190 | /* | ||
1191 | writes current playlist to m3u file */ | ||
1192 | void PlayListWidget::writem3u() { | ||
1193 | InputDialog *fileDlg; | ||
1194 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | ||
1195 | fileDlg->exec(); | ||
1196 | QString name, filename, list; | ||
1197 | Om3u *m3uList; | ||
1198 | |||
1199 | if( fileDlg->result() == 1 ) { | ||
1200 | name = fileDlg->text(); | ||
1201 | // qDebug( filename ); | ||
1202 | |||
1203 | if( name.left( 1) != "/" ) { | ||
1204 | filename = QPEApplication::documentDir() + "/" + name; | ||
1205 | } | ||
1206 | |||
1207 | if( name.right( 3 ) != "m3u" ) { | ||
1208 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
1209 | } | ||
1210 | |||
1211 | if( d->selectedFiles->first()) { | ||
1212 | m3uList = new Om3u(filename, IO_ReadWrite); | ||
1213 | |||
1214 | do { | ||
1215 | m3uList->add( d->selectedFiles->current()->file()); | ||
1216 | } | ||
1217 | while ( d->selectedFiles->next() ); | ||
1218 | // qDebug( list ); | ||
1219 | m3uList->write(); | ||
1220 | m3uList->close(); | ||
1221 | if(m3uList) delete m3uList; | ||
1222 | |||
1223 | if(fileDlg) delete fileDlg; | ||
1224 | |||
1225 | DocLnk lnk; | ||
1226 | lnk.setFile( filename); | ||
1227 | lnk.setIcon("opieplayer2/playlist2"); | ||
1228 | lnk.setName( name); //sets file name | ||
1229 | |||
1230 | // qDebug(filename); | ||
1231 | Config config( "OpiePlayer" ); | ||
1232 | config.setGroup( "PlayList" ); | ||
1233 | |||
1234 | config.writeEntry("CurrentPlaylist",filename); | ||
1235 | currentPlayList=filename; | ||
1236 | |||
1237 | if(!lnk.writeLink()) { | ||
1238 | qDebug("Writing doclink did not work"); | ||
1239 | } | ||
1240 | |||
1241 | setCaption(tr("OpiePlayer: ") + name); | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | |||
1246 | |||
1083 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1247 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1084 | { | 1248 | { |
@@ -1142,5 +1306,5 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1142 | } | 1306 | } |
1143 | 1307 | ||
1144 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1308 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1145 | { | 1309 | { |
1146 | // qDebug("Key press"); | 1310 | // qDebug("Key press"); |
@@ -1187,146 +1351,2 @@ void PlayListWidget::doUnblank() { | |||
1187 | } | 1351 | } |
1188 | 1352 | ||
1189 | void PlayListWidget::readm3u(const QString &filename) { | ||
1190 | |||
1191 | qDebug("m3u filename is "+filename); | ||
1192 | QFile f(filename); | ||
1193 | |||
1194 | if(f.open(IO_ReadOnly)) { | ||
1195 | QTextStream t(&f); | ||
1196 | QString s;//, first, second; | ||
1197 | int i=0; | ||
1198 | while ( !t.atEnd()) { | ||
1199 | // Lview->insertLine(t.readLine(),-1); | ||
1200 | s=t.readLine(); | ||
1201 | |||
1202 | if(s.find("#",0,TRUE) == -1) { | ||
1203 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | ||
1204 | if(s.left(2) == "E:" || s.left(2) == "P:") { | ||
1205 | s=s.right(s.length()-2); | ||
1206 | DocLnk lnk( s ); | ||
1207 | QFileInfo f(s); | ||
1208 | QString name = f.baseName(); | ||
1209 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1210 | lnk.setName( name); | ||
1211 | s=s.replace( QRegExp("\\"),"/"); | ||
1212 | lnk.setFile( s); | ||
1213 | lnk.writeLink(); | ||
1214 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1215 | qDebug("add "+name); | ||
1216 | d->selectedFiles->addToSelection( lnk); | ||
1217 | } else { // is url | ||
1218 | |||
1219 | s.replace(QRegExp("%20")," "); | ||
1220 | DocLnk lnk( s); | ||
1221 | QString name; | ||
1222 | if(name.left(4)=="http") | ||
1223 | name = s.right( s.length() - 7); | ||
1224 | else | ||
1225 | name=s; | ||
1226 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1227 | lnk.setName(name); | ||
1228 | if(s.at(s.length()-4) == '.') | ||
1229 | lnk.setFile( s); | ||
1230 | else | ||
1231 | lnk.setFile( s+"/"); | ||
1232 | // lnk.setFile( filename); | ||
1233 | // lnk.setComment( s+"/"); | ||
1234 | lnk.setType("audio/x-mpegurl"); | ||
1235 | lnk.writeLink(); | ||
1236 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1237 | // qDebug("add "+s); | ||
1238 | d->selectedFiles->addToSelection( lnk); | ||
1239 | } | ||
1240 | i++; | ||
1241 | } | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | f.close(); | ||
1246 | } | ||
1247 | |||
1248 | void PlayListWidget::writem3u() { | ||
1249 | |||
1250 | InputDialog *fileDlg; | ||
1251 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | ||
1252 | fileDlg->exec(); | ||
1253 | QString filename,list; | ||
1254 | if( fileDlg->result() == 1 ) { | ||
1255 | filename = fileDlg->LineEdit1->text(); | ||
1256 | qDebug(filename); | ||
1257 | int noOfFiles = 0; | ||
1258 | d->selectedFiles->first(); | ||
1259 | do { | ||
1260 | // we dont check for existance because of url's | ||
1261 | // qDebug(d->selectedFiles->current()->file()); | ||
1262 | list += d->selectedFiles->current()->file()+"\n"; | ||
1263 | noOfFiles++; | ||
1264 | } | ||
1265 | while ( d->selectedFiles->next() ); | ||
1266 | qDebug(list); | ||
1267 | if(filename.left(1) != "/") | ||
1268 | filename=QPEApplication::documentDir()+"/"+filename; | ||
1269 | if(filename.right(3) != "m3u") | ||
1270 | filename=filename+".m3u"; | ||
1271 | |||
1272 | QFile f(filename); | ||
1273 | f.open(IO_WriteOnly); | ||
1274 | f.writeBlock(list, list.length()); | ||
1275 | f.close(); | ||
1276 | } | ||
1277 | if(fileDlg) delete fileDlg; | ||
1278 | } | ||
1279 | |||
1280 | void PlayListWidget::readPls(const QString &filename) { | ||
1281 | |||
1282 | qDebug("pls filename is "+filename); | ||
1283 | QFile f(filename); | ||
1284 | |||
1285 | if(f.open(IO_ReadOnly)) { | ||
1286 | QTextStream t(&f); | ||
1287 | QString s;//, first, second; | ||
1288 | int i=0; | ||
1289 | while ( !t.atEnd()) { | ||
1290 | s=t.readLine(); | ||
1291 | if(s.left(4) == "File") { | ||
1292 | s=s.right(s.length() - 6); | ||
1293 | s.replace(QRegExp("%20")," "); | ||
1294 | qDebug("adding "+s+" to playlist"); | ||
1295 | // numberofentries=2 | ||
1296 | // File1=http | ||
1297 | // Title | ||
1298 | // Length | ||
1299 | // Version | ||
1300 | // File2=http | ||
1301 | |||
1302 | s=s.replace( QRegExp("\\"),"/"); | ||
1303 | DocLnk lnk( s ); | ||
1304 | QFileInfo f(s); | ||
1305 | QString name = f.baseName(); | ||
1306 | if(name.left(4)=="http") | ||
1307 | name = s.right( s.length() - 7); | ||
1308 | else | ||
1309 | name=s; | ||
1310 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1311 | // QFileInfo f(s); | ||
1312 | // QString name = f.baseName(); | ||
1313 | // name = name.left(name.length()-4); | ||
1314 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1315 | lnk.setName( name); | ||
1316 | if(s.at(s.length()-4) == '.') // if this is probably a file | ||
1317 | lnk.setFile( s); | ||
1318 | else { //if its a url | ||
1319 | if( name.right(1).find('/') == -1) | ||
1320 | s+="/"; | ||
1321 | lnk.setFile( s); | ||
1322 | } | ||
1323 | lnk.setType("audio/x-mpegurl"); | ||
1324 | |||
1325 | qDebug("DocLnk add "+name); | ||
1326 | d->selectedFiles->addToSelection( lnk); | ||
1327 | } | ||
1328 | } | ||
1329 | i++; | ||
1330 | } | ||
1331 | } | ||
1332 | |||