summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer3/audiowidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer3/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.cpp110
1 files changed, 30 insertions, 80 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
@@ -14,133 +14,83 @@ 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
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;
71 if (m_xineLib != aLib) { 29 if (m_xineLib != aLib) {
72 if (m_xineLib) disconnect(m_xineLib); 30 if (m_xineLib) disconnect(m_xineLib);
73 m_xineLib = aLib; 31 m_xineLib = aLib;
74 } 32 }
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
90 QString artist = m_xineLib->metaInfo(2); 47 QString artist = m_xineLib->metaInfo(2);
91 // album 48 // album
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()
133{ 88{
134 if (m_xineLib) { 89 if (m_xineLib) {
135 m_xineLib->stop(); 90 m_xineLib->stop();
136 } 91 }
137} 92}
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}