author | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
commit | 4c53e68c3ac96baaaf39cc049c89d8ccf022ff59 (patch) (unidiff) | |
tree | 8273ae338f0d611c28438a4f8a6a6fc8329e90e8 | |
parent | a214128c01e38ffd50edc4ed5b5c72593796eab2 (diff) | |
download | opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.zip opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.gz opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.bz2 |
Handling of Errors is a bit problematic with the current design.
We can start playing from multiple contexts. This are the PlayList context
and single file context. Now the problem is that
MediapPlayerState::setPlaying emits a signal. If started from the
the PlayList setPlaying(false) would trigger an infite loop together
with the Play ToggleButton, in single file context setPlaying(false)
is the right choiche.
The intermediate solution is to show an Error MessageBox and to raise
the Audio Widget and leave it to the user to close it or go to the next
file.
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 48 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 4 |
3 files changed, 30 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index d73f0cd..37b998f 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1049 +1,1050 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include "playlistselection.h" | 34 | #include "playlistselection.h" |
35 | #include "playlistwidget.h" | 35 | #include "playlistwidget.h" |
36 | #include "mediaplayer.h" | 36 | #include "mediaplayer.h" |
37 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
38 | #include "om3u.h" | 38 | #include "om3u.h" |
39 | #include "playlistfileview.h" | 39 | #include "playlistfileview.h" |
40 | 40 | ||
41 | /* OPIE */ | 41 | /* OPIE */ |
42 | #include <opie2/odebug.h> | 42 | #include <opie2/odebug.h> |
43 | #include <opie2/ofiledialog.h> | 43 | #include <opie2/ofiledialog.h> |
44 | using namespace Opie::Core; | 44 | using namespace Opie::Core; |
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qtoolbar.h> | 49 | #include <qtoolbar.h> |
50 | 50 | ||
51 | /* STD */ | 51 | /* STD */ |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
56 | { | 56 | { |
57 | Global::statusMessage( tr( "Loading of Skin started" ) ); | ||
57 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 58 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
58 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 59 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
59 | 60 | ||
60 | 61 | ||
61 | 62 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 64 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 65 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 66 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 67 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 68 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 69 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
69 | this , SLOT( btnPlay(bool) ), TRUE ); | 70 | this , SLOT( btnPlay(bool) ), TRUE ); |
70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 71 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
71 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); | 72 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 73 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
73 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); | 74 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
74 | 75 | ||
75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 77 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
77 | this, SLOT( addAllMusicToList() ) ); | 78 | this, SLOT( addAllMusicToList() ) ); |
78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 79 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
79 | this, SLOT( addAllVideoToList() ) ); | 80 | this, SLOT( addAllVideoToList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 81 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
81 | this, SLOT( addAllToList() ) ); | 82 | this, SLOT( addAllToList() ) ); |
82 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
83 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
84 | this,SLOT( openFile() ) ); | 85 | this,SLOT( openFile() ) ); |
85 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 86 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
86 | this,SLOT( openURL() ) ); | 87 | this,SLOT( openURL() ) ); |
87 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 89 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
89 | this, SLOT(writem3u() ) ); | 90 | this, SLOT(writem3u() ) ); |
90 | pmPlayList->insertSeparator(-1); | 91 | pmPlayList->insertSeparator(-1); |
91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 92 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
92 | audioView, SLOT( scanFiles() ) ); | 93 | audioView, SLOT( scanFiles() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
94 | videoView, SLOT( scanFiles() ) ); | 95 | videoView, SLOT( scanFiles() ) ); |
95 | 96 | ||
96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 97 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
97 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 98 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
98 | 99 | ||
99 | Config cfg( "OpiePlayer" ); | 100 | Config cfg( "OpiePlayer" ); |
100 | bool b= cfg.readBoolEntry("FullScreen", 0); | 101 | bool b= cfg.readBoolEntry("FullScreen", 0); |
101 | mediaPlayerState->setFullscreen( b ); | 102 | mediaPlayerState->setFullscreen( b ); |
102 | pmView->setItemChecked( -16, b ); | 103 | pmView->setItemChecked( -16, b ); |
103 | 104 | ||
104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 105 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 106 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 107 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
107 | d->selectedFiles, SLOT(removeSelected() ) ); | 108 | d->selectedFiles, SLOT(removeSelected() ) ); |
108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 109 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 110 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
110 | QVBox *stretch2 = new QVBox( vbox1 ); | 111 | QVBox *stretch2 = new QVBox( vbox1 ); |
111 | 112 | ||
112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 113 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
113 | SLOT( deletePlaylist() ) ); | 114 | SLOT( deletePlaylist() ) ); |
114 | connect( pmView, SIGNAL( activated(int) ), | 115 | connect( pmView, SIGNAL( activated(int) ), |
115 | this, SLOT( pmViewActivated(int) ) ); | 116 | this, SLOT( pmViewActivated(int) ) ); |
116 | connect( skinsMenu, SIGNAL( activated(int) ) , | 117 | connect( skinsMenu, SIGNAL( activated(int) ) , |
117 | this, SLOT( skinsMenuActivated(int) ) ); | 118 | this, SLOT( skinsMenuActivated(int) ) ); |
118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 119 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
119 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 120 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
120 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 121 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
121 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 122 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
122 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), | 123 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
123 | this,SLOT( playIt(QListViewItem*) ) ); | 124 | this,SLOT( playIt(QListViewItem*) ) ); |
124 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), | 125 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
125 | this, SLOT( addToSelection(QListViewItem*) ) ); | 126 | this, SLOT( addToSelection(QListViewItem*) ) ); |
126 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 127 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
127 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 128 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
128 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), | 129 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
129 | this,SLOT( playIt(QListViewItem*) ) ); | 130 | this,SLOT( playIt(QListViewItem*) ) ); |
130 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), | 131 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
131 | this, SLOT( addToSelection(QListViewItem*) ) ); | 132 | this, SLOT( addToSelection(QListViewItem*) ) ); |
132 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), | 133 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
133 | this, SLOT( loadList(const DocLnk&) ) ); | 134 | this, SLOT( loadList(const DocLnk&) ) ); |
134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 135 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
135 | this, SLOT( tabChanged(QWidget*) ) ); | 136 | this, SLOT( tabChanged(QWidget*) ) ); |
136 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), | 137 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
137 | d->tbPlay, SLOT( setOn(bool) ) ); | 138 | d->tbPlay, SLOT( setOn(bool) ) ); |
138 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 139 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
139 | d->tbLoop, SLOT( setOn(bool) ) ); | 140 | d->tbLoop, SLOT( setOn(bool) ) ); |
140 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 141 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
141 | d->tbShuffle, SLOT( setOn(bool) ) ); | 142 | d->tbShuffle, SLOT( setOn(bool) ) ); |
142 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 143 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
143 | this, SLOT( playIt(QListViewItem*) ) ); | 144 | this, SLOT( playIt(QListViewItem*) ) ); |
144 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 145 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
145 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 146 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
146 | 147 | ||
147 | connect( this, SIGNAL(skinSelected() ), | 148 | connect( this, SIGNAL(skinSelected() ), |
148 | m_mp, SLOT( reloadSkins() ) ); | 149 | m_mp, SLOT( reloadSkins() ) ); |
149 | 150 | ||
150 | // see which skins are installed | 151 | // see which skins are installed |
151 | populateSkinsMenu(); | 152 | populateSkinsMenu(); |
152 | initializeStates(); | 153 | initializeStates(); |
153 | 154 | ||
154 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 155 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
155 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 156 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
156 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 157 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
157 | 158 | ||
158 | 159 | ||
159 | cfg.setGroup("PlayList"); | 160 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 161 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
161 | loadList(DocLnk( currentPlaylist ) ); | 162 | loadList(DocLnk( currentPlaylist ) ); |
162 | 163 | ||
163 | tabWidget->showPage( playListTab ); | 164 | tabWidget->showPage( playListTab ); |
164 | } | 165 | } |
165 | 166 | ||
166 | 167 | ||
167 | PlayListWidget::~PlayListWidget() { | 168 | PlayListWidget::~PlayListWidget() { |
168 | delete d; | 169 | delete d; |
169 | delete m_mp; | 170 | delete m_mp; |
170 | } | 171 | } |
171 | 172 | ||
172 | 173 | ||
173 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
177 | d->playListFrame->show(); | 178 | d->playListFrame->show(); |
178 | } | 179 | } |
179 | 180 | ||
180 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
181 | 182 | ||
182 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
183 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
186 | if( currentString == filename) { | 187 | if( currentString == filename) { |
187 | Om3u *m3uList; | 188 | Om3u *m3uList; |
188 | if( d->selectedFiles->first() ) { | 189 | if( d->selectedFiles->first() ) { |
189 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
190 | do { | 191 | do { |
191 | m3uList->add( d->selectedFiles->current()->file() ); | 192 | m3uList->add( d->selectedFiles->current()->file() ); |
192 | } | 193 | } |
193 | while ( d->selectedFiles->next() ); | 194 | while ( d->selectedFiles->next() ); |
194 | 195 | ||
195 | m3uList->write(); | 196 | m3uList->write(); |
196 | m3uList->close(); | 197 | m3uList->close(); |
197 | delete m3uList; | 198 | delete m3uList; |
198 | 199 | ||
199 | } | 200 | } |
200 | } | 201 | } |
201 | } | 202 | } |
202 | 203 | ||
203 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 204 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
204 | d->setDocumentUsed = FALSE; | 205 | d->setDocumentUsed = FALSE; |
205 | if( QFileInfo( lnk.file() ).exists() || | 206 | if( QFileInfo( lnk.file() ).exists() || |
206 | lnk.file().left(4) == "http" ) { | 207 | lnk.file().left(4) == "http" ) { |
207 | d->selectedFiles->addToSelection( lnk ); | 208 | d->selectedFiles->addToSelection( lnk ); |
208 | } | 209 | } |
209 | } | 210 | } |
210 | 211 | ||
211 | 212 | ||
212 | void PlayListWidget::clearList() { | 213 | void PlayListWidget::clearList() { |
213 | while ( first() ) { | 214 | while ( first() ) { |
214 | d->selectedFiles->removeSelected(); | 215 | d->selectedFiles->removeSelected(); |
215 | } | 216 | } |
216 | Config cfg( "OpiePlayer" ); | 217 | Config cfg( "OpiePlayer" ); |
217 | cfg.setGroup("PlayList"); | 218 | cfg.setGroup("PlayList"); |
218 | cfg.writeEntry("CurrentPlaylist","default"); | 219 | cfg.writeEntry("CurrentPlaylist","default"); |
219 | setCaption("OpiePlayer"); | 220 | setCaption("OpiePlayer"); |
220 | } | 221 | } |
221 | 222 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 223 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 224 | switch (mouse) { |
224 | case LeftButton: | 225 | case LeftButton: |
225 | break; | 226 | break; |
226 | case RightButton: | 227 | case RightButton: |
227 | { | 228 | { |
228 | QPopupMenu m; | 229 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 230 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 231 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 232 | m.exec( QCursor::pos() ); |
232 | } | 233 | } |
233 | break; | 234 | break; |
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 239 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 240 | switch (mouse) { |
240 | case LeftButton: | 241 | case LeftButton: |
241 | break; | 242 | break; |
242 | case RightButton: | 243 | case RightButton: |
243 | { | 244 | { |
244 | QPopupMenu m; | 245 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 246 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 247 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 248 | m.exec( QCursor::pos() ); |
248 | } | 249 | } |
249 | break; | 250 | break; |
250 | } | 251 | } |
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | void PlayListWidget::addAllToList() { | 255 | void PlayListWidget::addAllToList() { |
255 | 256 | ||
256 | 257 | ||
257 | audioView->populateView(); | 258 | audioView->populateView(); |
258 | 259 | ||
259 | QListViewItemIterator audioIt( audioView ); | 260 | QListViewItemIterator audioIt( audioView ); |
260 | DocLnk lnk; | 261 | DocLnk lnk; |
261 | QString filename; | 262 | QString filename; |
262 | // iterate through all items of the listview | 263 | // iterate through all items of the listview |
263 | for ( ; audioIt.current(); ++audioIt ) { | 264 | for ( ; audioIt.current(); ++audioIt ) { |
264 | filename = audioIt.current()->text(3); | 265 | filename = audioIt.current()->text(3); |
265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 266 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
266 | lnk.setFile( filename ); //sets file name | 267 | lnk.setFile( filename ); //sets file name |
267 | d->selectedFiles->addToSelection( lnk); | 268 | d->selectedFiles->addToSelection( lnk); |
268 | } | 269 | } |
269 | 270 | ||
270 | videoView->populateView(); | 271 | videoView->populateView(); |
271 | 272 | ||
272 | QListViewItemIterator videoIt( videoView ); | 273 | QListViewItemIterator videoIt( videoView ); |
273 | for ( ; videoIt.current(); ++videoIt ) { | 274 | for ( ; videoIt.current(); ++videoIt ) { |
274 | filename = videoIt.current()->text(3); | 275 | filename = videoIt.current()->text(3); |
275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 276 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
276 | lnk.setFile( filename ); //sets file name | 277 | lnk.setFile( filename ); //sets file name |
277 | d->selectedFiles->addToSelection( lnk); | 278 | d->selectedFiles->addToSelection( lnk); |
278 | } | 279 | } |
279 | 280 | ||
280 | tabWidget->setCurrentPage(0); | 281 | tabWidget->setCurrentPage(0); |
281 | 282 | ||
282 | writeCurrentM3u(); | 283 | writeCurrentM3u(); |
283 | d->selectedFiles->first(); | 284 | d->selectedFiles->first(); |
284 | } | 285 | } |
285 | 286 | ||
286 | 287 | ||
287 | void PlayListWidget::addAllMusicToList() { | 288 | void PlayListWidget::addAllMusicToList() { |
288 | 289 | ||
289 | audioView->populateView(); | 290 | audioView->populateView(); |
290 | 291 | ||
291 | QListViewItemIterator audioIt( audioView ); | 292 | QListViewItemIterator audioIt( audioView ); |
292 | DocLnk lnk; | 293 | DocLnk lnk; |
293 | QString filename; | 294 | QString filename; |
294 | // iterate through all items of the listview | 295 | // iterate through all items of the listview |
295 | for ( ; audioIt.current(); ++audioIt ) { | 296 | for ( ; audioIt.current(); ++audioIt ) { |
296 | filename = audioIt.current()->text(3); | 297 | filename = audioIt.current()->text(3); |
297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 298 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
298 | lnk.setFile( filename ); //sets file name | 299 | lnk.setFile( filename ); //sets file name |
299 | d->selectedFiles->addToSelection( lnk); | 300 | d->selectedFiles->addToSelection( lnk); |
300 | } | 301 | } |
301 | 302 | ||
302 | tabWidget->setCurrentPage(0); | 303 | tabWidget->setCurrentPage(0); |
303 | writeCurrentM3u(); | 304 | writeCurrentM3u(); |
304 | d->selectedFiles->first(); | 305 | d->selectedFiles->first(); |
305 | } | 306 | } |
306 | 307 | ||
307 | 308 | ||
308 | void PlayListWidget::addAllVideoToList() { | 309 | void PlayListWidget::addAllVideoToList() { |
309 | 310 | ||
310 | videoView->populateView(); | 311 | videoView->populateView(); |
311 | 312 | ||
312 | QListViewItemIterator videoIt( videoView ); | 313 | QListViewItemIterator videoIt( videoView ); |
313 | DocLnk lnk; | 314 | DocLnk lnk; |
314 | QString filename; | 315 | QString filename; |
315 | for ( ; videoIt.current(); ++videoIt ) { | 316 | for ( ; videoIt.current(); ++videoIt ) { |
316 | filename = videoIt.current()->text(3); | 317 | filename = videoIt.current()->text(3); |
317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 318 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
318 | lnk.setFile( filename ); //sets file name | 319 | lnk.setFile( filename ); //sets file name |
319 | d->selectedFiles->addToSelection( lnk); | 320 | d->selectedFiles->addToSelection( lnk); |
320 | } | 321 | } |
321 | tabWidget->setCurrentPage(0); | 322 | tabWidget->setCurrentPage(0); |
322 | writeCurrentM3u(); | 323 | writeCurrentM3u(); |
323 | d->selectedFiles->first(); | 324 | d->selectedFiles->first(); |
324 | } | 325 | } |
325 | 326 | ||
326 | 327 | ||
327 | void PlayListWidget::setDocument( const QString& _fileref ) { | 328 | void PlayListWidget::setDocument( const QString& _fileref ) { |
328 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 329 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
329 | QString fileref = _fileref; | 330 | QString fileref = _fileref; |
330 | fromSetDocument = TRUE; | 331 | fromSetDocument = TRUE; |
331 | 332 | ||
332 | DocLnk lnk(_fileref); | 333 | DocLnk lnk(_fileref); |
333 | if(lnk.isValid()) | 334 | if(lnk.isValid()) |
334 | fileref = lnk.file(); | 335 | fileref = lnk.file(); |
335 | 336 | ||
336 | QFileInfo fileInfo(fileref); | 337 | QFileInfo fileInfo(fileref); |
337 | 338 | ||
338 | if ( !fileInfo.exists() ) { | 339 | if ( !fileInfo.exists() ) { |
339 | QMessageBox::warning( this, tr( "Invalid File" ), | 340 | QMessageBox::warning( this, tr( "Invalid File" ), |
340 | tr( "There was a problem in getting the file." ) ); | 341 | tr( "There was a problem in getting the file." ) ); |
341 | return; | 342 | return; |
342 | } | 343 | } |
343 | 344 | ||
344 | clearList(); | 345 | clearList(); |
345 | QString extension = fileInfo.extension(false); | 346 | QString extension = fileInfo.extension(false); |
346 | 347 | ||
347 | if( extension.find( "m3u", 0, false) != -1 | 348 | if( extension.find( "m3u", 0, false) != -1 |
348 | || extension.find( "pls", 0, false) != -1 ) { | 349 | || extension.find( "pls", 0, false) != -1 ) { |
349 | readListFromFile( fileref ); | 350 | readListFromFile( fileref ); |
350 | } else { | 351 | } else { |
351 | clearList(); | 352 | clearList(); |
352 | DocLnk lnk; | 353 | DocLnk lnk; |
353 | lnk.setName( fileInfo.baseName() ); //sets name | 354 | lnk.setName( fileInfo.baseName() ); //sets name |
354 | lnk.setFile( fileref ); //sets file name | 355 | lnk.setFile( fileref ); //sets file name |
355 | addToSelection( lnk ); | 356 | addToSelection( lnk ); |
356 | writeCurrentM3u(); | 357 | writeCurrentM3u(); |
357 | 358 | ||
358 | d->setDocumentUsed = TRUE; | 359 | d->setDocumentUsed = TRUE; |
359 | mediaPlayerState->setPlaying( FALSE ); | 360 | mediaPlayerState->setPlaying( FALSE ); |
360 | mediaPlayerState->setPlaying( TRUE ); | 361 | mediaPlayerState->setPlaying( TRUE ); |
361 | } | 362 | } |
362 | } | 363 | } |
363 | 364 | ||
364 | 365 | ||
365 | void PlayListWidget::useSelectedDocument() { | 366 | void PlayListWidget::useSelectedDocument() { |
366 | d->setDocumentUsed = FALSE; | 367 | d->setDocumentUsed = FALSE; |
367 | } | 368 | } |
368 | 369 | ||
369 | 370 | ||
370 | const DocLnk *PlayListWidget::current() const { // this is fugly | 371 | const DocLnk *PlayListWidget::current() const { // this is fugly |
371 | assert( currentTab() == CurrentPlayList ); | 372 | assert( currentTab() == CurrentPlayList ); |
372 | 373 | ||
373 | const DocLnk *lnk = d->selectedFiles->current(); | 374 | const DocLnk *lnk = d->selectedFiles->current(); |
374 | if ( !lnk ) { | 375 | if ( !lnk ) { |
375 | d->selectedFiles->first(); | 376 | d->selectedFiles->first(); |
376 | lnk = d->selectedFiles->current(); | 377 | lnk = d->selectedFiles->current(); |
377 | } | 378 | } |
378 | assert( lnk ); | 379 | assert( lnk ); |
379 | return lnk; | 380 | return lnk; |
380 | } | 381 | } |
381 | 382 | ||
382 | 383 | ||
383 | bool PlayListWidget::prev() { | 384 | bool PlayListWidget::prev() { |
384 | if ( mediaPlayerState->isShuffled() ) { | 385 | if ( mediaPlayerState->isShuffled() ) { |
385 | const DocLnk *cur = current(); | 386 | const DocLnk *cur = current(); |
386 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 387 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
387 | for ( int i = 0; i < j; i++ ) { | 388 | for ( int i = 0; i < j; i++ ) { |
388 | if ( !d->selectedFiles->next() ) | 389 | if ( !d->selectedFiles->next() ) |
389 | d->selectedFiles->first(); | 390 | d->selectedFiles->first(); |
390 | } | 391 | } |
391 | if ( cur == current() ) | 392 | if ( cur == current() ) |
392 | if ( !d->selectedFiles->next() ) { | 393 | if ( !d->selectedFiles->next() ) { |
393 | d->selectedFiles->first(); | 394 | d->selectedFiles->first(); |
394 | } | 395 | } |
395 | return TRUE; | 396 | return TRUE; |
396 | } else { | 397 | } else { |
397 | if ( !d->selectedFiles->prev() ) { | 398 | if ( !d->selectedFiles->prev() ) { |
398 | if ( mediaPlayerState->isLooping() ) { | 399 | if ( mediaPlayerState->isLooping() ) { |
399 | return d->selectedFiles->last(); | 400 | return d->selectedFiles->last(); |
400 | } else { | 401 | } else { |
401 | return FALSE; | 402 | return FALSE; |
402 | } | 403 | } |
403 | } | 404 | } |
404 | return TRUE; | 405 | return TRUE; |
405 | } | 406 | } |
406 | } | 407 | } |
407 | 408 | ||
408 | 409 | ||
409 | bool PlayListWidget::next() { | 410 | bool PlayListWidget::next() { |
410 | //odebug << "<<<<<<<<<<<<next()" << oendl; | 411 | //odebug << "<<<<<<<<<<<<next()" << oendl; |
411 | if ( mediaPlayerState->isShuffled() ) { | 412 | if ( mediaPlayerState->isShuffled() ) { |
412 | return prev(); | 413 | return prev(); |
413 | } else { | 414 | } else { |
414 | if ( !d->selectedFiles->next() ) { | 415 | if ( !d->selectedFiles->next() ) { |
415 | if ( mediaPlayerState->isLooping() ) { | 416 | if ( mediaPlayerState->isLooping() ) { |
416 | return d->selectedFiles->first(); | 417 | return d->selectedFiles->first(); |
417 | } else { | 418 | } else { |
418 | return FALSE; | 419 | return FALSE; |
419 | } | 420 | } |
420 | } | 421 | } |
421 | return TRUE; | 422 | return TRUE; |
422 | } | 423 | } |
423 | } | 424 | } |
424 | 425 | ||
425 | 426 | ||
426 | bool PlayListWidget::first() { | 427 | bool PlayListWidget::first() { |
427 | return d->selectedFiles->first(); | 428 | return d->selectedFiles->first(); |
428 | } | 429 | } |
429 | 430 | ||
430 | 431 | ||
431 | bool PlayListWidget::last() { | 432 | bool PlayListWidget::last() { |
432 | return d->selectedFiles->last(); | 433 | return d->selectedFiles->last(); |
433 | } | 434 | } |
434 | 435 | ||
435 | 436 | ||
436 | void PlayListWidget::saveList() { | 437 | void PlayListWidget::saveList() { |
437 | writem3u(); | 438 | writem3u(); |
438 | } | 439 | } |
439 | 440 | ||
440 | 441 | ||
441 | void PlayListWidget::loadList( const DocLnk & lnk) { | 442 | void PlayListWidget::loadList( const DocLnk & lnk) { |
442 | QString name = lnk.name(); | 443 | QString name = lnk.name(); |
443 | 444 | ||
444 | if( name.length()>0) { | 445 | if( name.length()>0) { |
445 | setCaption("OpiePlayer: "+name); | 446 | setCaption("OpiePlayer: "+name); |
446 | clearList(); | 447 | clearList(); |
447 | readListFromFile(lnk.file()); | 448 | readListFromFile(lnk.file()); |
448 | tabWidget->setCurrentPage(0); | 449 | tabWidget->setCurrentPage(0); |
449 | } | 450 | } |
450 | } | 451 | } |
451 | 452 | ||
452 | void PlayListWidget::addSelected() { | 453 | void PlayListWidget::addSelected() { |
453 | assert( inFileListMode() ); | 454 | assert( inFileListMode() ); |
454 | 455 | ||
455 | QListViewItemIterator it( currentFileListView ); | 456 | QListViewItemIterator it( currentFileListView ); |
456 | for ( ; it.current(); ++it ) | 457 | for ( ; it.current(); ++it ) |
457 | if ( it.current()->isSelected() ) { | 458 | if ( it.current()->isSelected() ) { |
458 | QString filename = it.current()->text(3); | 459 | QString filename = it.current()->text(3); |
459 | 460 | ||
460 | DocLnk lnk; | 461 | DocLnk lnk; |
461 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 462 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
462 | lnk.setFile( filename ); //sets file name | 463 | lnk.setFile( filename ); //sets file name |
463 | 464 | ||
464 | d->selectedFiles->addToSelection( lnk ); | 465 | d->selectedFiles->addToSelection( lnk ); |
465 | } | 466 | } |
466 | 467 | ||
467 | currentFileListView->clearSelection(); | 468 | currentFileListView->clearSelection(); |
468 | 469 | ||
469 | writeCurrentM3u(); | 470 | writeCurrentM3u(); |
470 | } | 471 | } |
471 | 472 | ||
472 | 473 | ||
473 | void PlayListWidget::removeSelected() { | 474 | void PlayListWidget::removeSelected() { |
474 | d->selectedFiles->removeSelected( ); | 475 | d->selectedFiles->removeSelected( ); |
475 | writeCurrentM3u(); | 476 | writeCurrentM3u(); |
476 | } | 477 | } |
477 | 478 | ||
478 | 479 | ||
479 | void PlayListWidget::playIt( QListViewItem *it) { | 480 | void PlayListWidget::playIt( QListViewItem *it) { |
480 | if(!it) return; | 481 | if(!it) return; |
481 | mediaPlayerState->setPlaying(FALSE); | 482 | mediaPlayerState->setPlaying(FALSE); |
482 | mediaPlayerState->setPlaying(TRUE); | 483 | mediaPlayerState->setPlaying(TRUE); |
483 | d->selectedFiles->unSelect(); | 484 | d->selectedFiles->unSelect(); |
484 | } | 485 | } |
485 | 486 | ||
486 | 487 | ||
487 | void PlayListWidget::addToSelection( QListViewItem *it) { | 488 | void PlayListWidget::addToSelection( QListViewItem *it) { |
488 | d->setDocumentUsed = FALSE; | 489 | d->setDocumentUsed = FALSE; |
489 | 490 | ||
490 | if(it) { | 491 | if(it) { |
491 | if ( currentTab() == CurrentPlayList ) | 492 | if ( currentTab() == CurrentPlayList ) |
492 | return; | 493 | return; |
493 | DocLnk lnk; | 494 | DocLnk lnk; |
494 | QString filename; | 495 | QString filename; |
495 | 496 | ||
496 | filename=it->text(3); | 497 | filename=it->text(3); |
497 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 498 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
498 | lnk.setFile( filename ); //sets file name | 499 | lnk.setFile( filename ); //sets file name |
499 | d->selectedFiles->addToSelection( lnk); | 500 | d->selectedFiles->addToSelection( lnk); |
500 | 501 | ||
501 | writeCurrentM3u(); | 502 | writeCurrentM3u(); |
502 | // tabWidget->setCurrentPage(0); | 503 | // tabWidget->setCurrentPage(0); |
503 | 504 | ||
504 | } | 505 | } |
505 | } | 506 | } |
506 | 507 | ||
507 | 508 | ||
508 | void PlayListWidget::tabChanged(QWidget *) { | 509 | void PlayListWidget::tabChanged(QWidget *) { |
509 | 510 | ||
510 | d->tbPlay->setEnabled( true ); | 511 | d->tbPlay->setEnabled( true ); |
511 | 512 | ||
512 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 513 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
513 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 514 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
514 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 515 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
515 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 516 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
516 | 517 | ||
517 | currentFileListView = 0; | 518 | currentFileListView = 0; |
518 | 519 | ||
519 | switch ( currentTab() ) { | 520 | switch ( currentTab() ) { |
520 | case CurrentPlayList: | 521 | case CurrentPlayList: |
521 | { | 522 | { |
522 | if( !tbDeletePlaylist->isHidden() ) { | 523 | if( !tbDeletePlaylist->isHidden() ) { |
523 | tbDeletePlaylist->hide(); | 524 | tbDeletePlaylist->hide(); |
524 | } | 525 | } |
525 | d->tbRemoveFromList->setEnabled(TRUE); | 526 | d->tbRemoveFromList->setEnabled(TRUE); |
526 | d->tbAddToList->setEnabled(FALSE); | 527 | d->tbAddToList->setEnabled(FALSE); |
527 | 528 | ||
528 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 529 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
529 | } | 530 | } |
530 | break; | 531 | break; |
531 | case AudioFiles: | 532 | case AudioFiles: |
532 | { | 533 | { |
533 | audioView->populateView(); | 534 | audioView->populateView(); |
534 | 535 | ||
535 | if( !tbDeletePlaylist->isHidden() ) { | 536 | if( !tbDeletePlaylist->isHidden() ) { |
536 | tbDeletePlaylist->hide(); | 537 | tbDeletePlaylist->hide(); |
537 | } | 538 | } |
538 | d->tbRemoveFromList->setEnabled(FALSE); | 539 | d->tbRemoveFromList->setEnabled(FALSE); |
539 | d->tbAddToList->setEnabled(TRUE); | 540 | d->tbAddToList->setEnabled(TRUE); |
540 | 541 | ||
541 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 542 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
542 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 543 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
543 | 544 | ||
544 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 545 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
545 | 546 | ||
546 | currentFileListView = audioView; | 547 | currentFileListView = audioView; |
547 | } | 548 | } |
548 | break; | 549 | break; |
549 | case VideoFiles: | 550 | case VideoFiles: |
550 | { | 551 | { |
551 | videoView->populateView(); | 552 | videoView->populateView(); |
552 | if( !tbDeletePlaylist->isHidden() ) { | 553 | if( !tbDeletePlaylist->isHidden() ) { |
553 | tbDeletePlaylist->hide(); | 554 | tbDeletePlaylist->hide(); |
554 | } | 555 | } |
555 | d->tbRemoveFromList->setEnabled(FALSE); | 556 | d->tbRemoveFromList->setEnabled(FALSE); |
556 | d->tbAddToList->setEnabled(TRUE); | 557 | d->tbAddToList->setEnabled(TRUE); |
557 | 558 | ||
558 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 559 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
559 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 560 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
560 | 561 | ||
561 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 562 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
562 | 563 | ||
563 | currentFileListView = videoView; | 564 | currentFileListView = videoView; |
564 | } | 565 | } |
565 | break; | 566 | break; |
566 | case PlayLists: | 567 | case PlayLists: |
567 | { | 568 | { |
568 | if( tbDeletePlaylist->isHidden() ) { | 569 | if( tbDeletePlaylist->isHidden() ) { |
569 | tbDeletePlaylist->show(); | 570 | tbDeletePlaylist->show(); |
570 | } | 571 | } |
571 | playLists->reread(); | 572 | playLists->reread(); |
572 | d->tbAddToList->setEnabled(FALSE); | 573 | d->tbAddToList->setEnabled(FALSE); |
573 | 574 | ||
574 | d->tbPlay->setEnabled( false ); | 575 | d->tbPlay->setEnabled( false ); |
575 | } | 576 | } |
576 | break; | 577 | break; |
577 | }; | 578 | }; |
578 | } | 579 | } |
579 | 580 | ||
580 | 581 | ||
581 | void PlayListWidget::btnPlay(bool b) { | 582 | void PlayListWidget::btnPlay(bool b) { |
582 | // mediaPlayerState->setPlaying(false); | 583 | // mediaPlayerState->setPlaying(false); |
583 | mediaPlayerState->setPlaying(b); | 584 | mediaPlayerState->setPlaying(b); |
584 | insanityBool=FALSE; | 585 | insanityBool=FALSE; |
585 | } | 586 | } |
586 | 587 | ||
587 | void PlayListWidget::deletePlaylist() { | 588 | void PlayListWidget::deletePlaylist() { |
588 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 589 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
589 | (tr("You really want to delete\nthis playlist?")), | 590 | (tr("You really want to delete\nthis playlist?")), |
590 | (tr("Yes")), (tr("No")), 0 )){ | 591 | (tr("Yes")), (tr("No")), 0 )){ |
591 | case 0: // Yes clicked, | 592 | case 0: // Yes clicked, |
592 | QFile().remove(playLists->selectedDocument().file()); | 593 | QFile().remove(playLists->selectedDocument().file()); |
593 | QFile().remove(playLists->selectedDocument().linkFile()); | 594 | QFile().remove(playLists->selectedDocument().linkFile()); |
594 | playLists->reread(); | 595 | playLists->reread(); |
595 | break; | 596 | break; |
596 | case 1: // Cancel | 597 | case 1: // Cancel |
597 | break; | 598 | break; |
598 | }; | 599 | }; |
599 | } | 600 | } |
600 | 601 | ||
601 | 602 | ||
602 | void PlayListWidget::playSelected() { | 603 | void PlayListWidget::playSelected() { |
603 | btnPlay( TRUE); | 604 | btnPlay( TRUE); |
604 | } | 605 | } |
605 | 606 | ||
606 | bool PlayListWidget::inFileListMode() const | 607 | bool PlayListWidget::inFileListMode() const |
607 | { | 608 | { |
608 | TabType tab = currentTab(); | 609 | TabType tab = currentTab(); |
609 | return tab == AudioFiles || tab == VideoFiles; | 610 | return tab == AudioFiles || tab == VideoFiles; |
610 | } | 611 | } |
611 | 612 | ||
612 | void PlayListWidget::openURL() { | 613 | void PlayListWidget::openURL() { |
613 | // http://66.28.164.33:2080 | 614 | // http://66.28.164.33:2080 |
614 | // http://somafm.com/star0242.m3u | 615 | // http://somafm.com/star0242.m3u |
615 | QString filename, name; | 616 | QString filename, name; |
616 | InputDialog *fileDlg; | 617 | InputDialog *fileDlg; |
617 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 618 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
618 | fileDlg->exec(); | 619 | fileDlg->exec(); |
619 | if( fileDlg->result() == 1 ) { | 620 | if( fileDlg->result() == 1 ) { |
620 | filename = fileDlg->text(); | 621 | filename = fileDlg->text(); |
621 | odebug << "Selected filename is " + filename << oendl; | 622 | odebug << "Selected filename is " + filename << oendl; |
622 | // Om3u *m3uList; | 623 | // Om3u *m3uList; |
623 | DocLnk lnk; | 624 | DocLnk lnk; |
624 | Config cfg( "OpiePlayer" ); | 625 | Config cfg( "OpiePlayer" ); |
625 | cfg.setGroup("PlayList"); | 626 | cfg.setGroup("PlayList"); |
626 | 627 | ||
627 | if(filename.left(4) == "http") { | 628 | if(filename.left(4) == "http") { |
628 | QString m3uFile, m3uFilePath; | 629 | QString m3uFile, m3uFilePath; |
629 | if(filename.find(":",8,TRUE) != -1) { //found a port | 630 | if(filename.find(":",8,TRUE) != -1) { //found a port |
630 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 631 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
631 | m3uFile = m3uFile.right( 7); | 632 | m3uFile = m3uFile.right( 7); |
632 | } else if(filename.left(4) == "http"){ | 633 | } else if(filename.left(4) == "http"){ |
633 | m3uFile=filename; | 634 | m3uFile=filename; |
634 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 635 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
635 | } else{ | 636 | } else{ |
636 | m3uFile=filename; | 637 | m3uFile=filename; |
637 | } | 638 | } |
638 | 639 | ||
639 | lnk.setName( filename ); //sets name | 640 | lnk.setName( filename ); //sets name |
640 | lnk.setFile( filename ); //sets file name | 641 | lnk.setFile( filename ); //sets file name |
641 | 642 | ||
642 | // lnk.setIcon("opieplayer2/musicfile"); | 643 | // lnk.setIcon("opieplayer2/musicfile"); |
643 | 644 | ||
644 | d->selectedFiles->addToSelection( lnk ); | 645 | d->selectedFiles->addToSelection( lnk ); |
645 | writeCurrentM3u(); | 646 | writeCurrentM3u(); |
646 | d->selectedFiles->setSelectedItem( lnk.name()); | 647 | d->selectedFiles->setSelectedItem( lnk.name()); |
647 | } | 648 | } |
648 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 649 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
649 | readListFromFile( filename ); | 650 | readListFromFile( filename ); |
650 | } else { | 651 | } else { |
651 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 652 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
652 | lnk.setFile( filename ); //sets file name | 653 | lnk.setFile( filename ); //sets file name |
653 | d->selectedFiles->addToSelection( lnk); | 654 | d->selectedFiles->addToSelection( lnk); |
654 | writeCurrentM3u(); | 655 | writeCurrentM3u(); |
655 | d->selectedFiles->setSelectedItem( lnk.name()); | 656 | d->selectedFiles->setSelectedItem( lnk.name()); |
656 | } | 657 | } |
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | delete fileDlg; | 661 | delete fileDlg; |
661 | } | 662 | } |
662 | 663 | ||
663 | 664 | ||
664 | void PlayListWidget::openFile() { | 665 | void PlayListWidget::openFile() { |
665 | 666 | ||
666 | QString filename, name; | 667 | QString filename, name; |
667 | 668 | ||
668 | Config cfg( "OpiePlayer" ); | 669 | Config cfg( "OpiePlayer" ); |
669 | cfg.setGroup("Dialog"); | 670 | cfg.setGroup("Dialog"); |
670 | MimeTypes types; | 671 | MimeTypes types; |
671 | QStringList audio, video, all; | 672 | QStringList audio, video, all; |
672 | audio << "audio/*"; | 673 | audio << "audio/*"; |
673 | audio << "playlist/plain"; | 674 | audio << "playlist/plain"; |
674 | audio << "audio/x-ogg"; | 675 | audio << "audio/x-ogg"; |
675 | audio << "audio/x-mpegurl"; | 676 | audio << "audio/x-mpegurl"; |
676 | 677 | ||
677 | video << "video/*"; | 678 | video << "video/*"; |
678 | video << "playlist/plain"; | 679 | video << "playlist/plain"; |
679 | 680 | ||
680 | all += audio; | 681 | all += audio; |
681 | all += video; | 682 | all += video; |
682 | types.insert("All Media Files", all ); | 683 | types.insert("All Media Files", all ); |
683 | types.insert("Audio", audio ); | 684 | types.insert("Audio", audio ); |
684 | types.insert("Video", video ); | 685 | types.insert("Video", video ); |
685 | 686 | ||
686 | QString str = OFileDialog::getOpenFileName( 1, | 687 | QString str = OFileDialog::getOpenFileName( 1, |
687 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 688 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
688 | types, 0 ); | 689 | types, 0 ); |
689 | 690 | ||
690 | if(str.left(2) == "//") { | 691 | if(str.left(2) == "//") { |
691 | str=str.right(str.length()-1); | 692 | str=str.right(str.length()-1); |
692 | } | 693 | } |
693 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 694 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
694 | 695 | ||
695 | if( !str.isEmpty() ) { | 696 | if( !str.isEmpty() ) { |
696 | 697 | ||
697 | odebug << "Selected filename is " + str << oendl; | 698 | odebug << "Selected filename is " + str << oendl; |
698 | filename = str; | 699 | filename = str; |
699 | DocLnk lnk; | 700 | DocLnk lnk; |
700 | 701 | ||
701 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 702 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
702 | readListFromFile( filename ); | 703 | readListFromFile( filename ); |
703 | } else { | 704 | } else { |
704 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 705 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
705 | lnk.setFile( filename ); //sets file name | 706 | lnk.setFile( filename ); //sets file name |
706 | d->selectedFiles->addToSelection( lnk ); | 707 | d->selectedFiles->addToSelection( lnk ); |
707 | writeCurrentM3u(); | 708 | writeCurrentM3u(); |
708 | d->selectedFiles->setSelectedItem( lnk.name() ); | 709 | d->selectedFiles->setSelectedItem( lnk.name() ); |
709 | } | 710 | } |
710 | } | 711 | } |
711 | } | 712 | } |
712 | 713 | ||
713 | 714 | ||
714 | void PlayListWidget::readListFromFile( const QString &filename ) { | 715 | void PlayListWidget::readListFromFile( const QString &filename ) { |
715 | odebug << "read list filename " + filename << oendl; | 716 | odebug << "read list filename " + filename << oendl; |
716 | QFileInfo fi(filename); | 717 | QFileInfo fi(filename); |
717 | Om3u *m3uList; | 718 | Om3u *m3uList; |
718 | QString s, name; | 719 | QString s, name; |
719 | m3uList = new Om3u( filename, IO_ReadOnly ); | 720 | m3uList = new Om3u( filename, IO_ReadOnly ); |
720 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 721 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
721 | m3uList->readM3u(); | 722 | m3uList->readM3u(); |
722 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 723 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
723 | m3uList->readPls(); | 724 | m3uList->readPls(); |
724 | 725 | ||
725 | DocLnk lnk; | 726 | DocLnk lnk; |
726 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 727 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
727 | s = *it; | 728 | s = *it; |
728 | // odebug << s << oendl; | 729 | // odebug << s << oendl; |
729 | if(s.left(4)=="http") { | 730 | if(s.left(4)=="http") { |
730 | lnk.setName( s ); //sets file name | 731 | lnk.setName( s ); //sets file name |
731 | lnk.setIcon("opieplayer2/musicfile"); | 732 | lnk.setIcon("opieplayer2/musicfile"); |
732 | lnk.setFile( s ); //sets file name | 733 | lnk.setFile( s ); //sets file name |
733 | 734 | ||
734 | } else { //is file | 735 | } else { //is file |
735 | lnk.setName( QFileInfo(s).baseName()); | 736 | lnk.setName( QFileInfo(s).baseName()); |
736 | if(s.left(1) != "/") { | 737 | if(s.left(1) != "/") { |
737 | 738 | ||
738 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 739 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
739 | } else { | 740 | } else { |
740 | lnk.setFile( s); | 741 | lnk.setFile( s); |
741 | } | 742 | } |
742 | } | 743 | } |
743 | d->selectedFiles->addToSelection( lnk ); | 744 | d->selectedFiles->addToSelection( lnk ); |
744 | } | 745 | } |
745 | Config config( "OpiePlayer" ); | 746 | Config config( "OpiePlayer" ); |
746 | config.setGroup( "PlayList" ); | 747 | config.setGroup( "PlayList" ); |
747 | 748 | ||
748 | config.writeEntry("CurrentPlaylist",filename); | 749 | config.writeEntry("CurrentPlaylist",filename); |
749 | config.write(); | 750 | config.write(); |
750 | currentPlayList=filename; | 751 | currentPlayList=filename; |
751 | 752 | ||
752 | m3uList->close(); | 753 | m3uList->close(); |
753 | delete m3uList; | 754 | delete m3uList; |
754 | 755 | ||
755 | d->selectedFiles->setSelectedItem( s); | 756 | d->selectedFiles->setSelectedItem( s); |
756 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 757 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
757 | 758 | ||
758 | } | 759 | } |
759 | 760 | ||
760 | // writes current playlist to current m3u file */ | 761 | // writes current playlist to current m3u file */ |
761 | void PlayListWidget::writeCurrentM3u() { | 762 | void PlayListWidget::writeCurrentM3u() { |
762 | odebug << "writing to current m3u" << oendl; | 763 | odebug << "writing to current m3u" << oendl; |
763 | Config cfg( "OpiePlayer" ); | 764 | Config cfg( "OpiePlayer" ); |
764 | cfg.setGroup("PlayList"); | 765 | cfg.setGroup("PlayList"); |
765 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 766 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
766 | 767 | ||
767 | Om3u *m3uList; | 768 | Om3u *m3uList; |
768 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 769 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
769 | if( d->selectedFiles->first()) { | 770 | if( d->selectedFiles->first()) { |
770 | 771 | ||
771 | do { | 772 | do { |
772 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 773 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
773 | m3uList->add( d->selectedFiles->current()->file() ); | 774 | m3uList->add( d->selectedFiles->current()->file() ); |
774 | } | 775 | } |
775 | while ( d->selectedFiles->next() ); | 776 | while ( d->selectedFiles->next() ); |
776 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 777 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
777 | m3uList->write(); | 778 | m3uList->write(); |
778 | m3uList->close(); | 779 | m3uList->close(); |
779 | } | 780 | } |
780 | delete m3uList; | 781 | delete m3uList; |
781 | 782 | ||
782 | } | 783 | } |
783 | 784 | ||
784 | /* | 785 | /* |
785 | writes current playlist to m3u file */ | 786 | writes current playlist to m3u file */ |
786 | void PlayListWidget::writem3u() { | 787 | void PlayListWidget::writem3u() { |
787 | //InputDilog *fileDlg; | 788 | //InputDilog *fileDlg; |
788 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 789 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
789 | //fileDlg->exec(); | 790 | //fileDlg->exec(); |
790 | 791 | ||
791 | Config cfg( "OpiePlayer" ); | 792 | Config cfg( "OpiePlayer" ); |
792 | cfg.setGroup("Dialog"); | 793 | cfg.setGroup("Dialog"); |
793 | MimeTypes types; | 794 | MimeTypes types; |
794 | QStringList audio, video, all; | 795 | QStringList audio, video, all; |
795 | audio << "audio/*"; | 796 | audio << "audio/*"; |
796 | audio << "playlist/plain"; | 797 | audio << "playlist/plain"; |
797 | audio << "audio/x-mpegurl"; | 798 | audio << "audio/x-mpegurl"; |
798 | 799 | ||
799 | video << "video/*"; | 800 | video << "video/*"; |
800 | video << "playlist/plain"; | 801 | video << "playlist/plain"; |
801 | 802 | ||
802 | all += audio; | 803 | all += audio; |
803 | all += video; | 804 | all += video; |
804 | types.insert("All Media Files", all ); | 805 | types.insert("All Media Files", all ); |
805 | types.insert("Audio", audio ); | 806 | types.insert("Audio", audio ); |
806 | types.insert("Video", video ); | 807 | types.insert("Video", video ); |
807 | 808 | ||
808 | QString str = OFileDialog::getOpenFileName( 1, | 809 | QString str = OFileDialog::getOpenFileName( 1, |
809 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 810 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
810 | types, 0 ); | 811 | types, 0 ); |
811 | if(str.left(2) == "//") str=str.right(str.length()-1); | 812 | if(str.left(2) == "//") str=str.right(str.length()-1); |
812 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 813 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
813 | 814 | ||
814 | 815 | ||
815 | QString name, filename, list; | 816 | QString name, filename, list; |
816 | Om3u *m3uList; | 817 | Om3u *m3uList; |
817 | 818 | ||
818 | if( !str.isEmpty() ) { | 819 | if( !str.isEmpty() ) { |
819 | name = str; | 820 | name = str; |
820 | // name = fileDlg->text(); | 821 | // name = fileDlg->text(); |
821 | // odebug << filename << oendl; | 822 | // odebug << filename << oendl; |
822 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 823 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
823 | filename = name; | 824 | filename = name; |
824 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 825 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
825 | } | 826 | } |
826 | else //otherwise dump it somewhere noticable | 827 | else //otherwise dump it somewhere noticable |
827 | filename = QPEApplication::documentDir() + "/" + name; | 828 | filename = QPEApplication::documentDir() + "/" + name; |
828 | 829 | ||
829 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 830 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
830 | filename += ".m3u"; | 831 | filename += ".m3u"; |
831 | 832 | ||
832 | if( d->selectedFiles->first()) { //ramble through playlist view | 833 | if( d->selectedFiles->first()) { //ramble through playlist view |
833 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 834 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
834 | 835 | ||
835 | do { | 836 | do { |
836 | m3uList->add( d->selectedFiles->current()->file()); | 837 | m3uList->add( d->selectedFiles->current()->file()); |
837 | } | 838 | } |
838 | while ( d->selectedFiles->next() ); | 839 | while ( d->selectedFiles->next() ); |
839 | // odebug << list << oendl; | 840 | // odebug << list << oendl; |
840 | m3uList->write(); | 841 | m3uList->write(); |
841 | m3uList->close(); | 842 | m3uList->close(); |
842 | delete m3uList; | 843 | delete m3uList; |
843 | 844 | ||
844 | //delete fileDlg; | 845 | //delete fileDlg; |
845 | 846 | ||
846 | DocLnk lnk; | 847 | DocLnk lnk; |
847 | lnk.setFile( filename); | 848 | lnk.setFile( filename); |
848 | lnk.setIcon("opieplayer2/playlist2"); | 849 | lnk.setIcon("opieplayer2/playlist2"); |
849 | lnk.setName( name); //sets file name | 850 | lnk.setName( name); //sets file name |
850 | 851 | ||
851 | // odebug << filename << oendl; | 852 | // odebug << filename << oendl; |
852 | Config config( "OpiePlayer" ); | 853 | Config config( "OpiePlayer" ); |
853 | config.setGroup( "PlayList" ); | 854 | config.setGroup( "PlayList" ); |
854 | 855 | ||
855 | config.writeEntry("CurrentPlaylist",filename); | 856 | config.writeEntry("CurrentPlaylist",filename); |
856 | currentPlayList=filename; | 857 | currentPlayList=filename; |
857 | 858 | ||
858 | if(!lnk.writeLink()) { | 859 | if(!lnk.writeLink()) { |
859 | odebug << "Writing doclink did not work" << oendl; | 860 | odebug << "Writing doclink did not work" << oendl; |
860 | } | 861 | } |
861 | 862 | ||
862 | setCaption(tr("OpiePlayer: ") + name); | 863 | setCaption(tr("OpiePlayer: ") + name); |
863 | } | 864 | } |
864 | } | 865 | } |
865 | } | 866 | } |
866 | 867 | ||
867 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 868 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
868 | switch ( e->key() ) { | 869 | switch ( e->key() ) { |
869 | ////////////////////////////// Zaurus keys | 870 | ////////////////////////////// Zaurus keys |
870 | case Key_F9: //activity | 871 | case Key_F9: //activity |
871 | // if(audioUI->isHidden()) | 872 | // if(audioUI->isHidden()) |
872 | // audioUI->showMaximized(); | 873 | // audioUI->showMaximized(); |
873 | break; | 874 | break; |
874 | case Key_F10: //contacts | 875 | case Key_F10: //contacts |
875 | // if( videoUI->isHidden()) | 876 | // if( videoUI->isHidden()) |
876 | // videoUI->showMaximized(); | 877 | // videoUI->showMaximized(); |
877 | break; | 878 | break; |
878 | case Key_F11: //menu | 879 | case Key_F11: //menu |
879 | break; | 880 | break; |
880 | case Key_F12: //home | 881 | case Key_F12: //home |
881 | // doBlank(); | 882 | // doBlank(); |
882 | break; | 883 | break; |
883 | case Key_F13: //mail | 884 | case Key_F13: //mail |
884 | // doUnblank(); | 885 | // doUnblank(); |
885 | break; | 886 | break; |
886 | case Key_Q: //add to playlist | 887 | case Key_Q: //add to playlist |
887 | addSelected(); | 888 | addSelected(); |
888 | break; | 889 | break; |
889 | case Key_R: //remove from playlist | 890 | case Key_R: //remove from playlist |
890 | removeSelected(); | 891 | removeSelected(); |
891 | break; | 892 | break; |
892 | // case Key_P: //play | 893 | // case Key_P: //play |
893 | // odebug << "Play" << oendl; | 894 | // odebug << "Play" << oendl; |
894 | // playSelected(); | 895 | // playSelected(); |
895 | // break; | 896 | // break; |
896 | case Key_Space: | 897 | case Key_Space: |
897 | // playSelected(); puh | 898 | // playSelected(); puh |
898 | break; | 899 | break; |
899 | case Key_1: | 900 | case Key_1: |
900 | tabWidget->setCurrentPage( 0 ); | 901 | tabWidget->setCurrentPage( 0 ); |
901 | break; | 902 | break; |
902 | case Key_2: | 903 | case Key_2: |
903 | tabWidget->setCurrentPage( 1 ); | 904 | tabWidget->setCurrentPage( 1 ); |
904 | break; | 905 | break; |
905 | case Key_3: | 906 | case Key_3: |
906 | tabWidget->setCurrentPage( 2 ); | 907 | tabWidget->setCurrentPage( 2 ); |
907 | break; | 908 | break; |
908 | case Key_4: | 909 | case Key_4: |
909 | tabWidget->setCurrentPage( 3 ); | 910 | tabWidget->setCurrentPage( 3 ); |
910 | break; | 911 | break; |
911 | case Key_Down: | 912 | case Key_Down: |
912 | if ( !d->selectedFiles->next() ) | 913 | if ( !d->selectedFiles->next() ) |
913 | d->selectedFiles->first(); | 914 | d->selectedFiles->first(); |
914 | break; | 915 | break; |
915 | case Key_Up: | 916 | case Key_Up: |
916 | if ( !d->selectedFiles->prev() ) | 917 | if ( !d->selectedFiles->prev() ) |
917 | // d->selectedFiles->last(); | 918 | // d->selectedFiles->last(); |
918 | break; | 919 | break; |
919 | } | 920 | } |
920 | } | 921 | } |
921 | 922 | ||
922 | void PlayListWidget::pmViewActivated(int index) { | 923 | void PlayListWidget::pmViewActivated(int index) { |
923 | // odebug << "" << index << "" << oendl; | 924 | // odebug << "" << index << "" << oendl; |
924 | switch(index) { | 925 | switch(index) { |
925 | case -16: | 926 | case -16: |
926 | { | 927 | { |
927 | mediaPlayerState->toggleFullscreen(); | 928 | mediaPlayerState->toggleFullscreen(); |
928 | bool b=mediaPlayerState->isFullscreen(); | 929 | bool b=mediaPlayerState->isFullscreen(); |
929 | pmView->setItemChecked( index, b); | 930 | pmView->setItemChecked( index, b); |
930 | Config cfg( "OpiePlayer" ); | 931 | Config cfg( "OpiePlayer" ); |
931 | cfg.writeEntry( "FullScreen", b ); | 932 | cfg.writeEntry( "FullScreen", b ); |
932 | } | 933 | } |
933 | break; | 934 | break; |
934 | }; | 935 | }; |
935 | } | 936 | } |
936 | 937 | ||
937 | void PlayListWidget::populateSkinsMenu() { | 938 | void PlayListWidget::populateSkinsMenu() { |
938 | int item = 0; | 939 | int item = 0; |
939 | defaultSkinIndex = 0; | 940 | defaultSkinIndex = 0; |
940 | QString skinName; | 941 | QString skinName; |
941 | Config cfg( "OpiePlayer" ); | 942 | Config cfg( "OpiePlayer" ); |
942 | cfg.setGroup("Options" ); | 943 | cfg.setGroup("Options" ); |
943 | QString skin = cfg.readEntry( "Skin", "default" ); | 944 | QString skin = cfg.readEntry( "Skin", "default" ); |
944 | 945 | ||
945 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 946 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
946 | skinsDir.setFilter( QDir::Dirs ); | 947 | skinsDir.setFilter( QDir::Dirs ); |
947 | skinsDir.setSorting(QDir::Name ); | 948 | skinsDir.setSorting(QDir::Name ); |
948 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 949 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
949 | QFileInfoListIterator it( *skinslist ); | 950 | QFileInfoListIterator it( *skinslist ); |
950 | QFileInfo *fi; | 951 | QFileInfo *fi; |
951 | while ( ( fi = it.current() ) ) { | 952 | while ( ( fi = it.current() ) ) { |
952 | skinName = fi->fileName(); | 953 | skinName = fi->fileName(); |
953 | // odebug << fi->fileName() << oendl; | 954 | // odebug << fi->fileName() << oendl; |
954 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 955 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
955 | item = skinsMenu->insertItem( fi->fileName() ) ; | 956 | item = skinsMenu->insertItem( fi->fileName() ) ; |
956 | } | 957 | } |
957 | if( skinName == "default" ) { | 958 | if( skinName == "default" ) { |
958 | defaultSkinIndex = item; | 959 | defaultSkinIndex = item; |
959 | } | 960 | } |
960 | if( skinName == skin ) { | 961 | if( skinName == skin ) { |
961 | skinsMenu->setItemChecked( item, TRUE ); | 962 | skinsMenu->setItemChecked( item, TRUE ); |
962 | } | 963 | } |
963 | ++it; | 964 | ++it; |
964 | } | 965 | } |
965 | } | 966 | } |
966 | 967 | ||
967 | void PlayListWidget::skinsMenuActivated( int item ) { | 968 | void PlayListWidget::skinsMenuActivated( int item ) { |
968 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 969 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
969 | skinsMenu->setItemChecked( i, FALSE ); | 970 | skinsMenu->setItemChecked( i, FALSE ); |
970 | } | 971 | } |
971 | skinsMenu->setItemChecked( item, TRUE ); | 972 | skinsMenu->setItemChecked( item, TRUE ); |
972 | 973 | ||
973 | { | 974 | { |
974 | Config cfg( "OpiePlayer" ); | 975 | Config cfg( "OpiePlayer" ); |
975 | cfg.setGroup("Options"); | 976 | cfg.setGroup("Options"); |
976 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 977 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
977 | } | 978 | } |
978 | 979 | ||
979 | emit skinSelected(); | 980 | emit skinSelected(); |
980 | } | 981 | } |
981 | 982 | ||
982 | PlayListWidget::TabType PlayListWidget::currentTab() const | 983 | PlayListWidget::TabType PlayListWidget::currentTab() const |
983 | { | 984 | { |
984 | static const TabType indexToTabType[ TabTypeCount ] = | 985 | static const TabType indexToTabType[ TabTypeCount ] = |
985 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 986 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
986 | 987 | ||
987 | int index = tabWidget->currentPageIndex(); | 988 | int index = tabWidget->currentPageIndex(); |
988 | assert( index < TabTypeCount && index >= 0 ); | 989 | assert( index < TabTypeCount && index >= 0 ); |
989 | 990 | ||
990 | return indexToTabType[ index ]; | 991 | return indexToTabType[ index ]; |
991 | } | 992 | } |
992 | 993 | ||
993 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 994 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
994 | { | 995 | { |
995 | if ( currentTab() == CurrentPlayList ) { | 996 | if ( currentTab() == CurrentPlayList ) { |
996 | const DocLnk *lnk = current(); | 997 | const DocLnk *lnk = current(); |
997 | return Entry( lnk->name(), lnk->file() ); | 998 | return Entry( lnk->name(), lnk->file() ); |
998 | } | 999 | } |
999 | 1000 | ||
1000 | return Entry( currentFileListPathName() ); | 1001 | return Entry( currentFileListPathName() ); |
1001 | } | 1002 | } |
1002 | 1003 | ||
1003 | QString PlayListWidget::currentFileListPathName() const { | 1004 | QString PlayListWidget::currentFileListPathName() const { |
1004 | return currentFileListView->currentItem()->text( 3 ); | 1005 | return currentFileListView->currentItem()->text( 3 ); |
1005 | } | 1006 | } |
1006 | 1007 | ||
1007 | 1008 | ||
1008 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1009 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1009 | odebug << "qcop message "+msg << oendl; | 1010 | odebug << "qcop message "+msg << oendl; |
1010 | QDataStream stream ( data, IO_ReadOnly ); | 1011 | QDataStream stream ( data, IO_ReadOnly ); |
1011 | if ( msg == "play()" ) { //plays current selection | 1012 | if ( msg == "play()" ) { //plays current selection |
1012 | btnPlay( true); | 1013 | btnPlay( true); |
1013 | } else if ( msg == "stop()" ) { | 1014 | } else if ( msg == "stop()" ) { |
1014 | mediaPlayerState->setPlaying( false); | 1015 | mediaPlayerState->setPlaying( false); |
1015 | } else if ( msg == "togglePause()" ) { | 1016 | } else if ( msg == "togglePause()" ) { |
1016 | mediaPlayerState->togglePaused(); | 1017 | mediaPlayerState->togglePaused(); |
1017 | } else if ( msg == "next()" ) { //select next in list | 1018 | } else if ( msg == "next()" ) { //select next in list |
1018 | mediaPlayerState->setNext(); | 1019 | mediaPlayerState->setNext(); |
1019 | } else if ( msg == "prev()" ) { //select previous in list | 1020 | } else if ( msg == "prev()" ) { //select previous in list |
1020 | mediaPlayerState->setPrev(); | 1021 | mediaPlayerState->setPrev(); |
1021 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1022 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1022 | mediaPlayerState->toggleLooping(); | 1023 | mediaPlayerState->toggleLooping(); |
1023 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1024 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1024 | mediaPlayerState->toggleShuffled(); | 1025 | mediaPlayerState->toggleShuffled(); |
1025 | } else if ( msg == "volUp()" ) { //volume more | 1026 | } else if ( msg == "volUp()" ) { //volume more |
1026 | // emit moreClicked(); | 1027 | // emit moreClicked(); |
1027 | // emit moreReleased(); | 1028 | // emit moreReleased(); |
1028 | } else if ( msg == "volDown()" ) { //volume less | 1029 | } else if ( msg == "volDown()" ) { //volume less |
1029 | // emit lessClicked(); | 1030 | // emit lessClicked(); |
1030 | // emit lessReleased(); | 1031 | // emit lessReleased(); |
1031 | } else if ( msg == "play(QString)" ) { //play this now | 1032 | } else if ( msg == "play(QString)" ) { //play this now |
1032 | QString file; | 1033 | QString file; |
1033 | stream >> file; | 1034 | stream >> file; |
1034 | setDocument( (const QString &) file); | 1035 | setDocument( (const QString &) file); |
1035 | } else if ( msg == "add(QString)" ) { //add to playlist | 1036 | } else if ( msg == "add(QString)" ) { //add to playlist |
1036 | QString file; | 1037 | QString file; |
1037 | stream >> file; | 1038 | stream >> file; |
1038 | QFileInfo fileInfo(file); | 1039 | QFileInfo fileInfo(file); |
1039 | DocLnk lnk; | 1040 | DocLnk lnk; |
1040 | lnk.setName( fileInfo.baseName() ); //sets name | 1041 | lnk.setName( fileInfo.baseName() ); //sets name |
1041 | lnk.setFile( file ); //sets file name | 1042 | lnk.setFile( file ); //sets file name |
1042 | addToSelection( lnk ); | 1043 | addToSelection( lnk ); |
1043 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1044 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1044 | QString file; | 1045 | QString file; |
1045 | stream >> file; | 1046 | stream >> file; |
1046 | 1047 | ||
1047 | } | 1048 | } |
1048 | 1049 | ||
1049 | } | 1050 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index e1816c8..c47a773 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,274 +1,282 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include "xinecontrol.h" | 34 | #include "xinecontrol.h" |
35 | #include "xinevideowidget.h" | 35 | #include "xinevideowidget.h" |
36 | 36 | ||
37 | /* OPIE */ | 37 | /* OPIE */ |
38 | #include <opie2/odebug.h> | 38 | #include <opie2/odebug.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | using namespace Opie::Core; | 41 | using namespace Opie::Core; |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | 46 | ||
47 | XineControl::XineControl( XineVideoWidget *xineWidget, | ||
48 | MediaPlayerState &_mediaPlayerState, | ||
49 | QObject *parent, const char *name ) | ||
50 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | ||
51 | { | ||
52 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); | ||
53 | |||
54 | init(); | ||
55 | } | ||
56 | |||
57 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 47 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
58 | MediaPlayerState &_mediaPlayerState, | 48 | MediaPlayerState &_mediaPlayerState, |
59 | QObject *parent, const char *name ) | 49 | QObject *parent, const char *name ) |
60 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 50 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
61 | { | 51 | { |
52 | m_wasError = false; | ||
53 | |||
62 | xine->ensureInitialized(); | 54 | xine->ensureInitialized(); |
63 | 55 | ||
64 | xine->setWidget( xineWidget ); | 56 | xine->setWidget( xineWidget ); |
65 | 57 | ||
66 | init(); | 58 | init(); |
67 | } | 59 | } |
68 | 60 | ||
69 | void XineControl::init() | 61 | void XineControl::init() |
70 | { | 62 | { |
71 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 63 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
72 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); | 64 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); |
73 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); | 65 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); |
74 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); | 66 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); |
75 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); | 67 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); |
76 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); | 68 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); |
77 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 69 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
78 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); | 70 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); |
79 | 71 | ||
80 | disabledSuspendScreenSaver = FALSE; | 72 | disabledSuspendScreenSaver = FALSE; |
81 | } | 73 | } |
82 | 74 | ||
83 | XineControl::~XineControl() { | 75 | XineControl::~XineControl() { |
84 | #if !defined(QT_NO_COP) | 76 | #if !defined(QT_NO_COP) |
85 | if ( disabledSuspendScreenSaver ) { | 77 | if ( disabledSuspendScreenSaver ) { |
86 | disabledSuspendScreenSaver = FALSE; | 78 | disabledSuspendScreenSaver = FALSE; |
87 | // Re-enable the suspend mode | 79 | // Re-enable the suspend mode |
88 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
89 | } | 81 | } |
90 | #endif | 82 | #endif |
91 | delete libXine; | 83 | delete libXine; |
92 | } | 84 | } |
93 | 85 | ||
94 | void XineControl::play( const QString& fileName ) { | 86 | void XineControl::play( const QString& fileName ) { |
95 | 87 | ||
96 | hasVideoChannel = FALSE; | 88 | hasVideoChannel = FALSE; |
97 | hasAudioChannel = FALSE; | 89 | hasAudioChannel = FALSE; |
98 | m_fileName = fileName; | 90 | m_fileName = fileName; |
91 | m_wasError = false; | ||
99 | 92 | ||
100 | odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; | ||
101 | 93 | ||
94 | /* | ||
95 | * If Playing Fails we will fire up an MessgaeBox | ||
96 | * but present the AudioWidget so the User can | ||
97 | * either Quit and change the Playlist or Continue | ||
98 | */ | ||
102 | if ( !libXine->play( fileName, 0, 0 ) ) { | 99 | if ( !libXine->play( fileName, 0, 0 ) ) { |
103 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 100 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
104 | // toggle stop so the the play button is reset | 101 | m_wasError = true; |
105 | mediaPlayerState.setPlaying( false ); | ||
106 | return; | ||
107 | } | 102 | } |
108 | mediaPlayerState.setPlaying( true ); | 103 | mediaPlayerState.setPlaying( true ); |
109 | 104 | ||
110 | MediaPlayerState::DisplayType displayType; | 105 | MediaPlayerState::DisplayType displayType; |
111 | if ( !libXine->hasVideo() ) { | 106 | if ( !libXine->hasVideo() ) { |
112 | displayType = MediaPlayerState::Audio; | 107 | displayType = MediaPlayerState::Audio; |
113 | libXine->setShowVideo( false ); | 108 | libXine->setShowVideo( false ); |
114 | hasAudioChannel = TRUE; | 109 | hasAudioChannel = TRUE; |
115 | } else { | 110 | } else { |
116 | displayType = MediaPlayerState::Video; | 111 | displayType = MediaPlayerState::Video; |
117 | libXine->setShowVideo( true ); | 112 | libXine->setShowVideo( true ); |
118 | hasVideoChannel = TRUE; | 113 | hasVideoChannel = TRUE; |
119 | } | 114 | } |
120 | // determine if slider is shown | 115 | // determine if slider is shown |
121 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 116 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
122 | 117 | ||
123 | // which gui (video / audio) | 118 | // which gui (video / audio) |
124 | mediaPlayerState.setDisplayType( displayType ); | 119 | mediaPlayerState.setDisplayType( displayType ); |
125 | 120 | ||
126 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 121 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
127 | if ( !disabledSuspendScreenSaver ) { | 122 | if ( !disabledSuspendScreenSaver ) { |
128 | disabledSuspendScreenSaver = TRUE; | 123 | disabledSuspendScreenSaver = TRUE; |
129 | // Stop the screen from blanking and power saving state | 124 | // Stop the screen from blanking and power saving state |
130 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 125 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
131 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 126 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
132 | } | 127 | } |
133 | #endif | 128 | #endif |
134 | 129 | ||
135 | length(); | 130 | length(); |
136 | position(); | 131 | position(); |
137 | } | 132 | } |
138 | 133 | ||
139 | void XineControl::nextMedia() { | 134 | void XineControl::nextMedia() { |
140 | mediaPlayerState.setNext(); | 135 | mediaPlayerState.setNext(); |
141 | } | 136 | } |
142 | 137 | ||
143 | void XineControl::setGamma( int value ) { | 138 | void XineControl::setGamma( int value ) { |
144 | libXine->setGamma( value ); | 139 | libXine->setGamma( value ); |
145 | } | 140 | } |
146 | 141 | ||
147 | void XineControl::stop( bool isSet ) { | 142 | void XineControl::stop( bool isSet ) { |
148 | if ( !isSet ) { | 143 | if ( !isSet ) { |
149 | libXine->stop(); | 144 | libXine->stop(); |
150 | 145 | ||
151 | #if !defined(QT_NO_COP) | 146 | #if !defined(QT_NO_COP) |
152 | if ( disabledSuspendScreenSaver ) { | 147 | if ( disabledSuspendScreenSaver ) { |
153 | disabledSuspendScreenSaver = FALSE; | 148 | disabledSuspendScreenSaver = FALSE; |
154 | // Re-enable the suspend mode | 149 | // Re-enable the suspend mode |
155 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 150 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
156 | } | 151 | } |
157 | #endif | 152 | #endif |
158 | } | 153 | } |
159 | } | 154 | } |
160 | 155 | ||
161 | /** | 156 | /** |
162 | * Pause playback | 157 | * Pause playback |
163 | * @isSet | 158 | * @isSet |
164 | */ | 159 | */ |
165 | void XineControl::pause( bool isSet) { | 160 | void XineControl::pause( bool isSet) { |
166 | libXine->pause( isSet ); | 161 | libXine->pause( isSet ); |
167 | } | 162 | } |
168 | 163 | ||
169 | 164 | ||
170 | /** | 165 | /** |
171 | * get current time in playback | 166 | * get current time in playback |
172 | */ | 167 | */ |
173 | long XineControl::currentTime() { | 168 | long XineControl::currentTime() { |
174 | // todo: jede sekunde überprüfen | 169 | // todo: jede sekunde überprüfen |
175 | m_currentTime = libXine->currentTime(); | 170 | m_currentTime = libXine->currentTime(); |
176 | return m_currentTime; | 171 | return m_currentTime; |
177 | } | 172 | } |
178 | 173 | ||
179 | /** | 174 | /** |
180 | * Set the length of the media file | 175 | * Set the length of the media file |
181 | */ | 176 | */ |
182 | void XineControl::length() { | 177 | void XineControl::length() { |
183 | m_length = libXine->length(); | 178 | m_length = libXine->length(); |
184 | mediaPlayerState.setLength( m_length ); | 179 | mediaPlayerState.setLength( m_length ); |
185 | } | 180 | } |
186 | 181 | ||
187 | 182 | ||
188 | /** | 183 | /** |
189 | * Reports the position the xine backend is at right now | 184 | * Reports the position the xine backend is at right now |
190 | * @return long the postion in seconds | 185 | * @return long the postion in seconds |
191 | */ | 186 | */ |
192 | long XineControl::position() { | 187 | long XineControl::position() { |
193 | m_position = ( currentTime() ); | 188 | m_position = ( currentTime() ); |
194 | mediaPlayerState.updatePosition( m_position ); | 189 | mediaPlayerState.updatePosition( m_position ); |
195 | long emitPos = (long)m_position; | 190 | long emitPos = (long)m_position; |
196 | emit positionChanged( emitPos ); | 191 | emit positionChanged( emitPos ); |
197 | if( mediaPlayerState.isPlaying() ) { | 192 | if( mediaPlayerState.isPlaying() ) { |
198 | // needs to be stopped the media is stopped | 193 | // needs to be stopped the media is stopped |
199 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 194 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
200 | } | 195 | } |
201 | return m_position; | 196 | return m_position; |
202 | } | 197 | } |
203 | 198 | ||
204 | /** | 199 | /** |
205 | * Set videoplayback to fullscreen | 200 | * Set videoplayback to fullscreen |
206 | * @param isSet | 201 | * @param isSet |
207 | */ | 202 | */ |
208 | void XineControl::setFullscreen( bool isSet ) { | 203 | void XineControl::setFullscreen( bool isSet ) { |
209 | libXine->showVideoFullScreen( isSet ); | 204 | libXine->showVideoFullScreen( isSet ); |
210 | } | 205 | } |
211 | 206 | ||
212 | 207 | ||
213 | QString XineControl::getMetaInfo() { | 208 | QString XineControl::getMetaInfo() { |
214 | 209 | ||
215 | QString returnString; | 210 | QString returnString; |
216 | 211 | ||
212 | /* | ||
213 | * If there was an error let us | ||
214 | * change the Meta Info to contain the Error Message | ||
215 | */ | ||
216 | if ( m_wasError ) { | ||
217 | returnString = tr("Error on file '%1' with reason: ", | ||
218 | "Error when playing a file" ).arg( m_fileName ); | ||
219 | returnString += getErrorCode(); | ||
220 | returnString.replace( QRegExp("<qt>", false), "" ); | ||
221 | returnString.replace( QRegExp("</qt>", false), "" ); | ||
222 | return returnString; | ||
223 | } | ||
224 | |||
217 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 225 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
218 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 226 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
219 | } | 227 | } |
220 | 228 | ||
221 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 229 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
222 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 230 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
223 | } | 231 | } |
224 | 232 | ||
225 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 233 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
226 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 234 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
227 | } | 235 | } |
228 | 236 | ||
229 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 237 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
230 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 238 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
231 | } | 239 | } |
232 | 240 | ||
233 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 241 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
234 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 242 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
235 | } | 243 | } |
236 | 244 | ||
237 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 245 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
238 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 246 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
239 | } | 247 | } |
240 | return returnString; | 248 | return returnString; |
241 | } | 249 | } |
242 | 250 | ||
243 | QString XineControl::getErrorCode() { | 251 | QString XineControl::getErrorCode() { |
244 | 252 | ||
245 | int errorCode = libXine->error(); | 253 | int errorCode = libXine->error(); |
246 | 254 | ||
247 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; | 255 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; |
248 | 256 | ||
249 | if ( errorCode == 1 ) { | 257 | if ( errorCode == 1 ) { |
250 | return tr( "No input plugin found for this media type" ); | 258 | return tr( "<qt>No input plugin found for this media type</qt>" ); |
251 | } else if ( errorCode == 2 ) { | 259 | } else if ( errorCode == 2 ) { |
252 | return tr( "No demux plugin found for this media type" ); | 260 | return tr( "<qt>No demux plugin found for this media type</qt>" ); |
253 | } else if ( errorCode == 3 ) { | 261 | } else if ( errorCode == 3 ) { |
254 | return tr( "Demuxing failed for this media type" ); | 262 | return tr( "<qt>Demuxing failed for this media type</qt>" ); |
255 | } else if ( errorCode == 4 ) { | 263 | } else if ( errorCode == 4 ) { |
256 | return tr( "Malformed MRL" ); | 264 | return tr( "<qt>Malformed MRL</qt>" ); |
257 | } else if ( errorCode == 5 ) { | 265 | } else if ( errorCode == 5 ) { |
258 | return tr( "Input failed" ); | 266 | return tr( "<qt>Input failed</qt>" ); |
259 | } else { | 267 | } else { |
260 | return tr( "Some other error" ); | 268 | return tr( "<qt>Some other error</qt>" ); |
261 | } | 269 | } |
262 | } | 270 | } |
263 | 271 | ||
264 | /** | 272 | /** |
265 | * Seek to a position in the track | 273 | * Seek to a position in the track |
266 | * @param second the second to jump to | 274 | * @param second the second to jump to |
267 | */ | 275 | */ |
268 | void XineControl::seekTo( long second ) { | 276 | void XineControl::seekTo( long second ) { |
269 | libXine->seekTo( (int)second ); | 277 | libXine->seekTo( (int)second ); |
270 | } | 278 | } |
271 | 279 | ||
272 | void XineControl::videoResized ( const QSize &s ) { | 280 | void XineControl::videoResized ( const QSize &s ) { |
273 | libXine->resize( s ); | 281 | libXine->resize( s ); |
274 | } | 282 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 3f44f2e..848bd05 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,126 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | 38 | ||
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | 40 | ||
41 | class XineControl : public QObject { | 41 | class XineControl : public QObject { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | XineControl( XineVideoWidget *xineWidget, | ||
45 | MediaPlayerState &_mediaPlayerState, | ||
46 | QObject *parent = 0, const char *name =0 ); | ||
47 | // note that this constructor takes over ownership of the passed | 44 | // note that this constructor takes over ownership of the passed |
48 | // XINE::Lib object. | 45 | // XINE::Lib object. |
49 | XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 46 | XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
50 | MediaPlayerState &_mediaPlayerState, | 47 | MediaPlayerState &_mediaPlayerState, |
51 | QObject *parent = 0, const char *name =0 ); | 48 | QObject *parent = 0, const char *name =0 ); |
52 | ~XineControl(); | 49 | ~XineControl(); |
53 | 50 | ||
54 | bool hasVideo() const { return hasVideoChannel; } | 51 | bool hasVideo() const { return hasVideoChannel; } |
55 | bool hasAudio() const { return hasAudioChannel; } | 52 | bool hasAudio() const { return hasAudioChannel; } |
56 | 53 | ||
57 | public slots: | 54 | public slots: |
58 | void play( const QString& fileName ); | 55 | void play( const QString& fileName ); |
59 | void stop( bool ); | 56 | void stop( bool ); |
60 | 57 | ||
61 | /** | 58 | /** |
62 | * Pause the media stream | 59 | * Pause the media stream |
63 | * @param if pause or not | 60 | * @param if pause or not |
64 | */ | 61 | */ |
65 | void pause( bool ); | 62 | void pause( bool ); |
66 | 63 | ||
67 | /** | 64 | /** |
68 | * Set videos fullscreen | 65 | * Set videos fullscreen |
69 | * @param yes or no | 66 | * @param yes or no |
70 | */ | 67 | */ |
71 | void setFullscreen( bool ); | 68 | void setFullscreen( bool ); |
72 | 69 | ||
73 | /** | 70 | /** |
74 | * | 71 | * |
75 | */ | 72 | */ |
76 | long currentTime(); | 73 | long currentTime(); |
77 | void seekTo( long ); | 74 | void seekTo( long ); |
78 | // get length of media file and set it | 75 | // get length of media file and set it |
79 | void length(); | 76 | void length(); |
80 | long position(); | 77 | long position(); |
81 | 78 | ||
82 | /** | 79 | /** |
83 | * Proceed to the next media file in playlist | 80 | * Proceed to the next media file in playlist |
84 | */ | 81 | */ |
85 | void nextMedia(); | 82 | void nextMedia(); |
86 | 83 | ||
87 | /** | 84 | /** |
88 | * Get as much info about the stream from xine as possible | 85 | * Get as much info about the stream from xine as possible |
89 | */ | 86 | */ |
90 | QString getMetaInfo(); | 87 | QString getMetaInfo(); |
91 | 88 | ||
92 | /** | 89 | /** |
93 | * get the error code and "translate" it for the user | 90 | * get the error code and "translate" it for the user |
94 | * | 91 | * |
95 | */ | 92 | */ |
96 | QString getErrorCode(); | 93 | QString getErrorCode(); |
97 | 94 | ||
98 | 95 | ||
99 | void videoResized ( const QSize &s ); | 96 | void videoResized ( const QSize &s ); |
100 | 97 | ||
101 | /** | 98 | /** |
102 | * Set the gamma value of the video output | 99 | * Set the gamma value of the video output |
103 | * @param int value between -100 and 100, 0 is original | 100 | * @param int value between -100 and 100, 0 is original |
104 | */ | 101 | */ |
105 | void setGamma( int ); | 102 | void setGamma( int ); |
106 | 103 | ||
107 | private: | 104 | private: |
108 | void init(); | 105 | void init(); |
109 | 106 | ||
110 | XINE::Lib *libXine; | 107 | XINE::Lib *libXine; |
111 | long m_currentTime; | 108 | long m_currentTime; |
112 | long m_position; | 109 | long m_position; |
113 | int m_length; | 110 | int m_length; |
114 | QString m_fileName; | 111 | QString m_fileName; |
115 | bool disabledSuspendScreenSaver : 1; | 112 | bool disabledSuspendScreenSaver : 1; |
116 | bool hasVideoChannel : 1; | 113 | bool hasVideoChannel : 1; |
117 | bool hasAudioChannel : 1; | 114 | bool hasAudioChannel : 1; |
118 | MediaPlayerState &mediaPlayerState; | 115 | MediaPlayerState &mediaPlayerState; |
119 | XineVideoWidget *xineVideoWidget; | 116 | XineVideoWidget *xineVideoWidget; |
117 | bool m_wasError : 1; // used for chaeting on the metainfo | ||
120 | 118 | ||
121 | signals: | 119 | signals: |
122 | void positionChanged( long ); | 120 | void positionChanged( long ); |
123 | }; | 121 | }; |
124 | 122 | ||
125 | 123 | ||
126 | #endif | 124 | #endif |