summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.cpp33
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.h4
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.cpp180
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.h16
-rw-r--r--noncore/multimedia/opieplayer3/opieplayer3.pro4
-rw-r--r--noncore/multimedia/opieplayer3/playlist.cpp131
-rw-r--r--noncore/multimedia/opieplayer3/playlist.h8
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.cpp39
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.h4
9 files changed, 353 insertions, 66 deletions
diff --git a/noncore/multimedia/opieplayer3/audiowidget.cpp b/noncore/multimedia/opieplayer3/audiowidget.cpp
index 7ba6274..b435c1b 100644
--- a/noncore/multimedia/opieplayer3/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer3/audiowidget.cpp
@@ -14,75 +14,91 @@ AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f)
14{ 14{
15 m_xineLib = 0; 15 m_xineLib = 0;
16 16
17 m_MainLayout = new QVBoxLayout(this); 17 m_MainLayout = new QVBoxLayout(this);
18 m_MainLayout->setAutoAdd(true); 18 m_MainLayout->setAutoAdd(true);
19 m_InfoBox = new QTextView(this); 19 m_InfoBox = new QTextView(this);
20#if 0
20 m_PosSlider = new QSlider(QSlider::Horizontal,this); 21 m_PosSlider = new QSlider(QSlider::Horizontal,this);
21 m_PosSlider->setTickInterval(60); 22 m_PosSlider->setTickInterval(60);
22 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); 23 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
23 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); 24 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
24 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); 25 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
25 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); 26 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
26 m_pressed = false; 27 m_pressed = false;
27 m_uppos=0; 28 m_uppos=0;
29#endif
28} 30}
29 31
30AudioWidget::~AudioWidget() 32AudioWidget::~AudioWidget()
31{ 33{
32} 34}
33 35
34void AudioWidget::slotNewPos(int pos) 36void AudioWidget::slotNewPos(int /* pos*/)
35{ 37{
36 if (!m_xineLib) return; 38 if (!m_xineLib) return;
39#if 0
37 if (m_uppos==pos) return; 40 if (m_uppos==pos) return;
38 m_xineLib->seekTo(pos); 41 m_xineLib->seekTo(pos);
42#endif
39} 43}
40 44
41void AudioWidget::sliderPressed() 45void AudioWidget::sliderPressed()
42{ 46{
47#if 0
43 m_pressed = true; 48 m_pressed = true;
49#endif
44} 50}
45 51
46void AudioWidget::sliderReleased() 52void AudioWidget::sliderReleased()
47{ 53{
54#if 0
48 m_pressed = false; 55 m_pressed = false;
56#endif
49} 57}
50 58
51void AudioWidget::closeEvent(QCloseEvent*e) 59void AudioWidget::closeEvent(QCloseEvent*e)
52{ 60{
53 odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl; 61 odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl;
54 if (m_xineLib) { 62 if (m_xineLib) {
55 m_xineLib->stop(); 63 m_xineLib->stop();
56 } 64 }
57 QWidget::closeEvent(e); 65 QWidget::closeEvent(e);
58} 66}
59 67
60void AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) 68int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
61{ 69{
62 m_current = aLnk; 70 m_current = aLnk;
63 if (m_xineLib != aLib) { 71 if (m_xineLib != aLib) {
64 disconnect(m_xineLib); 72 if (m_xineLib) disconnect(m_xineLib);
65 m_xineLib = aLib; 73 m_xineLib = aLib;
66 } 74 }
67 if (!m_xineLib) { 75 if (!m_xineLib) {
68 return; 76 return -1;
69 } 77 }
78#if 0
70 m_uppos=0; 79 m_uppos=0;
71 m_PosSlider->setValue(0); 80 m_PosSlider->setValue(0);
81#endif
72 m_xineLib->setShowVideo(false); 82 m_xineLib->setShowVideo(false);
73 m_xineLib->play(m_current.file()); 83 int res = m_xineLib->play(m_current.file());
84 if (res != 1) {
85 return -2;
86 }
74 // title 87 // title
75 QString title = m_xineLib->metaInfo(0); 88 QString title = m_xineLib->metaInfo(0);
76 // artist 89 // artist
77 QString artist = m_xineLib->metaInfo(2); 90 QString artist = m_xineLib->metaInfo(2);
78 // album 91 // album
79 QString album = m_xineLib->metaInfo(4); 92 QString album = m_xineLib->metaInfo(4);
80 93
81 int l = m_xineLib->length(); 94 int l = m_xineLib->length();
95 int tmp = l;
96#if 0
82 m_PosSlider->setRange(0,l); 97 m_PosSlider->setRange(0,l);
98#endif
83 QString laenge=""; 99 QString laenge="";
84 int h = l/3600; 100 int h = l/3600;
85 l-=h*3600; 101 l-=h*3600;
86 int m = l/60; 102 int m = l/60;
87 l-=m*60; 103 l-=m*60;
88 if (h>0) { 104 if (h>0) {
@@ -99,27 +115,32 @@ void AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
99 QString text = "<qt>"; 115 QString text = "<qt>";
100 if (artist.length()) { 116 if (artist.length()) {
101 text+="<H2><center>"+artist+"</center></h2>"; 117 text+="<H2><center>"+artist+"</center></h2>";
102 } 118 }
103 if (title.length()) { 119 if (title.length()) {
104 text+="<H2><center>"+title+"</center></h2>"; 120 text+="<H2><center>"+title+"</center></h2>";
121 } else {
122 text+="<H2><center>"+m_current.name()+"</center></h2>";
105 } 123 }
106 if (album.length()) { 124 if (album.length()) {
107 text+="<H2><center>"+album+"</center></h2>"; 125 text+="<H2><center>"+album+"</center></h2>";
108 } 126 }
109 text+="<h3><center>"+laenge+"</center></h3>"; 127 text+="<h3><center>"+laenge+"</center></h3>";
110 m_InfoBox->setText(text); 128 m_InfoBox->setText(text);
129 return tmp;
111} 130}
112 131
113void AudioWidget::stopPlaying() 132void AudioWidget::stopPlaying()
114{ 133{
115 if (m_xineLib) { 134 if (m_xineLib) {
116 m_xineLib->stop(); 135 m_xineLib->stop();
117 } 136 }
118} 137}
119 138
120void AudioWidget::updatePos(int val) 139void AudioWidget::updatePos(int /* val */)
121{ 140{
141#if 0
122 if (m_pressed) return; 142 if (m_pressed) return;
123 m_uppos = val; 143 m_uppos = val;
124 m_PosSlider->setValue(val); 144 m_PosSlider->setValue(val);
145#endif
125} 146}
diff --git a/noncore/multimedia/opieplayer3/audiowidget.h b/noncore/multimedia/opieplayer3/audiowidget.h
index 07b51b6..5e5dc09 100644
--- a/noncore/multimedia/opieplayer3/audiowidget.h
+++ b/noncore/multimedia/opieplayer3/audiowidget.h
@@ -18,26 +18,28 @@ class AudioWidget:public QWidget
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20public: 20public:
21 AudioWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); 21 AudioWidget( QWidget * parent=0, const char * name=0, WFlags f=0 );
22 virtual ~AudioWidget(); 22 virtual ~AudioWidget();
23 23
24 void playFile(const DocLnk&,XINE::Lib*); 24 int playFile(const DocLnk&,XINE::Lib*);
25 25
26public slots: 26public slots:
27 virtual void stopPlaying(); 27 virtual void stopPlaying();
28 virtual void updatePos(int); 28 virtual void updatePos(int);
29 29
30protected: 30protected:
31 XINE::Lib*m_xineLib; 31 XINE::Lib*m_xineLib;
32 DocLnk m_current; 32 DocLnk m_current;
33 QVBoxLayout*m_MainLayout; 33 QVBoxLayout*m_MainLayout;
34 QTextView*m_InfoBox; 34 QTextView*m_InfoBox;
35#if 0
35 QSlider*m_PosSlider; 36 QSlider*m_PosSlider;
36 bool m_pressed; 37 bool m_pressed;
37 int m_uppos; 38 int m_uppos;
39#endif
38 40
39protected slots: 41protected slots:
40 virtual void closeEvent(QCloseEvent*e); 42 virtual void closeEvent(QCloseEvent*e);
41 virtual void slotNewPos(int pos); 43 virtual void slotNewPos(int pos);
42 virtual void sliderPressed(); 44 virtual void sliderPressed();
43 virtual void sliderReleased(); 45 virtual void sliderReleased();
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp
index dab910a..57418f0 100644
--- a/noncore/multimedia/opieplayer3/mwindow.cpp
+++ b/noncore/multimedia/opieplayer3/mwindow.cpp
@@ -47,31 +47,38 @@
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qtoolbar.h> 49#include <qtoolbar.h>
50#include <qpopupmenu.h> 50#include <qpopupmenu.h>
51#include <qmenubar.h> 51#include <qmenubar.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qslider.h>
54#include <qlayout.h>
53 55
54OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 56OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
55 57
56using namespace Opie::Ui; 58using namespace Opie::Ui;
57 59
58PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) 60PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
59 : QMainWindow(w,name,f) 61 : QMainWindow(w,name,f)
60{ 62{
61 setCaption( QObject::tr("Opie Mediaplayer 3" ) ); 63 setCaption( QObject::tr("Opie Mediaplayer 3" ) );
62 setupActions();
63 setupToolBar();
64 setupMenu();
65 64
66 m_stack = new OWidgetStack(this); 65 m_MainBox = new QWidget(this);
66
67 QVBoxLayout*m_l = new QVBoxLayout(m_MainBox);
68
69 m_stack = new OWidgetStack(m_MainBox);
67 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 70 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
68 setCentralWidget(m_stack ); 71 m_l->addWidget(m_stack);
72 m_scrollBar = new QSlider(QSlider::Horizontal,m_MainBox);
73 m_l->addWidget(m_scrollBar);
74 m_scrollBar->setEnabled(false);
75
69 m_playList = new PlaylistView(m_stack,"playlist"); 76 m_playList = new PlaylistView(m_stack,"playlist");
70 m_stack->addWidget(m_playList,stack_list); 77 m_stack->addWidget(m_playList,stack_list);
71 78 connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int)));
72 m_sfl = new OFileSelector("video/*;audio/*",m_stack); 79 m_sfl = new OFileSelector("video/*;audio/*",m_stack);
73 m_stack->addWidget(m_sfl,stack_file); 80 m_stack->addWidget(m_sfl,stack_file);
74 connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); 81 connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &)));
75 m_AudioPlayer = new AudioWidget(m_stack); 82 m_AudioPlayer = new AudioWidget(m_stack);
76 m_stack->addWidget(m_AudioPlayer,stack_audio); 83 m_stack->addWidget(m_AudioPlayer,stack_audio);
77 connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); 84 connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int)));
@@ -80,12 +87,34 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
80 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); 87 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int)));
81 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); 88 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
82 89
83 m_stack->raiseWidget(stack_list); 90 m_stack->raiseWidget(stack_list);
84 m_PlayLib = 0; 91 m_PlayLib = 0;
85 m_LastItem = 0; 92 m_LastItem = 0;
93 setupActions();
94 setupToolBar();
95 setupMenu();
96
97 setCentralWidget(m_MainBox );
98}
99
100void PMainWindow::slotListChanged(int count)
101{
102 if (!m_playList->isVisible()) {
103 return;
104 }
105 a_removeFiles->setEnabled(count>0);
106}
107
108void PMainWindow::mediaWindowraised()
109{
110 playlistOnly->setEnabled(false);
111 a_appendFiles->setEnabled(true);
112 a_loadPlaylist->setEnabled(true);
113 a_showPlaylist->setEnabled(true);
114 a_ShowMedia->setEnabled(false);
86} 115}
87 116
88void PMainWindow::checkLib() 117void PMainWindow::checkLib()
89{ 118{
90 if (m_PlayLib == 0) { 119 if (m_PlayLib == 0) {
91 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately); 120 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately);
@@ -106,71 +135,136 @@ void PMainWindow::fileSelected(const DocLnk&)
106{ 135{
107} 136}
108 137
109void PMainWindow::slotAppendFiles() 138void PMainWindow::slotAppendFiles()
110{ 139{
111 m_stack->raiseWidget(m_sfl); 140 m_stack->raiseWidget(m_sfl);
141 playlistOnly->setEnabled(false);
142
143 a_showPlaylist->setEnabled(true);
144 if (m_PlayLib && m_playing) {
145 a_ShowMedia->setEnabled(true);
146 } else {
147 a_ShowMedia->setEnabled(false);
148 }
112} 149}
113 150
114void PMainWindow::slotShowList() 151void PMainWindow::slotShowList()
115{ 152{
116 m_stack->raiseWidget(m_playList); 153 m_stack->raiseWidget(m_playList);
154 playlistOnly->setEnabled(true);
155 a_showPlaylist->setEnabled(false);
156 if (m_playList->childCount()) {
157 a_removeFiles->setEnabled(true);
158 } else {
159 a_removeFiles->setEnabled(false);
160 }
161 if (m_PlayLib && m_playing) {
162 a_ShowMedia->setEnabled(true);
163 } else {
164 a_ShowMedia->setEnabled(false);
165 }
117} 166}
118 167
119void PMainWindow::slotPlayList() 168void PMainWindow::slotShowMediaWindow()
120{ 169{
121 if (m_playing && m_LastItem && m_PlayLib) { 170 if (m_playing && m_LastItem && m_PlayLib) {
122 if (!m_LastItem->isVideo()) { 171 if (!m_LastItem->isVideo()) {
123 m_stack->raiseWidget(stack_audio); 172 m_stack->raiseWidget(stack_audio);
124 } else { 173 } else {
125 m_stack->raiseWidget(stack_video); 174 m_stack->raiseWidget(stack_video);
126 } 175 }
176 mediaWindowraised();
177 return;
178 }
179}
180
181void PMainWindow::slotPlayList()
182{
183 if (m_playing && m_LastItem && m_PlayLib) {
184 slotShowMediaWindow();
127 return; 185 return;
128 } 186 }
129 187
130 m_LastItem = m_playList->currentItem(); 188 m_LastItem = m_playList->currentItem();
131 if (!m_LastItem) { 189 if (!m_LastItem) {
132 slotPlayNext(); 190 slotPlayNext();
133 return; 191 return;
134 } 192 }
135 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); 193 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn());
136 slotPlayCurrent(); 194 slotPlayCurrent();
137} 195}
138 196
197void PMainWindow::slotUserStop()
198{
199 if (!m_playing || !m_PlayLib) return;
200 m_playing = false;
201 m_PlayLib->stop();
202 m_scrollBar->setEnabled(false);
203 hideVideo();
204 slotShowList();
205}
206
207void PMainWindow::slotTogglePlay(bool how)
208{
209 if (how == m_playing) {
210 if (how) {
211 slotShowMediaWindow();
212 }
213 return;
214 }
215 if (how) {
216 slotPlayList();
217 } else {
218 slotUserStop();
219 }
220}
221
139void PMainWindow::hideVideo() 222void PMainWindow::hideVideo()
140{ 223{
141 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { 224 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) {
142 m_VideoPlayer->showNormal(); 225 //m_VideoPlayer->showNormal();
143 m_VideoPlayer->hide(); 226 m_VideoPlayer->hide();
144 } 227 }
145} 228}
146 229
147void PMainWindow::slotPlayCurrent() 230void PMainWindow::slotPlayCurrent()
148{ 231{
149 if (!m_LastItem) { 232 if (!m_LastItem) {
150 if (m_PlayLib) m_PlayLib->stop(); 233 if (m_PlayLib) m_PlayLib->stop();
234 m_scrollBar->setEnabled(false);
235 a_playAction->setOn(false);
151 hideVideo(); 236 hideVideo();
152 m_stack->raiseWidget(stack_list); 237 slotShowList();
153 return; 238 return;
154 } 239 }
155 checkLib(); 240 checkLib();
156 m_CurrentPos = 0; 241 m_CurrentPos = 0;
157 m_playList->setCurrentItem(m_LastItem); 242 m_playList->setCurrentItem(m_LastItem);
158 odebug << "Pos: " << m_PlayLib->currentTime() << oendl; 243 odebug << "Pos: " << m_PlayLib->currentTime() << oendl;
244 int result = 0;
159 if (!m_LastItem->isVideo()) { 245 if (!m_LastItem->isVideo()) {
160 hideVideo(); 246 hideVideo();
161 m_playing = true; 247 m_playing = true;
162 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
163 m_stack->raiseWidget(stack_audio); 248 m_stack->raiseWidget(stack_audio);
164 m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 249 result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
165 } else { 250 } else {
166 m_playing = true; 251 m_playing = true;
167 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
168 setupVideo(a_ShowFull->isOn()); 252 setupVideo(a_ShowFull->isOn());
169 m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 253 result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
170 } 254 }
255 if (result<0) {
256 // fehler
257 return;
258 }
259 mediaWindowraised();
260 odebug << "Range: " << result << oendl;
261 m_scrollBar->setRange(0,result);
262 m_scrollBar->setValue(0);
263 m_scrollBar->setEnabled(true);
264 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
171} 265}
172 266
173void PMainWindow::slotPlayNext() 267void PMainWindow::slotPlayNext()
174{ 268{
175 PlaylistItem*item = m_playList->nextItem(m_LastItem); 269 PlaylistItem*item = m_playList->nextItem(m_LastItem);
176 if (!item) return; 270 if (!item) return;
@@ -189,70 +283,81 @@ void PMainWindow::slotPlayPrevious()
189 PlaylistItem*item = m_playList->prevItem(m_LastItem); 283 PlaylistItem*item = m_playList->prevItem(m_LastItem);
190 if (!item) return; 284 if (!item) return;
191 m_LastItem = item; 285 m_LastItem = item;
192 slotPlayCurrent(); 286 slotPlayCurrent();
193} 287}
194 288
195void PMainWindow::slotUserStop()
196{
197 if (!m_playing || !m_PlayLib) return;
198 m_playing = false;
199 m_PlayLib->stop();
200 hideVideo();
201 m_stack->raiseWidget(stack_list);
202}
203
204void PMainWindow::slotStopped() 289void PMainWindow::slotStopped()
205{ 290{
206 if (!m_playing) return; 291 if (!m_playing) return;
207 m_playing = false; 292 m_playing = false;
208 slotGoNext(); 293 slotGoNext();
209} 294}
210 295
211void PMainWindow::slotCheckPos() 296void PMainWindow::slotCheckPos()
212{ 297{
213 if (!m_playing) return; 298 if (!m_playing) return;
214 emit sigPos(m_PlayLib->currentTime()); 299 //emit sigPos(m_PlayLib->currentTime());
300 m_scrollBar->setValue(m_PlayLib->currentTime());
215 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); 301 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) );
216} 302}
217 303
218void PMainWindow::slotRemoveFiles() 304void PMainWindow::slotRemoveFiles()
219{ 305{
220 slotUserStop(); 306 if (m_playing||!m_playList->isVisible()) return;
221 PlaylistItem* Item = m_playList->currentItem(); 307 PlaylistItem* Item = m_playList->currentItem();
222 m_stack->raiseWidget(stack_list); 308 slotShowList();
223 m_playList->removeFromList(Item); 309 m_playList->removeFromList(Item);
224} 310}
225 311
226void PMainWindow::setupActions() 312void PMainWindow::setupActions()
227{ 313{
228 a_appendFiles = new QAction(tr("Open file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); 314 a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false );
229 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); 315 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles()));
316 a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false);
317 connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir()));
318 a_loadPlaylist = new QAction(tr("Append .m3u playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false);
319 connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u()));
320 a_savePlaylist = new QAction(tr("Save .m3u playlist"),Resource::loadIconSet("save"),0,0,this,0,false);
321 connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u()));
322
323 playlistOnly = new QActionGroup(this,"playlistgroup",false);
324 playlistOnly->insert(a_appendFiles);
325 playlistOnly->insert(a_addDir);
326 playlistOnly->insert(a_loadPlaylist);
327 playlistOnly->insert(a_savePlaylist);
328
230 a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); 329 a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false );
231 connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); 330 connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList()));
331 a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false );
332 connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow()));
333
232 a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false ); 334 a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false );
233 connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles())); 335 connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles()));
234 336
235 playersGroup = new QActionGroup(this,"playgroup",false); 337 playersGroup = new QActionGroup(this,"playgroup",false);
236 338
237 a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, false ); 339 a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true);
238 connect(a_playAction,SIGNAL(activated()),this,SLOT(slotPlayList())); 340 a_playAction->setOn(false);
341 connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool)));
342
239 a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false ); 343 a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false );
240 connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext())); 344 connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext()));
241 a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false ); 345 a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false );
242 connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious())); 346 connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious()));
243 a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); 347 a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
244 connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); 348 connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool)));
245 a_stopPlay = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "stop" ), 0, 0, this, 0, false );
246 connect(a_stopPlay,SIGNAL(activated()),this,SLOT(slotUserStop()));
247 349
248 playersGroup->insert(a_playPrevious); 350 playersGroup->insert(a_playPrevious);
249 playersGroup->insert(a_playAction); 351 playersGroup->insert(a_playAction);
250 playersGroup->insert(a_stopPlay);
251 playersGroup->insert(a_playNext); 352 playersGroup->insert(a_playNext);
252 //playersGroup->insert(a_ShowFull); 353
354 /* initial states of actions */
355 a_showPlaylist->setEnabled(false);
356 a_removeFiles->setEnabled(false);
357 a_ShowMedia->setEnabled(false);
253} 358}
254 359
255void PMainWindow::setupToolBar() 360void PMainWindow::setupToolBar()
256{ 361{
257 setToolBarsMovable( false ); 362 setToolBarsMovable( false );
258 m_toolBar = new QToolBar( this ); 363 m_toolBar = new QToolBar( this );
@@ -260,31 +365,33 @@ void PMainWindow::setupToolBar()
260 m_menuBar=menuBar(); 365 m_menuBar=menuBar();
261 addToolBar(m_toolBar); 366 addToolBar(m_toolBar);
262 m_toolBar->setHorizontalStretchable( true ); 367 m_toolBar->setHorizontalStretchable( true );
263 a_appendFiles->addTo(m_toolBar); 368 a_appendFiles->addTo(m_toolBar);
264 a_removeFiles->addTo(m_toolBar); 369 a_removeFiles->addTo(m_toolBar);
265 a_showPlaylist->addTo(m_toolBar); 370 a_showPlaylist->addTo(m_toolBar);
371 a_ShowMedia->addTo(m_toolBar);
266 a_ShowFull->addTo(m_toolBar); 372 a_ShowFull->addTo(m_toolBar);
267 playersGroup->addTo(m_toolBar); 373 playersGroup->addTo(m_toolBar);
268} 374}
269 375
270void PMainWindow::setupVideo(bool full) 376void PMainWindow::setupVideo(bool full)
271{ 377{
272 if (full) { 378 if (full) {
273 m_VideoPlayer->setBackgroundColor(black); 379 m_VideoPlayer->setBackgroundColor(black);
274 m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); 380 m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
275 m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); 381 m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height());
276 m_VideoPlayer->showFullScreen(); 382 m_VideoPlayer->showFullScreen();
383 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
277 } else { 384 } else {
278 m_VideoPlayer->hide(); 385 m_VideoPlayer->hide();
386 m_VideoPlayer->disconnect(this);
279 m_stack->addWidget(m_VideoPlayer,stack_video); 387 m_stack->addWidget(m_VideoPlayer,stack_video);
280 m_stack->raiseWidget(stack_video); 388 m_stack->raiseWidget(stack_video);
281 } 389 }
390 mediaWindowraised();
282 m_VideoPlayer->fullScreen(full); 391 m_VideoPlayer->fullScreen(full);
283 m_VideoPlayer->disconnect(this);
284 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
285} 392}
286 393
287void PMainWindow::slotVideoclicked() 394void PMainWindow::slotVideoclicked()
288{ 395{
289 odebug << "PMainWindow::slotVideoclicked()" << oendl; 396 odebug << "PMainWindow::slotVideoclicked()" << oendl;
290 if (a_ShowFull->isOn()) { 397 if (a_ShowFull->isOn()) {
@@ -305,16 +412,21 @@ void PMainWindow::slotToggleFull(bool how)
305void PMainWindow::setupMenu() 412void PMainWindow::setupMenu()
306{ 413{
307 fileMenu = new QPopupMenu( m_menuBar ); 414 fileMenu = new QPopupMenu( m_menuBar );
308 m_menuBar->insertItem( tr( "Playlist" ), fileMenu ); 415 m_menuBar->insertItem( tr( "Playlist" ), fileMenu );
309 a_appendFiles->addTo(fileMenu); 416 a_appendFiles->addTo(fileMenu);
310 a_removeFiles->addTo(fileMenu); 417 a_removeFiles->addTo(fileMenu);
418 a_addDir->addTo(fileMenu);
419 fileMenu->insertSeparator();
420 a_loadPlaylist->addTo(fileMenu);
421 a_savePlaylist->addTo(fileMenu);
311 422
312 dispMenu = new QPopupMenu( m_menuBar ); 423 dispMenu = new QPopupMenu( m_menuBar );
313 m_menuBar->insertItem( tr( "Show" ), dispMenu ); 424 m_menuBar->insertItem( tr( "Show" ), dispMenu );
314 a_showPlaylist->addTo(dispMenu); 425 a_showPlaylist->addTo(dispMenu);
426 a_ShowMedia->addTo(dispMenu);
315 a_ShowFull->addTo(dispMenu); 427 a_ShowFull->addTo(dispMenu);
316 playMenu = new QPopupMenu(m_menuBar); 428 playMenu = new QPopupMenu(m_menuBar);
317 m_menuBar->insertItem(tr("Playing"),playMenu); 429 m_menuBar->insertItem(tr("Playing"),playMenu);
318 430
319 playersGroup->addTo(playMenu); 431 playersGroup->addTo(playMenu);
320} 432}
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h
index 28f820f..10c7a29 100644
--- a/noncore/multimedia/opieplayer3/mwindow.h
+++ b/noncore/multimedia/opieplayer3/mwindow.h
@@ -55,36 +55,42 @@ class PlaylistView;
55class QToolBar; 55class QToolBar;
56class QPopupMenu; 56class QPopupMenu;
57class QMenuBar; 57class QMenuBar;
58class AudioWidget; 58class AudioWidget;
59class VideoWidget; 59class VideoWidget;
60class PlaylistItem; 60class PlaylistItem;
61class QSlider;
61 62
62class PMainWindow : public QMainWindow { 63class PMainWindow : public QMainWindow {
63 Q_OBJECT 64 Q_OBJECT
64public: 65public:
65 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } 66 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); }
66 PMainWindow(QWidget*, const char*, WFlags ); 67 PMainWindow(QWidget*, const char*, WFlags );
67 virtual ~PMainWindow(); 68 virtual ~PMainWindow();
68 69
69public slots: 70public slots:
70 virtual void slotVideoclicked(); 71 virtual void slotVideoclicked();
71protected: 72protected:
73
74 /* GUI parts */
72 static const int stack_list = 0; 75 static const int stack_list = 0;
73 static const int stack_file = 1; 76 static const int stack_file = 1;
74 static const int stack_audio = 2; 77 static const int stack_audio = 2;
75 static const int stack_video = 3; 78 static const int stack_video = 3;
76 Opie::Ui::OWidgetStack *m_stack; 79 Opie::Ui::OWidgetStack *m_stack;
77 Opie::Ui::OFileSelector*m_sfl; 80 Opie::Ui::OFileSelector*m_sfl;
78 PlaylistView*m_playList; 81 PlaylistView*m_playList;
79 AudioWidget*m_AudioPlayer; 82 AudioWidget*m_AudioPlayer;
80 VideoWidget*m_VideoPlayer; 83 VideoWidget*m_VideoPlayer;
84 QWidget*m_MainBox;
85 QSlider*m_scrollBar;
81 86
82 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_deleteItem,*a_stopAction; 87 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction;
83 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay; 88 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia;
84 QActionGroup*playersGroup; 89 QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist;
90 QActionGroup*playersGroup,*playlistOnly;
85 QToolBar*m_toolBar; 91 QToolBar*m_toolBar;
86 QPopupMenu *fileMenu,*dispMenu,*playMenu; 92 QPopupMenu *fileMenu,*dispMenu,*playMenu;
87 QMenuBar*m_menuBar; 93 QMenuBar*m_menuBar;
88 XINE::Lib*m_PlayLib; 94 XINE::Lib*m_PlayLib;
89 95
90 void setupActions(); 96 void setupActions();
@@ -94,12 +100,13 @@ protected:
94 void setupVideo(bool full); 100 void setupVideo(bool full);
95 void hideVideo(); 101 void hideVideo();
96 102
97 bool m_playing:1; 103 bool m_playing:1;
98 int m_CurrentPos; 104 int m_CurrentPos;
99 PlaylistItem*m_LastItem; 105 PlaylistItem*m_LastItem;
106 void mediaWindowraised();
100 107
101protected slots: 108protected slots:
102 virtual void fileSelected(const DocLnk&); 109 virtual void fileSelected(const DocLnk&);
103 virtual void slotAppendFiles(); 110 virtual void slotAppendFiles();
104 virtual void slotRemoveFiles(); 111 virtual void slotRemoveFiles();
105 virtual void slotShowList(); 112 virtual void slotShowList();
@@ -109,12 +116,15 @@ protected slots:
109 virtual void slotPlayCurrent(); 116 virtual void slotPlayCurrent();
110 virtual void slotStopped(); 117 virtual void slotStopped();
111 virtual void slotCheckPos(); 118 virtual void slotCheckPos();
112 virtual void slotToggleFull(bool); 119 virtual void slotToggleFull(bool);
113 virtual void slotUserStop(); 120 virtual void slotUserStop();
114 virtual void slotGoNext(); 121 virtual void slotGoNext();
122 virtual void slotTogglePlay(bool);
123 virtual void slotShowMediaWindow();
124 virtual void slotListChanged(int);
115 125
116signals: 126signals:
117 void sigPos(int); 127 void sigPos(int);
118}; 128};
119 129
120#endif 130#endif
diff --git a/noncore/multimedia/opieplayer3/opieplayer3.pro b/noncore/multimedia/opieplayer3/opieplayer3.pro
index 1c7149f..a5d5def 100644
--- a/noncore/multimedia/opieplayer3/opieplayer3.pro
+++ b/noncore/multimedia/opieplayer3/opieplayer3.pro
@@ -1,13 +1,13 @@
1CONFIG = qt warn_on quick-app 1CONFIG = qt warn_on quick-app
2HEADERS = mwindow.h playlist.h ../opieplayer2/lib.h ../opieplayer2/threadutil.h \ 2HEADERS = mwindow.h playlist.h ../opieplayer2/lib.h ../opieplayer2/threadutil.h \
3 ../opieplayer2/alphablend.h ../opieplayer2/yuv2rgb.h \ 3 ../opieplayer2/alphablend.h ../opieplayer2/yuv2rgb.h ../opieplayer2/om3u.h \
4 audiowidget.h ../opieplayer2/xinevideowidget.h \ 4 audiowidget.h ../opieplayer2/xinevideowidget.h \
5 videowidget.h 5 videowidget.h
6SOURCES = mwindow.cpp playlist.cpp ../opieplayer2/lib.cpp ../opieplayer2/threadutil.cpp \ 6SOURCES = mwindow.cpp playlist.cpp ../opieplayer2/lib.cpp ../opieplayer2/threadutil.cpp \
7 ../opieplayer2/nullvideo.c \ 7 ../opieplayer2/nullvideo.c ../opieplayer2/om3u.cpp \
8 ../opieplayer2/alphablend.c ../opieplayer2/yuv2rgb.c \ 8 ../opieplayer2/alphablend.c ../opieplayer2/yuv2rgb.c \
9 audiowidget.cpp ../opieplayer2/xinevideowidget.cpp \ 9 audiowidget.cpp ../opieplayer2/xinevideowidget.cpp \
10 videowidget.cpp ../opieplayer2/yuv2rgb_arm2.c ../opieplayer2/yuv2rgb_arm4l.S 10 videowidget.cpp ../opieplayer2/yuv2rgb_arm2.c ../opieplayer2/yuv2rgb_arm4l.S
11 11
12TARGET = opie-mediaplayer3 12TARGET = opie-mediaplayer3
13INCLUDEPATH += $(OPIEDIR)/include 13INCLUDEPATH += $(OPIEDIR)/include
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp
index 272a71e..babe8ce 100644
--- a/noncore/multimedia/opieplayer3/playlist.cpp
+++ b/noncore/multimedia/opieplayer3/playlist.cpp
@@ -29,19 +29,26 @@
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#include "playlist.h" 33#include "playlist.h"
34#include "../opieplayer2/lib.h" 34#include "../opieplayer2/lib.h"
35#include "../opieplayer2/om3u.h"
35 36
36#include <opie2/odebug.h> 37#include <opie2/odebug.h>
37#include <opie2/oresource.h> 38#include <opie2/oresource.h>
39#include <opie2/ofiledialog.h>
38 40
39#include <qpe/resource.h> 41#include <qpe/resource.h>
40 42
41#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qmessagebox.h>
45#include <qdir.h>
46
47//#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.pls;*.m3u;*.mp4;*.m4a"
48#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.mp4;*.m4a"
42 49
43PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent) 50PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent)
44 :QListViewItem(parent),m_Content(aLink),m_video(false) 51 :QListViewItem(parent),m_Content(aLink),m_video(false)
45{ 52{
46} 53}
47 54
@@ -82,12 +89,13 @@ PlaylistView::PlaylistView(QWidget *parent, const char *name)
82 } 89 }
83 m_Infolib=0; 90 m_Infolib=0;
84 setAllColumnsShowFocus(true); 91 setAllColumnsShowFocus(true);
85 setSelectionMode(Single); 92 setSelectionMode(Single);
86 setSorting(-1); 93 setSorting(-1);
87 m_lastItem = 0; 94 m_lastItem = 0;
95 m_lastDir = QDir::homeDirPath();
88} 96}
89 97
90PlaylistView::~PlaylistView() 98PlaylistView::~PlaylistView()
91{ 99{
92 if (m_Infolib) delete m_Infolib; 100 if (m_Infolib) delete m_Infolib;
93} 101}
@@ -99,30 +107,62 @@ void PlaylistView::checkLib()
99 m_Infolib->ensureInitialized(); 107 m_Infolib->ensureInitialized();
100 } 108 }
101} 109}
102 110
103void PlaylistView::slotAddFile(const DocLnk&aLink) 111void PlaylistView::slotAddFile(const DocLnk&aLink)
104{ 112{
105 QFileInfo fileInfo(aLink.file()); 113 addFile(aLink.file(),aLink.name());
114 emit contentChanged(childCount());
115}
116
117void PlaylistView::addFile(const QString&aFile,const QString&aName)
118{
119 QFileInfo fileInfo(aFile);
106 if (!fileInfo.exists()) return; 120 if (!fileInfo.exists()) return;
107 checkLib(); 121 checkLib();
108
109 m_Infolib->stop(); 122 m_Infolib->stop();
110 123
111 if (m_lastItem) { 124 QString name = aName;
112 m_lastItem = new PlaylistItem(aLink,this,m_lastItem); 125 if (name.isEmpty()) {
113 } else { 126 name = fileInfo.fileName();
114 m_lastItem = new PlaylistItem(aLink,this);
115 } 127 }
116 m_lastItem->setExpandable(false); 128 int i = m_Infolib->setfile(aFile.utf8().data());
117 m_lastItem->setText(1,aLink.name()); 129 odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl;
118 int i = m_Infolib->setfile(aLink.file());
119 odebug << "File set: " << i << oendl;
120 if (i<1) { 130 if (i<1) {
131 i = m_Infolib->error();
132 odebug << "Errorcode: " << i << oendl;
133 QString msg;
134 msg = QString(tr("Error open file %1: ")).arg(name);
135 switch (i) {
136 case 1:
137 msg += tr("No input plugin");
138 break;
139 case 2:
140 msg += tr("No demuxer plugin");
141 break;
142 case 3:
143 msg += tr("Demuxer failed");
144 break;
145 case 4:
146 msg+=tr("Malformed mrl");
147 break;
148 default:
149 msg += tr("Unknown error");
150 break;
151 }
152 QMessageBox::warning(0,tr("Error reading fileheader"),msg);
121 return; 153 return;
122 } 154 }
155 m_lastItem = m_items.last();
156 if (m_lastItem) {
157 m_lastItem = new PlaylistItem(aFile,this,m_lastItem);
158 } else {
159 m_lastItem = new PlaylistItem(aFile,this);
160 }
161 m_lastItem->setExpandable(false);
162 m_lastItem->setText(1,name);
123 163
124 QString codec = m_Infolib->metaInfo(6); 164 QString codec = m_Infolib->metaInfo(6);
125 if (codec.isEmpty()) { 165 if (codec.isEmpty()) {
126 codec = m_Infolib->metaInfo(7); 166 codec = m_Infolib->metaInfo(7);
127 } 167 }
128 // codec 168 // codec
@@ -151,23 +191,92 @@ void PlaylistView::slotAddFile(const DocLnk&aLink)
151 codec+=QString("%1 s").arg(l); 191 codec+=QString("%1 s").arg(l);
152 } 192 }
153 // time 193 // time
154 m_lastItem->setText(COL_TIME,codec); 194 m_lastItem->setText(COL_TIME,codec);
155 m_lastItem->Video(m_Infolib->hasVideo()); 195 m_lastItem->Video(m_Infolib->hasVideo());
156 m_items.append(m_lastItem); 196 m_items.append(m_lastItem);
197 setSelected(m_lastItem,true);
198}
199
200void PlaylistView::slotAppendDir()
201{
202 QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir);
203 if (_dir.isEmpty()) return;
204 m_lastDir = _dir;
205 QDir sDir(_dir);
206 QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase);
207 for (unsigned i = 0; i < list.count();++i) {
208 addFile(_dir+QString("/")+list[i]);
209 }
210 emit contentChanged(childCount());
211}
212
213void PlaylistView::slotOpenM3u()
214{
215 QStringList types;
216 QMap<QString, QStringList> mimeTypes;
217 types << "audio/x-mpegurl";
218 mimeTypes.insert("Playlists",types);
219 mimeTypes.insert("All",types);
220 QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED,
221 m_lastDir,"playlist.m3u", mimeTypes);
222 if (fileName.isEmpty()) {
223 return;
224 }
225 QFileInfo f(fileName);
226
227 Om3u _om3u(fileName, IO_ReadOnly);
228 if (f.extension(FALSE).lower()=="m3u") {
229 _om3u.readM3u();
230 } else if (f.extension(FALSE).lower()=="pls") {
231 _om3u.readPls();
232 }
233 for (unsigned int j=0; j<_om3u.count();++j) {
234 addFile(_om3u[j]);
235 }
236 emit contentChanged(childCount());
237}
238
239void PlaylistView::slotSaveAsM3u()
240{
241 QStringList types;
242 QMap<QString, QStringList> mimeTypes;
243 types << "audio/x-mpegurl";
244 mimeTypes.insert("Playlists",types);
245 mimeTypes.insert("All",types);
246 QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED,
247 m_lastDir,"playlist.m3u", mimeTypes);
248 if (fileName.isEmpty()) {
249 return;
250 }
251 Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate);
252 for (unsigned j=0; j<m_items.count();++j) {
253 _om3u.add(m_items[j]->Lnk().file());
254 }
255 _om3u.write();
157} 256}
158 257
159void PlaylistView::removeFromList(PlaylistItem*Item) 258void PlaylistView::removeFromList(PlaylistItem*Item)
160{ 259{
161 if (!Item)return; 260 if (!Item)return;
162 t_itemlist::Iterator iter; 261 t_itemlist::Iterator iter,it2;
163 iter = m_items.find(Item); 262 iter = m_items.find(Item);
263 it2 = m_items.end();
164 if (iter!=m_items.end()) { 264 if (iter!=m_items.end()) {
265 it2 = iter;
266 ++it2;
165 m_items.remove(iter); 267 m_items.remove(iter);
166 } 268 }
167 delete Item; 269 delete Item;
270 if (it2!=m_items.end()) {
271 setSelected((*it2),true);
272 } else if (m_items.count()) {
273 QListViewItem * it = m_items.last();
274 setSelected(it,true);
275 }
276 emit contentChanged(childCount());
168} 277}
169 278
170XINE::Lib*PlaylistView::getXine() 279XINE::Lib*PlaylistView::getXine()
171{ 280{
172 checkLib(); 281 checkLib();
173 return m_Infolib; 282 return m_Infolib;
diff --git a/noncore/multimedia/opieplayer3/playlist.h b/noncore/multimedia/opieplayer3/playlist.h
index ad4c472..4a9268c 100644
--- a/noncore/multimedia/opieplayer3/playlist.h
+++ b/noncore/multimedia/opieplayer3/playlist.h
@@ -83,18 +83,26 @@ public:
83 COL_ARTIST=3, 83 COL_ARTIST=3,
84 COL_ALBUM=4, 84 COL_ALBUM=4,
85 COL_TITLE=5, 85 COL_TITLE=5,
86 COL_TYPE=6, 86 COL_TYPE=6,
87 COL_SIZE=7 87 COL_SIZE=7
88 }; 88 };
89 void addFile(const QString&aFile,const QString&aName="");
90signals:
91 void contentChanged(int);
92
89public slots: 93public slots:
90 virtual void slotAddFile(const DocLnk&); 94 virtual void slotAddFile(const DocLnk&);
95 virtual void slotAppendDir();
96 virtual void slotOpenM3u();
97 virtual void slotSaveAsM3u();
91 98
92protected: 99protected:
93 void checkLib(); 100 void checkLib();
94 QStringList columnLabels; 101 QStringList columnLabels;
95 XINE::Lib*m_Infolib; 102 XINE::Lib*m_Infolib;
96 PlaylistItem*m_lastItem; 103 PlaylistItem*m_lastItem;
97 t_itemlist m_items; 104 t_itemlist m_items;
105 QString m_lastDir;
98}; 106};
99 107
100#endif 108#endif
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp
index c5c63c7..a28d47d 100644
--- a/noncore/multimedia/opieplayer3/videowidget.cpp
+++ b/noncore/multimedia/opieplayer3/videowidget.cpp
@@ -16,22 +16,26 @@ VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f)
16{ 16{
17 m_xineLib = 0; 17 m_xineLib = 0;
18 18
19 m_MainLayout = new QVBoxLayout(this); 19 m_MainLayout = new QVBoxLayout(this);
20 m_MainLayout->setAutoAdd(true); 20 m_MainLayout->setAutoAdd(true);
21 m_Videodisplay = new XineVideoWidget(this,"videodisp"); 21 m_Videodisplay = new XineVideoWidget(this,"videodisp");
22#if 0
22 m_PosSlider = new QSlider(QSlider::Horizontal,this); 23 m_PosSlider = new QSlider(QSlider::Horizontal,this);
23 m_PosSlider->setTickInterval(60); 24 m_PosSlider->setTickInterval(60);
24 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); 25 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
25 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); 26 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
26 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); 27 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
27 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); 28 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
29#endif
28 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&))); 30 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
29 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked())); 31 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
32#if 0
30 m_pressed = false; 33 m_pressed = false;
31 m_uppos=0; 34 m_uppos=0;
35#endif
32} 36}
33 37
34VideoWidget::~VideoWidget() 38VideoWidget::~VideoWidget()
35{ 39{
36} 40}
37 41
@@ -42,59 +46,76 @@ void VideoWidget::slotClicked()
42} 46}
43 47
44void VideoWidget::closeEvent(QCloseEvent*e) 48void VideoWidget::closeEvent(QCloseEvent*e)
45{ 49{
46} 50}
47 51
48void VideoWidget::slotNewPos(int pos) 52void VideoWidget::slotNewPos(int /*pos*/)
49{ 53{
54#if 0
50 if (!m_xineLib) return; 55 if (!m_xineLib) return;
51 if (m_uppos==pos) return; 56 if (m_uppos==pos) return;
52 m_xineLib->seekTo(pos); 57 m_xineLib->seekTo(pos);
58#endif
53} 59}
54 60
55void VideoWidget::sliderPressed() 61void VideoWidget::sliderPressed()
56{ 62{
63#if 0
57 m_pressed = true; 64 m_pressed = true;
65#endif
58} 66}
59 67
60void VideoWidget::sliderReleased() 68void VideoWidget::sliderReleased()
61{ 69{
70#if 0
62 m_pressed = false; 71 m_pressed = false;
72#endif
63} 73}
64 74
65void VideoWidget::fullScreen(bool how) 75void VideoWidget::fullScreen(bool /* how */)
66{ 76{
77#if 0
67 if (how) { 78 if (how) {
68 m_PosSlider->hide(); 79 m_PosSlider->hide();
69 } else { 80 } else {
70 m_PosSlider->show(); 81 m_PosSlider->show();
71 } 82 }
83#endif
72} 84}
73 85
74void VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) 86int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
75{ 87{
76 m_current = aLnk; 88 m_current = aLnk;
89 bool recon;
77 if (m_xineLib != aLib) { 90 if (m_xineLib != aLib) {
78 disconnect(m_xineLib); 91 if (m_xineLib) disconnect(m_xineLib);
79 m_xineLib = aLib; 92 m_xineLib = aLib;
80 if (aLib) m_xineLib->setWidget(m_Videodisplay); 93 if (aLib) m_xineLib->setWidget(m_Videodisplay);
81 } 94 }
82 if (!m_xineLib) { 95 if (!m_xineLib) {
83 return; 96 return -1;
84 } 97 }
85 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 98 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
99#if 0
86 m_uppos=0; 100 m_uppos=0;
87 m_PosSlider->setValue(0); 101 m_PosSlider->setValue(0);
102#endif
88 m_xineLib->setWidget(m_Videodisplay); 103 m_xineLib->setWidget(m_Videodisplay);
89 m_xineLib->setShowVideo(true); 104 m_xineLib->setShowVideo(true);
90 m_xineLib->resize(m_Videodisplay->size()); 105 m_xineLib->resize(m_Videodisplay->size());
91 m_xineLib->play(m_current.file()); 106 int res = m_xineLib->play(m_current.file());
92 int l = m_xineLib->length(); 107 odebug << "Xine play: " << res << oendl;
108 if (res != 1) {
109 return -2;
110 }
111 return m_xineLib->length();
112#if 0
93 m_PosSlider->setRange(0,l); 113 m_PosSlider->setRange(0,l);
94 m_PosSlider->setPageStep(l/10); 114 m_PosSlider->setPageStep(l/10);
115#endif
95} 116}
96 117
97void VideoWidget::stopPlaying() 118void VideoWidget::stopPlaying()
98{ 119{
99 if (m_xineLib) { 120 if (m_xineLib) {
100 m_xineLib->stop(); 121 m_xineLib->stop();
@@ -111,12 +132,14 @@ void VideoWidget::slot_Videoresized(const QSize&s)
111 odebug << "Videoresized: " << s << oendl; 132 odebug << "Videoresized: " << s << oendl;
112 if (m_xineLib) { 133 if (m_xineLib) {
113 m_xineLib->resize(s); 134 m_xineLib->resize(s);
114 } 135 }
115} 136}
116 137
117void VideoWidget::updatePos(int val) 138void VideoWidget::updatePos(int /*val*/)
118{ 139{
140#if 0
119 if (m_pressed) return; 141 if (m_pressed) return;
120 m_uppos = val; 142 m_uppos = val;
121 m_PosSlider->setValue(val); 143 m_PosSlider->setValue(val);
144#endif
122} 145}
diff --git a/noncore/multimedia/opieplayer3/videowidget.h b/noncore/multimedia/opieplayer3/videowidget.h
index f181980..935a648 100644
--- a/noncore/multimedia/opieplayer3/videowidget.h
+++ b/noncore/multimedia/opieplayer3/videowidget.h
@@ -17,13 +17,13 @@ class VideoWidget:public QWidget
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 VideoWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); 20 VideoWidget( QWidget * parent=0, const char * name=0, WFlags f=0 );
21 virtual ~VideoWidget(); 21 virtual ~VideoWidget();
22 22
23 void playFile(const DocLnk&,XINE::Lib*); 23 int playFile(const DocLnk&,XINE::Lib*);
24 void fullScreen(bool how); 24 void fullScreen(bool how);
25 25
26signals: 26signals:
27 void videoclicked(); 27 void videoclicked();
28 28
29public slots: 29public slots:
@@ -33,15 +33,17 @@ public slots:
33protected: 33protected:
34 XINE::Lib*m_xineLib; 34 XINE::Lib*m_xineLib;
35 DocLnk m_current; 35 DocLnk m_current;
36 QVBoxLayout*m_MainLayout; 36 QVBoxLayout*m_MainLayout;
37 XineVideoWidget*m_Videodisplay; 37 XineVideoWidget*m_Videodisplay;
38 QWidget * m_holder; 38 QWidget * m_holder;
39#if 0
39 QSlider*m_PosSlider; 40 QSlider*m_PosSlider;
40 bool m_pressed:1; 41 bool m_pressed:1;
41 int m_uppos; 42 int m_uppos;
43#endif
42 44
43protected slots: 45protected slots:
44 virtual void closeEvent(QCloseEvent*e); 46 virtual void closeEvent(QCloseEvent*e);
45 virtual void slotNewPos(int pos); 47 virtual void slotNewPos(int pos);
46 virtual void sliderPressed(); 48 virtual void sliderPressed();
47 virtual void sliderReleased(); 49 virtual void sliderReleased();