summaryrefslogtreecommitdiff
authoralwin <alwin>2005-04-12 16:35:06 (UTC)
committer alwin <alwin>2005-04-12 16:35:06 (UTC)
commit4fd936e4096ba9c732bde17a48489bfbb94b19ba (patch) (unidiff)
treefa96015a24e24298c227bfa19314603debb1586d
parent6df2eb36803e072ea9db62153b762250742610f0 (diff)
downloadopie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.zip
opie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.tar.gz
opie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.tar.bz2
some gui stuff
may switch if videos will scaled up even if display size is larger than video size
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.cpp110
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.h10
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.cpp81
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.h16
-rw-r--r--noncore/multimedia/opieplayer3/playlist.cpp40
-rw-r--r--noncore/multimedia/opieplayer3/playlist.h2
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.cpp77
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.h11
8 files changed, 152 insertions, 195 deletions
diff --git a/noncore/multimedia/opieplayer3/audiowidget.cpp b/noncore/multimedia/opieplayer3/audiowidget.cpp
index b435c1b..aeebf45 100644
--- a/noncore/multimedia/opieplayer3/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer3/audiowidget.cpp
@@ -17,54 +17,12 @@ AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f)
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
21 m_PosSlider = new QSlider(QSlider::Horizontal,this);
22 m_PosSlider->setTickInterval(60);
23 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
24 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
25 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
26 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
27 m_pressed = false;
28 m_uppos=0;
29#endif
30} 20}
31 21
32AudioWidget::~AudioWidget() 22AudioWidget::~AudioWidget()
33{ 23{
34} 24}
35 25
36void AudioWidget::slotNewPos(int /* pos*/)
37{
38 if (!m_xineLib) return;
39#if 0
40 if (m_uppos==pos) return;
41 m_xineLib->seekTo(pos);
42#endif
43}
44
45void AudioWidget::sliderPressed()
46{
47#if 0
48 m_pressed = true;
49#endif
50}
51
52void AudioWidget::sliderReleased()
53{
54#if 0
55 m_pressed = false;
56#endif
57}
58
59void AudioWidget::closeEvent(QCloseEvent*e)
60{
61 odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl;
62 if (m_xineLib) {
63 m_xineLib->stop();
64 }
65 QWidget::closeEvent(e);
66}
67
68int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) 26int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
69{ 27{
70 m_current = aLnk; 28 m_current = aLnk;
@@ -75,15 +33,14 @@ int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
75 if (!m_xineLib) { 33 if (!m_xineLib) {
76 return -1; 34 return -1;
77 } 35 }
78#if 0 36 int res = m_xineLib->play(m_current.file(),0,0);
79 m_uppos=0;
80 m_PosSlider->setValue(0);
81#endif
82 m_xineLib->setShowVideo(false);
83 int res = m_xineLib->play(m_current.file());
84 if (res != 1) { 37 if (res != 1) {
85 return -2; 38 return -2;
86 } 39 }
40 if (!m_xineLib->hasVideo()) {
41 m_xineLib->setShowVideo( false );
42 }
43
87 // title 44 // title
88 QString title = m_xineLib->metaInfo(0); 45 QString title = m_xineLib->metaInfo(0);
89 // artist 46 // artist
@@ -92,41 +49,39 @@ int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
92 QString album = m_xineLib->metaInfo(4); 49 QString album = m_xineLib->metaInfo(4);
93 50
94 int l = m_xineLib->length(); 51 int l = m_xineLib->length();
95 int tmp = l; 52 QString laenge = secToString(l);
96#if 0 53 QString text = "<qt><center><table border=\"0\">";
97 m_PosSlider->setRange(0,l);
98#endif
99 QString laenge="";
100 int h = l/3600;
101 l-=h*3600;
102 int m = l/60;
103 l-=m*60;
104 if (h>0) {
105 laenge+=QString("%1 h").arg(h);
106 }
107 if (m>0) {
108 if (!laenge.isEmpty()) laenge+=" ";
109 laenge+=QString("%1 m").arg(m);
110 }
111 if (l>0) {
112 if (!laenge.isEmpty()) laenge+=" ";
113 laenge+=QString("%1 s").arg(l);
114 }
115 QString text = "<qt>";
116 if (artist.length()) { 54 if (artist.length()) {
117 text+="<H2><center>"+artist+"</center></h2>"; 55 text+="<tr><td>"+tr("Artist: ")+"</td><td><b>"+artist+"</b></td></tr>";
118 } 56 }
119 if (title.length()) { 57 if (title.length()) {
120 text+="<H2><center>"+title+"</center></h2>"; 58 text+="<tr><td>"+tr("Title: ")+"</td><td><font size=\"+2\">"+title+"</font></td></tr>";
121 } else { 59 } else {
122 text+="<H2><center>"+m_current.name()+"</center></h2>"; 60 text+="<tr><td>"+tr("Filename: ")+"</td><td><b>"+m_current.name()+"</b></td></tr>";
123 } 61 }
124 if (album.length()) { 62 if (album.length()) {
125 text+="<H2><center>"+album+"</center></h2>"; 63 text+="<tr><td>"+tr("Album: ")+"</td><td><b>"+album+"</b></td></tr>";
126 } 64 }
127 text+="<h3><center>"+laenge+"</center></h3>"; 65 text+="<tr><td>"+tr("Length: ")+"</td><td><b>"+laenge+"</b></td></tr>";
66 text+="</table></center></qt>";
128 m_InfoBox->setText(text); 67 m_InfoBox->setText(text);
129 return tmp; 68 return l;
69}
70
71QString AudioWidget::secToString(int sec)
72{
73 int l = sec;
74 int h = l/3600;
75 l-=h*3600;
76 int m = l/60;
77 l-=m*60;
78 QString s = "";
79 if (h>0) {
80 s.sprintf("%2i:%2i:%2i",h,m,l);
81 } else {
82 s.sprintf("%02i:%02i",m,l);
83 }
84 return s;
130} 85}
131 86
132void AudioWidget::stopPlaying() 87void AudioWidget::stopPlaying()
@@ -138,9 +93,4 @@ void AudioWidget::stopPlaying()
138 93
139void AudioWidget::updatePos(int /* val */) 94void AudioWidget::updatePos(int /* val */)
140{ 95{
141#if 0
142 if (m_pressed) return;
143 m_uppos = val;
144 m_PosSlider->setValue(val);
145#endif
146} 96}
diff --git a/noncore/multimedia/opieplayer3/audiowidget.h b/noncore/multimedia/opieplayer3/audiowidget.h
index 5e5dc09..abdd781 100644
--- a/noncore/multimedia/opieplayer3/audiowidget.h
+++ b/noncore/multimedia/opieplayer3/audiowidget.h
@@ -32,17 +32,9 @@ protected:
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
36 QSlider*m_PosSlider;
37 bool m_pressed;
38 int m_uppos;
39#endif
40 35
36 static QString secToString(int sec);
41protected slots: 37protected slots:
42 virtual void closeEvent(QCloseEvent*e);
43 virtual void slotNewPos(int pos);
44 virtual void sliderPressed();
45 virtual void sliderReleased();
46}; 38};
47 39
48#endif 40#endif
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp
index 57418f0..75d1490 100644
--- a/noncore/multimedia/opieplayer3/mwindow.cpp
+++ b/noncore/multimedia/opieplayer3/mwindow.cpp
@@ -60,6 +60,7 @@ using namespace Opie::Ui;
60PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) 60PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
61 : QMainWindow(w,name,f) 61 : QMainWindow(w,name,f)
62{ 62{
63 checkLib();
63 setCaption( QObject::tr("Opie Mediaplayer 3" ) ); 64 setCaption( QObject::tr("Opie Mediaplayer 3" ) );
64 65
65 m_MainBox = new QWidget(this); 66 m_MainBox = new QWidget(this);
@@ -69,9 +70,9 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
69 m_stack = new OWidgetStack(m_MainBox); 70 m_stack = new OWidgetStack(m_MainBox);
70 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 71 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
71 m_l->addWidget(m_stack); 72 m_l->addWidget(m_stack);
72 m_scrollBar = new QSlider(QSlider::Horizontal,m_MainBox); 73 m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox);
73 m_l->addWidget(m_scrollBar); 74 m_l->addWidget(m_PosSlider);
74 m_scrollBar->setEnabled(false); 75 m_PosSlider->setEnabled(false);
75 76
76 m_playList = new PlaylistView(m_stack,"playlist"); 77 m_playList = new PlaylistView(m_stack,"playlist");
77 m_stack->addWidget(m_playList,stack_list); 78 m_stack->addWidget(m_playList,stack_list);
@@ -87,8 +88,14 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
87 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); 88 connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int)));
88 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); 89 connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
89 90
91 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
92 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
93 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
94 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
95 m_pressed = false;
96 m_uppos=0;
97
90 m_stack->raiseWidget(stack_list); 98 m_stack->raiseWidget(stack_list);
91 m_PlayLib = 0;
92 m_LastItem = 0; 99 m_LastItem = 0;
93 setupActions(); 100 setupActions();
94 setupToolBar(); 101 setupToolBar();
@@ -99,6 +106,7 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
99 106
100void PMainWindow::slotListChanged(int count) 107void PMainWindow::slotListChanged(int count)
101{ 108{
109 playersGroup->setEnabled(count>0);
102 if (!m_playList->isVisible()) { 110 if (!m_playList->isVisible()) {
103 return; 111 return;
104 } 112 }
@@ -117,8 +125,9 @@ void PMainWindow::mediaWindowraised()
117void PMainWindow::checkLib() 125void PMainWindow::checkLib()
118{ 126{
119 if (m_PlayLib == 0) { 127 if (m_PlayLib == 0) {
120 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately); 128 m_PlayLib = new XINE::Lib(XINE::Lib::InitializeInThread);
121 m_PlayLib->ensureInitialized(); 129 qApp->processEvents();
130// m_PlayLib->ensureInitialized();
122 connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 131 connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
123 } 132 }
124} 133}
@@ -199,7 +208,7 @@ void PMainWindow::slotUserStop()
199 if (!m_playing || !m_PlayLib) return; 208 if (!m_playing || !m_PlayLib) return;
200 m_playing = false; 209 m_playing = false;
201 m_PlayLib->stop(); 210 m_PlayLib->stop();
202 m_scrollBar->setEnabled(false); 211 m_PosSlider->setEnabled(false);
203 hideVideo(); 212 hideVideo();
204 slotShowList(); 213 slotShowList();
205} 214}
@@ -231,16 +240,16 @@ void PMainWindow::slotPlayCurrent()
231{ 240{
232 if (!m_LastItem) { 241 if (!m_LastItem) {
233 if (m_PlayLib) m_PlayLib->stop(); 242 if (m_PlayLib) m_PlayLib->stop();
234 m_scrollBar->setEnabled(false); 243 m_PosSlider->setEnabled(false);
235 a_playAction->setOn(false); 244 a_playAction->setOn(false);
236 hideVideo(); 245 hideVideo();
237 slotShowList(); 246 slotShowList();
238 return; 247 return;
239 } 248 }
240 checkLib();
241 m_CurrentPos = 0; 249 m_CurrentPos = 0;
242 m_playList->setCurrentItem(m_LastItem); 250 m_playList->setCurrentItem(m_LastItem);
243 odebug << "Pos: " << m_PlayLib->currentTime() << oendl; 251 m_uppos = 0;
252 m_PosSlider->setValue(0);
244 int result = 0; 253 int result = 0;
245 if (!m_LastItem->isVideo()) { 254 if (!m_LastItem->isVideo()) {
246 hideVideo(); 255 hideVideo();
@@ -258,9 +267,9 @@ void PMainWindow::slotPlayCurrent()
258 } 267 }
259 mediaWindowraised(); 268 mediaWindowraised();
260 odebug << "Range: " << result << oendl; 269 odebug << "Range: " << result << oendl;
261 m_scrollBar->setRange(0,result); 270 m_PosSlider->setEnabled(true);
262 m_scrollBar->setValue(0); 271 m_PosSlider->setRange(0,m_PlayLib->length());
263 m_scrollBar->setEnabled(true); 272 m_PosSlider->setValue(m_PlayLib->currentTime());
264 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); 273 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
265} 274}
266 275
@@ -289,6 +298,7 @@ void PMainWindow::slotPlayPrevious()
289void PMainWindow::slotStopped() 298void PMainWindow::slotStopped()
290{ 299{
291 if (!m_playing) return; 300 if (!m_playing) return;
301 odebug << "Slot stopped" << oendl;
292 m_playing = false; 302 m_playing = false;
293 slotGoNext(); 303 slotGoNext();
294} 304}
@@ -296,8 +306,11 @@ void PMainWindow::slotStopped()
296void PMainWindow::slotCheckPos() 306void PMainWindow::slotCheckPos()
297{ 307{
298 if (!m_playing) return; 308 if (!m_playing) return;
299 //emit sigPos(m_PlayLib->currentTime()); 309 if (!m_pressed) {
300 m_scrollBar->setValue(m_PlayLib->currentTime()); 310 m_uppos = m_PlayLib->currentTime();
311 emit sigPos(m_uppos);
312 m_PosSlider->setValue(m_PlayLib->currentTime());
313 }
301 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); 314 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) );
302} 315}
303 316
@@ -315,9 +328,9 @@ void PMainWindow::setupActions()
315 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); 328 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); 329 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())); 330 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); 331 a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false);
319 connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); 332 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); 333 a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false);
321 connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); 334 connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u()));
322 335
323 playlistOnly = new QActionGroup(this,"playlistgroup",false); 336 playlistOnly = new QActionGroup(this,"playlistgroup",false);
@@ -351,10 +364,18 @@ void PMainWindow::setupActions()
351 playersGroup->insert(a_playAction); 364 playersGroup->insert(a_playAction);
352 playersGroup->insert(a_playNext); 365 playersGroup->insert(a_playNext);
353 366
367
354 /* initial states of actions */ 368 /* initial states of actions */
355 a_showPlaylist->setEnabled(false); 369 a_showPlaylist->setEnabled(false);
356 a_removeFiles->setEnabled(false); 370 a_removeFiles->setEnabled(false);
357 a_ShowMedia->setEnabled(false); 371 a_ShowMedia->setEnabled(false);
372 playersGroup->setEnabled(false);
373
374 settingsGroup = new QActionGroup(this,"configgroup",false);
375
376 a_Scaleup = new QAction(tr("Scale videos larger"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
377 connect(a_Scaleup,SIGNAL(toggled(bool)),this,SLOT(slot_scaleupToggled(bool)));
378 settingsGroup->insert(a_Scaleup);
358} 379}
359 380
360void PMainWindow::setupToolBar() 381void PMainWindow::setupToolBar()
@@ -427,6 +448,30 @@ void PMainWindow::setupMenu()
427 a_ShowFull->addTo(dispMenu); 448 a_ShowFull->addTo(dispMenu);
428 playMenu = new QPopupMenu(m_menuBar); 449 playMenu = new QPopupMenu(m_menuBar);
429 m_menuBar->insertItem(tr("Playing"),playMenu); 450 m_menuBar->insertItem(tr("Playing"),playMenu);
430
431 playersGroup->addTo(playMenu); 451 playersGroup->addTo(playMenu);
452 configMenu = new QPopupMenu(m_menuBar);
453 m_menuBar->insertItem(tr("Config"),configMenu);
454 settingsGroup->addTo(configMenu);
455}
456
457void PMainWindow::slotNewPos(int pos)
458{
459 if (!m_PlayLib) return;
460 if (m_uppos==pos) return;
461 m_PlayLib->seekTo(pos);
462}
463
464void PMainWindow::sliderPressed()
465{
466 m_pressed = true;
467}
468
469void PMainWindow::sliderReleased()
470{
471 m_pressed = false;
472}
473
474void PMainWindow::slot_scaleupToggled(bool how)
475{
476 m_VideoPlayer->scaleUp(how);
432} 477}
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h
index 10c7a29..5d011d5 100644
--- a/noncore/multimedia/opieplayer3/mwindow.h
+++ b/noncore/multimedia/opieplayer3/mwindow.h
@@ -82,14 +82,15 @@ protected:
82 AudioWidget*m_AudioPlayer; 82 AudioWidget*m_AudioPlayer;
83 VideoWidget*m_VideoPlayer; 83 VideoWidget*m_VideoPlayer;
84 QWidget*m_MainBox; 84 QWidget*m_MainBox;
85 QSlider*m_scrollBar; 85 QSlider*m_PosSlider;
86 86
87 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; 87 QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction;
88 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; 88 QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia;
89 QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; 89 QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist;
90 QActionGroup*playersGroup,*playlistOnly; 90 QAction*a_Scaleup;
91 QActionGroup*playersGroup,*playlistOnly,*settingsGroup;
91 QToolBar*m_toolBar; 92 QToolBar*m_toolBar;
92 QPopupMenu *fileMenu,*dispMenu,*playMenu; 93 QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu;
93 QMenuBar*m_menuBar; 94 QMenuBar*m_menuBar;
94 XINE::Lib*m_PlayLib; 95 XINE::Lib*m_PlayLib;
95 96
@@ -99,8 +100,10 @@ protected:
99 void checkLib(); 100 void checkLib();
100 void setupVideo(bool full); 101 void setupVideo(bool full);
101 void hideVideo(); 102 void hideVideo();
102
103 bool m_playing:1; 103 bool m_playing:1;
104 bool m_pressed:1;
105 int m_uppos;
106
104 int m_CurrentPos; 107 int m_CurrentPos;
105 PlaylistItem*m_LastItem; 108 PlaylistItem*m_LastItem;
106 void mediaWindowraised(); 109 void mediaWindowraised();
@@ -122,6 +125,11 @@ protected slots:
122 virtual void slotTogglePlay(bool); 125 virtual void slotTogglePlay(bool);
123 virtual void slotShowMediaWindow(); 126 virtual void slotShowMediaWindow();
124 virtual void slotListChanged(int); 127 virtual void slotListChanged(int);
128 virtual void slotNewPos(int pos);
129 virtual void sliderPressed();
130 virtual void sliderReleased();
131 virtual void slot_scaleupToggled(bool);
132
125 133
126signals: 134signals:
127 void sigPos(int); 135 void sigPos(int);
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp
index babe8ce..2eb40e3 100644
--- a/noncore/multimedia/opieplayer3/playlist.cpp
+++ b/noncore/multimedia/opieplayer3/playlist.cpp
@@ -104,13 +104,24 @@ void PlaylistView::checkLib()
104{ 104{
105 if (!m_Infolib) { 105 if (!m_Infolib) {
106 m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); 106 m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately);
107 connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop()));
107 m_Infolib->ensureInitialized(); 108 m_Infolib->ensureInitialized();
108 } 109 }
109} 110}
110 111
112void PlaylistView::slotDummyStop()
113{
114 odebug << "void PlaylistView::slotDummyStop()" << oendl;
115}
116
111void PlaylistView::slotAddFile(const DocLnk&aLink) 117void PlaylistView::slotAddFile(const DocLnk&aLink)
112{ 118{
113 addFile(aLink.file(),aLink.name()); 119 QFileInfo f(aLink.file());
120 if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") {
121 readPlayList(aLink.file());
122 } else {
123 addFile(aLink.file(),aLink.name());
124 }
114 emit contentChanged(childCount()); 125 emit contentChanged(childCount());
115} 126}
116 127
@@ -119,13 +130,13 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName)
119 QFileInfo fileInfo(aFile); 130 QFileInfo fileInfo(aFile);
120 if (!fileInfo.exists()) return; 131 if (!fileInfo.exists()) return;
121 checkLib(); 132 checkLib();
122 m_Infolib->stop();
123
124 QString name = aName; 133 QString name = aName;
125 if (name.isEmpty()) { 134 if (name.isEmpty()) {
126 name = fileInfo.fileName(); 135 name = fileInfo.fileName();
127 } 136 }
128 int i = m_Infolib->setfile(aFile.utf8().data()); 137 int i = m_Infolib->setfile(aFile.utf8().data());
138 /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */
139 m_Infolib->stop();
129 odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; 140 odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl;
130 if (i<1) { 141 if (i<1) {
131 i = m_Infolib->error(); 142 i = m_Infolib->error();
@@ -180,15 +191,9 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName)
180 l-=m*60; 191 l-=m*60;
181 codec = ""; 192 codec = "";
182 if (h>0) { 193 if (h>0) {
183 codec+=QString("%1 h").arg(h); 194 codec.sprintf("%2i:%2i:%2i h",h,m,l);
184 } 195 } else {
185 if (m>0) { 196 codec.sprintf("%02i:%02i m",m,l);
186 if (!codec.isEmpty()) codec+=" ";
187 codec+=QString("%1 m").arg(m);
188 }
189 if (l>0) {
190 if (!codec.isEmpty()) codec+=" ";
191 codec+=QString("%1 s").arg(l);
192 } 197 }
193 // time 198 // time
194 m_lastItem->setText(COL_TIME,codec); 199 m_lastItem->setText(COL_TIME,codec);
@@ -216,12 +221,18 @@ void PlaylistView::slotOpenM3u()
216 QMap<QString, QStringList> mimeTypes; 221 QMap<QString, QStringList> mimeTypes;
217 types << "audio/x-mpegurl"; 222 types << "audio/x-mpegurl";
218 mimeTypes.insert("Playlists",types); 223 mimeTypes.insert("Playlists",types);
219 mimeTypes.insert("All",types); 224// mimeTypes.insert("All",types);
220 QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, 225 QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED,
221 m_lastDir,"playlist.m3u", mimeTypes); 226 m_lastDir,"playlist.m3u", mimeTypes);
222 if (fileName.isEmpty()) { 227 if (fileName.isEmpty()) {
223 return; 228 return;
224 } 229 }
230 readPlayList(fileName);
231 emit contentChanged(childCount());
232}
233
234void PlaylistView::readPlayList(const QString&fileName)
235{
225 QFileInfo f(fileName); 236 QFileInfo f(fileName);
226 237
227 Om3u _om3u(fileName, IO_ReadOnly); 238 Om3u _om3u(fileName, IO_ReadOnly);
@@ -233,7 +244,6 @@ void PlaylistView::slotOpenM3u()
233 for (unsigned int j=0; j<_om3u.count();++j) { 244 for (unsigned int j=0; j<_om3u.count();++j) {
234 addFile(_om3u[j]); 245 addFile(_om3u[j]);
235 } 246 }
236 emit contentChanged(childCount());
237} 247}
238 248
239void PlaylistView::slotSaveAsM3u() 249void PlaylistView::slotSaveAsM3u()
@@ -242,9 +252,9 @@ void PlaylistView::slotSaveAsM3u()
242 QMap<QString, QStringList> mimeTypes; 252 QMap<QString, QStringList> mimeTypes;
243 types << "audio/x-mpegurl"; 253 types << "audio/x-mpegurl";
244 mimeTypes.insert("Playlists",types); 254 mimeTypes.insert("Playlists",types);
245 mimeTypes.insert("All",types);
246 QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, 255 QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED,
247 m_lastDir,"playlist.m3u", mimeTypes); 256 m_lastDir,"playlist.m3u", mimeTypes);
257 odebug << "Save as " << fileName << oendl;
248 if (fileName.isEmpty()) { 258 if (fileName.isEmpty()) {
249 return; 259 return;
250 } 260 }
diff --git a/noncore/multimedia/opieplayer3/playlist.h b/noncore/multimedia/opieplayer3/playlist.h
index 4a9268c..3c9a68d 100644
--- a/noncore/multimedia/opieplayer3/playlist.h
+++ b/noncore/multimedia/opieplayer3/playlist.h
@@ -95,9 +95,11 @@ public slots:
95 virtual void slotAppendDir(); 95 virtual void slotAppendDir();
96 virtual void slotOpenM3u(); 96 virtual void slotOpenM3u();
97 virtual void slotSaveAsM3u(); 97 virtual void slotSaveAsM3u();
98 virtual void slotDummyStop();
98 99
99protected: 100protected:
100 void checkLib(); 101 void checkLib();
102 void readPlayList(const QString&);
101 QStringList columnLabels; 103 QStringList columnLabels;
102 XINE::Lib*m_Infolib; 104 XINE::Lib*m_Infolib;
103 PlaylistItem*m_lastItem; 105 PlaylistItem*m_lastItem;
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp
index a28d47d..833ecb4 100644
--- a/noncore/multimedia/opieplayer3/videowidget.cpp
+++ b/noncore/multimedia/opieplayer3/videowidget.cpp
@@ -15,24 +15,12 @@ VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f)
15 :QWidget(parent,name,f) 15 :QWidget(parent,name,f)
16{ 16{
17 m_xineLib = 0; 17 m_xineLib = 0;
18 18 m_scaleUp = false;
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
23 m_PosSlider = new QSlider(QSlider::Horizontal,this);
24 m_PosSlider->setTickInterval(60);
25 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
26 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
27 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
28 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
29#endif
30 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&))); 22 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
31 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked())); 23 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
32#if 0
33 m_pressed = false;
34 m_uppos=0;
35#endif
36} 24}
37 25
38VideoWidget::~VideoWidget() 26VideoWidget::~VideoWidget()
@@ -41,7 +29,6 @@ VideoWidget::~VideoWidget()
41 29
42void VideoWidget::slotClicked() 30void VideoWidget::slotClicked()
43{ 31{
44 odebug << "clicked " << oendl;
45 emit videoclicked(); 32 emit videoclicked();
46} 33}
47 34
@@ -49,38 +36,8 @@ void VideoWidget::closeEvent(QCloseEvent*e)
49{ 36{
50} 37}
51 38
52void VideoWidget::slotNewPos(int /*pos*/)
53{
54#if 0
55 if (!m_xineLib) return;
56 if (m_uppos==pos) return;
57 m_xineLib->seekTo(pos);
58#endif
59}
60
61void VideoWidget::sliderPressed()
62{
63#if 0
64 m_pressed = true;
65#endif
66}
67
68void VideoWidget::sliderReleased()
69{
70#if 0
71 m_pressed = false;
72#endif
73}
74
75void VideoWidget::fullScreen(bool /* how */) 39void VideoWidget::fullScreen(bool /* how */)
76{ 40{
77#if 0
78 if (how) {
79 m_PosSlider->hide();
80 } else {
81 m_PosSlider->show();
82 }
83#endif
84} 41}
85 42
86int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) 43int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
@@ -96,23 +53,16 @@ int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
96 return -1; 53 return -1;
97 } 54 }
98 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 55 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
99#if 0
100 m_uppos=0;
101 m_PosSlider->setValue(0);
102#endif
103 m_xineLib->setWidget(m_Videodisplay); 56 m_xineLib->setWidget(m_Videodisplay);
104 m_xineLib->setShowVideo(true); 57 m_xineLib->setShowVideo(true);
105 m_xineLib->resize(m_Videodisplay->size());
106 int res = m_xineLib->play(m_current.file()); 58 int res = m_xineLib->play(m_current.file());
59 vSize = m_xineLib->videoSize();
60 slot_Videoresized(m_Videodisplay->size());
107 odebug << "Xine play: " << res << oendl; 61 odebug << "Xine play: " << res << oendl;
108 if (res != 1) { 62 if (res != 1) {
109 return -2; 63 return -2;
110 } 64 }
111 return m_xineLib->length(); 65 return m_xineLib->length();
112#if 0
113 m_PosSlider->setRange(0,l);
114 m_PosSlider->setPageStep(l/10);
115#endif
116} 66}
117 67
118void VideoWidget::stopPlaying() 68void VideoWidget::stopPlaying()
@@ -124,22 +74,27 @@ void VideoWidget::stopPlaying()
124 74
125void VideoWidget::slotStopped() 75void VideoWidget::slotStopped()
126{ 76{
127// check fullscreen here!
128} 77}
129 78
130void VideoWidget::slot_Videoresized(const QSize&s) 79void VideoWidget::slot_Videoresized(const QSize&s)
131{ 80{
132 odebug << "Videoresized: " << s << oendl;
133 if (m_xineLib) { 81 if (m_xineLib) {
134 m_xineLib->resize(s); 82 if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) {
83 m_xineLib->resize(vSize);
84 } else {
85 m_xineLib->resize(s);
86 }
135 } 87 }
136} 88}
137 89
90void VideoWidget::scaleUp(bool how)
91{
92 if (how == m_scaleUp) return;
93 m_scaleUp = how;
94 slot_Videoresized(m_Videodisplay->size());
95 m_Videodisplay->repaint();
96}
97
138void VideoWidget::updatePos(int /*val*/) 98void VideoWidget::updatePos(int /*val*/)
139{ 99{
140#if 0
141 if (m_pressed) return;
142 m_uppos = val;
143 m_PosSlider->setValue(val);
144#endif
145} 100}
diff --git a/noncore/multimedia/opieplayer3/videowidget.h b/noncore/multimedia/opieplayer3/videowidget.h
index 935a648..e082407 100644
--- a/noncore/multimedia/opieplayer3/videowidget.h
+++ b/noncore/multimedia/opieplayer3/videowidget.h
@@ -22,6 +22,7 @@ public:
22 22
23 int playFile(const DocLnk&,XINE::Lib*); 23 int playFile(const DocLnk&,XINE::Lib*);
24 void fullScreen(bool how); 24 void fullScreen(bool how);
25 void scaleUp(bool how);
25 26
26signals: 27signals:
27 void videoclicked(); 28 void videoclicked();
@@ -36,17 +37,11 @@ protected:
36 QVBoxLayout*m_MainLayout; 37 QVBoxLayout*m_MainLayout;
37 XineVideoWidget*m_Videodisplay; 38 XineVideoWidget*m_Videodisplay;
38 QWidget * m_holder; 39 QWidget * m_holder;
39#if 0 40 QSize vSize;
40 QSlider*m_PosSlider; 41 bool m_scaleUp:1;
41 bool m_pressed:1;
42 int m_uppos;
43#endif
44 42
45protected slots: 43protected slots:
46 virtual void closeEvent(QCloseEvent*e); 44 virtual void closeEvent(QCloseEvent*e);
47 virtual void slotNewPos(int pos);
48 virtual void sliderPressed();
49 virtual void sliderReleased();
50 virtual void slot_Videoresized(const QSize&); 45 virtual void slot_Videoresized(const QSize&);
51 virtual void slotStopped(); 46 virtual void slotStopped();
52 virtual void slotClicked(); 47 virtual void slotClicked();